Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions packages/web-app/cypress/e2e/associate-document-preview.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
describe('Previewing a document before association', () => {
beforeEach(() => {
cy.mockApiCatchAll();
cy.intercept(
{ method: 'GET', pathname: '/api/v1/entrances/42' },
{
body: {
id: 42,
name: 'Test entrance',
isDeleted: false,
documents: [],
massifs: [],
locations: [],
descriptions: [],
riggings: [],
histories: [],
comments: []
}
}
);
cy.intercept(
{ method: 'GET', pathname: '/api/v1/documents/types' },
{
body: { documentTypes: [] }
}
);
cy.intercept(
{ method: 'GET', pathname: '/api/v1/documents/subjects' },
{
body: { subjects: [] }
}
);
cy.intercept(
{ method: 'GET', pathname: '/api/v1/languages' },
{
body: { languages: [] }
}
);
cy.intercept(
{ method: 'GET', pathname: '/api/v1/licenses' },
{
body: { licenses: [] }
}
);
cy.intercept(
{ method: 'POST', pathname: '/api/v1/advanced-search' },
{
body: {
results: [
{
id: 7,
type: 'Article',
title: 'Preview document',
description: 'Document to inspect before association',
authors: []
}
],
totalResults: 1
}
}
).as('searchDocuments');
cy.intercept(
{ method: 'GET', pathname: '/api/v1/documents/7' },
{
body: {
id: 7,
title: 'Preview document',
type: 'Article',
files: [],
authors: [],
authorsOrganization: [],
massifs: [],
entrances: [],
isDeleted: false,
isValidated: true
}
}
).as('getDocument');
cy.intercept(
{ method: 'GET', pathname: '/api/v1/documents/7/children' },
{
body: { documents: [] }
}
);
});

it('keeps preview and selection separate in table and card views', () => {
cy.loginAs();
cy.visit('/entrances/42?tab=documents', {
onBeforeLoad: win => win.localStorage.setItem('selectedLanguage', 'en')
});
cy.get('[data-testid="associate-documents-button"]', {
timeout: 30000
}).click();
cy.get('input[placeholder="Search for a document..."]')
.closest('form')
.find('button[type="submit"]')
.click();
cy.wait('@searchDocuments');

cy.contains('tr', 'Preview document').click();
cy.wait('@getDocument');
cy.contains('[role="dialog"]', 'Detailed document view').should(
'contain.text',
'Preview document'
);
cy.contains('[role="dialog"]', 'Detailed document view')
.find('[aria-label="close"]')
.click();
cy.contains('[role="dialog"]', 'Detailed document view').should(
'not.exist'
);
cy.contains('button', 'Associate 0 documents').should('be.disabled');

cy.get('[aria-label="Card view"]').filter(':visible').first().click();
cy.viewport(390, 844);
cy.get('[aria-label="Preview"]').click();
cy.contains('[role="dialog"]', 'Detailed document view').should(
'contain.text',
'Preview document'
);
cy.contains('[role="dialog"]', 'Detailed document view')
.find('[aria-label="close"]')
.click();
cy.contains('[role="dialog"]', 'Detailed document view').should(
'not.exist'
);
cy.contains('button', 'Associate 0 documents').should('be.disabled');

cy.clock(null, ['setTimeout', 'clearTimeout']);
cy.contains('button', 'Preview document')
.find('input[type="checkbox"]')
.trigger('touchstart', {
force: true,
touches: [{ clientX: 10, clientY: 10 }]
});
cy.tick(600);
cy.contains('[role="dialog"]', 'Detailed document view').should(
'not.exist'
);
cy.contains('button', 'Preview document')
.find('input[type="checkbox"]')
.trigger('touchend', { force: true });
cy.contains('button', 'Preview document')
.find('input[type="checkbox"]')
.click({ force: true });
cy.contains('button', 'Associate 1 document').should('be.enabled');
cy.contains('button', 'Preview document')
.find('input[type="checkbox"]')
.click({ force: true });
cy.clock().invoke('restore');

cy.contains('Preview document').click();
cy.contains('button', 'Associate 1 document').should('be.enabled');
});

it('closes entrance association when a document is soft-deleted', () => {
let isDeleted = false;
cy.intercept({ method: 'GET', pathname: '/api/v1/documents/7' }, request =>
request.reply({
id: 7,
title: 'Preview document',
type: 'Article',
files: [],
authors: [],
authorsOrganization: [],
massifs: [],
entrances: [{ id: 42, name: 'Test entrance' }],
isDeleted,
isValidated: true
})
);
cy.intercept(
{ method: 'DELETE', pathname: '/api/v1/documents/7' },
request => {
isDeleted = true;
request.reply({ statusCode: 200, body: {} });
}
).as('deleteDocument');
cy.loginAs({ groups: ['User', 'Moderator'] });
cy.visit('/documents/7', {
onBeforeLoad: win => win.localStorage.setItem('selectedLanguage', 'en')
});
cy.get('[data-testid="associate-entrances-button"]', {
timeout: 30000
}).click();
cy.get('input[placeholder="Entrance name"]').should('exist');

cy.get('[aria-label="Delete"]').click();
cy.contains('[role="dialog"]', 'Deletion confirmation')
.contains('button', /^Delete$/)
.click();
cy.wait('@deleteDocument');

cy.get('[data-testid="associate-entrances-button"]').should('not.exist');
cy.get('input[placeholder="Entrance name"]').should('not.exist');
cy.contains('Test entrance').should('exist');
});
});
8 changes: 7 additions & 1 deletion packages/web-app/public/lang/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
"An article from a source": "مقالة من مصدر",
"An email has been sent to {email} to verify your account. Please click the link in the email to activate your account.": "تم إرسال بريد إلكتروني إلى {email} للتحقق من حسابك. يرجى النقر على الرابط الموجود في البريد الإلكتروني لتفعيل حسابك.",
"An email will be sent to:": "سيتم إرسال بريد إلكتروني إلى:",
"An entity cannot redirect to itself.": "لا يمكن إعادة التوجيه من كيان إلى نفسه.",
"An entrance with a similar name already exists. Please check whether it is the same cave before creating a new one.": "An entrance with a similar name already exists. Please check whether it is the same cave before creating a new one.",
"An error occurred when creating a massif.": "حدث خطأ عند إنشاء كتلة جبلية.",
"An error occurred when creating a network.": "حدث خطأ عند إنشاء شبكة.",
Expand Down Expand Up @@ -419,7 +420,9 @@
"Assign an existing document": "تعيين وثيقة موجودة",
"Associate": "ربط",
"Associate {nb} documents": "ربط {nb} وثيقة",
"Associate {nb} entrances": "ربط {nb} من المداخل",
"Associate 1 document": "ربط وثيقة واحدة",
"Associate 1 entrance": "ربط مدخل واحد",
"Associate to an entrance": "ربط بمدخل",
"at": "في",
"At least one polygon must not be marked as a hole.": "يجب ألا يُعلَّم ما لا يقل عن مضلع واحد كفجوة.",
Expand Down Expand Up @@ -1909,6 +1912,7 @@
"No files attached to this document.": "لا توجد ملفات مرفقة بهذا المستند.",
"No interest": "غير مثير للاهتمام",
"No issues in this collection.": "لا توجد أعداد في هذه المجموعة.",
"No linked entities.": "لا توجد كيانات مرتبطة.",
"No massif subscriptions": "لا توجد اشتراكات للكتلة الجبلية",
"No modifications allowed": "لا يُسمح بأي تعديلات",
"no name": "بدون اسم",
Expand Down Expand Up @@ -2353,7 +2357,8 @@
"Select an authorization document": "حدد مستند التخويل",
"Select an existing organization from the list, or a new one named \"{name}\" will be created.": "اختر منظمة موجودة من القائمة، وإلا فسيتم إنشاء منظمة جديدة باسم «{name}».",
"Select an identifier type": "حدد نوع المعرف",
"Select document(s) by clicking on the result table above.": "حدد المستند(ات) بالنقر على جدول النتائج أعلاه.",
"Select documents with the checkboxes. Preview any document before associating it.": "حدّد المستندات باستخدام مربعات الاختيار. عاين أي مستند قبل ربطه.",
"Select entrances with the checkboxes to associate them.": "حدد المداخل باستخدام مربعات الاختيار لربطها.",
"Select the attributes that apply to this entrance": "حدد الخصائص التي تنطبق على هذا المدخل",
"Selected": "محدد",
"Semi-major radius: ": "نصف القطر شبه الرئيسي: ",
Expand Down Expand Up @@ -2684,6 +2689,7 @@
"Unable to display this PDF.": "تعذّر عرض ملف PDF هذا.",
"Unable to load recent changes": "تعذر تحميل التغييرات الأخيرة",
"Unable to open the statistics dashboard. Please try again.": "تعذّر فتح لوحة الإحصاءات. يرجى المحاولة مرة أخرى.",
"Unable to search for a replacement. Please try again.": "تعذّر البحث عن كيان بديل. يرجى المحاولة مرة أخرى.",
"Unarchive": "إلغاء الأرشفة",
"Underground time": "الوقت تحت الأرض",
"Underground time (short)": "تحت الأرض",
Expand Down
8 changes: 7 additions & 1 deletion packages/web-app/public/lang/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
"An article from a source": "Статия от източник",
"An email has been sent to {email} to verify your account. Please click the link in the email to activate your account.": "На {email} е изпратен имейл за проверка на вашия акаунт. Моля, щракнете на връзката в имейла, за да активирате вашия акаунт.",
"An email will be sent to:": "Ще бъде изпратен имейл до:",
"An entity cannot redirect to itself.": "Обектът не може да пренасочва към себе си.",
"An entrance with a similar name already exists. Please check whether it is the same cave before creating a new one.": "An entrance with a similar name already exists. Please check whether it is the same cave before creating a new one.",
"An error occurred when creating a massif.": "Възникна грешка при създаването на масив.",
"An error occurred when creating a network.": "Възникна грешка при създаването на мрежа.",
Expand Down Expand Up @@ -419,7 +420,9 @@
"Assign an existing document": "Присвояване на съществуващ документ",
"Associate": "Сътрудник",
"Associate {nb} documents": "Свързване на {nb} документа",
"Associate {nb} entrances": "Свързване на {nb} входа",
"Associate 1 document": "Свързване на 1 документ",
"Associate 1 entrance": "Свързване на 1 вход",
"Associate to an entrance": "Свържете с вход",
"at": "в",
"At least one polygon must not be marked as a hole.": "Поне един полигон не трябва да бъде маркиран като дупка.",
Expand Down Expand Up @@ -1909,6 +1912,7 @@
"No files attached to this document.": "Към този документ не са прикачени файлове.",
"No interest": "Без интерес",
"No issues in this collection.": "Няма броеве в тази колекция.",
"No linked entities.": "Няма свързани обекти.",
"No massif subscriptions": "Няма абонаменти за масив",
"No modifications allowed": "Не се разрешават промени",
"no name": "без име",
Expand Down Expand Up @@ -2353,7 +2357,8 @@
"Select an authorization document": "Изберете документ за разрешение",
"Select an existing organization from the list, or a new one named \"{name}\" will be created.": "Изберете съществуваща организация от списъка, в противен случай ще бъде създадена нова с име „{name}“.",
"Select an identifier type": "Изберете тип идентификатор",
"Select document(s) by clicking on the result table above.": "Изберете документ(и), като щракнете върху таблицата с резултати по-горе.",
"Select documents with the checkboxes. Preview any document before associating it.": "Изберете документи с квадратчетата за отметка. Прегледайте всеки документ, преди да го свържете.",
"Select entrances with the checkboxes to associate them.": "Изберете входовете с отметките, за да ги свържете.",
"Select the attributes that apply to this entrance": "Изберете характеристиките, които се отнасят за този вход",
"Selected": "Избрано",
"Semi-major radius: ": "Голяма полуос",
Expand Down Expand Up @@ -2684,6 +2689,7 @@
"Unable to display this PDF.": "Този PDF файл не може да бъде показан.",
"Unable to load recent changes": "Скорошните промени не могат да бъдат заредени",
"Unable to open the statistics dashboard. Please try again.": "Неуспешно отваряне на таблото със статистики. Моля, опитайте отново.",
"Unable to search for a replacement. Please try again.": "Неуспешно търсене на заместващ обект. Моля, опитайте отново.",
"Unarchive": "Разархивиране",
"Underground time": "Време под земята",
"Underground time (short)": "Под земята",
Expand Down
8 changes: 7 additions & 1 deletion packages/web-app/public/lang/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
"An article from a source": "Un article d'una font",
"An email has been sent to {email} to verify your account. Please click the link in the email to activate your account.": "S'ha enviat un correu a {email} per verificar el teu compte. Fes clic a l'enllaç del correu per activar el teu compte.",
"An email will be sent to:": "S'enviarà un correu electrònic a:",
"An entity cannot redirect to itself.": "Una entitat no pot redirigir a si mateixa.",
"An entrance with a similar name already exists. Please check whether it is the same cave before creating a new one.": "An entrance with a similar name already exists. Please check whether it is the same cave before creating a new one.",
"An error occurred when creating a massif.": "S'ha produït un error en crear un massís.",
"An error occurred when creating a network.": "S'ha produït un error en crear una xarxa.",
Expand Down Expand Up @@ -419,7 +420,9 @@
"Assign an existing document": "Assignar un document existent",
"Associate": "Associar",
"Associate {nb} documents": "Associar {nb} documents",
"Associate {nb} entrances": "Associar {nb} entrades",
"Associate 1 document": "Associar 1 document",
"Associate 1 entrance": "Associar 1 entrada",
"Associate to an entrance": "Associa a una entrada",
"at": "a",
"At least one polygon must not be marked as a hole.": "Almenys un polígon no ha d'estar marcat com a forat.",
Expand Down Expand Up @@ -1909,6 +1912,7 @@
"No files attached to this document.": "No hi ha fitxers adjunts a aquest document.",
"No interest": "Sense interès",
"No issues in this collection.": "No hi ha números en aquesta col·lecció.",
"No linked entities.": "No hi ha entitats vinculades.",
"No massif subscriptions": "Sense subscripcions al massís",
"No modifications allowed": "No es permeten modificacions",
"no name": "sense nom",
Expand Down Expand Up @@ -2353,7 +2357,8 @@
"Select an authorization document": "Seleccioneu un document d'autorització",
"Select an existing organization from the list, or a new one named \"{name}\" will be created.": "Seleccioneu una organització existent de la llista; en cas contrari, se'n crearà una de nova anomenada «{name}».",
"Select an identifier type": "Selecciona un tipus d'identificador",
"Select document(s) by clicking on the result table above.": "Seleccioneu els documents fent clic a la taula de resultats de dalt.",
"Select documents with the checkboxes. Preview any document before associating it.": "Seleccioneu els documents amb les caselles de selecció. Previsualitzeu qualsevol document abans d'associar-lo.",
"Select entrances with the checkboxes to associate them.": "Seleccioneu les entrades amb les caselles per associar-les.",
"Select the attributes that apply to this entrance": "Seleccioneu els atributs que s'apliquen a aquesta entrada",
"Selected": "Escollit",
"Semi-major radius: ": "Semieix major :",
Expand Down Expand Up @@ -2684,6 +2689,7 @@
"Unable to display this PDF.": "No es pot mostrar aquest PDF.",
"Unable to load recent changes": "No s'han pogut carregar els canvis recents",
"Unable to open the statistics dashboard. Please try again.": "No s'ha pogut obrir el tauler d'estadístiques. Torneu-ho a provar.",
"Unable to search for a replacement. Please try again.": "No s'ha pogut cercar una entitat de substitució. Torneu-ho a provar.",
"Unarchive": "Desarxivar",
"Underground time": "Moment de ficar-se sota terra",
"Underground time (short)": "Sota terra",
Expand Down
Loading
Loading