diff --git a/frontend/packages/akr/src/tests/cypress/integration/clerk/examination_dates.spec.ts b/frontend/packages/akr/src/tests/cypress/integration/clerk/examination_dates.spec.ts index b7ee1b565..a6908aada 100644 --- a/frontend/packages/akr/src/tests/cypress/integration/clerk/examination_dates.spec.ts +++ b/frontend/packages/akr/src/tests/cypress/integration/clerk/examination_dates.spec.ts @@ -13,7 +13,11 @@ const examinationDateToAdd = { version: 0, date: '2030-10-04', }; -const examinationDateToDelete = 5; + +const examinationDateToDelete = { + id: 5, + dateLabel: '18.11.2021', +}; beforeEach(() => { cy.fixture('examination_dates_10.json').then((dates) => { @@ -94,7 +98,8 @@ describe('ExaminationDatesPage', () => { }); it('should open a confirmation dialog when row delete icon is clicked, and do no changes if user backs out', () => { - onExaminationDatesPage.clickDeleteRowIcon(1); + onExaminationDatesPage.filterByStatus(ExaminationDateStatus.Passed); + onExaminationDatesPage.deleteExaminationDate(examinationDateToDelete.dateLabel); onDialog.expectText('Haluatko varmasti poistaa tutkintopäivän?'); onDialog.clickButtonByText('Takaisin'); @@ -103,38 +108,46 @@ describe('ExaminationDatesPage', () => { }); it('should open a confirmation dialog when row delete icon is clicked, and delete the selected examination date if user confirms', () => { - const newExaminationDates = examinationDates.filter( - (m) => m.id !== examinationDateToDelete, - ); - - cy.intercept('GET', APIEndpoints.ExaminationDate, [...newExaminationDates]); onExaminationDatesPage.filterByStatus(ExaminationDateStatus.Passed); - onExaminationDatesPage.clickDeleteRowIcon(1); + onExaminationDatesPage.deleteExaminationDate( + examinationDateToDelete.dateLabel, + ); cy.intercept( 'DELETE', - `${APIEndpoints.ExaminationDate}/${examinationDateToDelete}`, + `${APIEndpoints.ExaminationDate}/${examinationDateToDelete.id}`, {}, - ).as('delete'); + ).as('deleteExamDate'); + const newExaminationDates = examinationDates.filter( + (m) => m.id !== examinationDateToDelete.id, + ); + cy.intercept('GET', APIEndpoints.ExaminationDate, [ + ...newExaminationDates, + ]).as('examDatesReload'); onDialog.clickButtonByText('Kyllä'); - cy.wait('@delete'); + cy.wait('@deleteExamDate'); + cy.wait('@examDatesReload'); onExaminationDatesPage.expectRowToContain(0, '01.01.2022'); onExaminationDatesPage.expectRowToContain(1, '15.08.2021'); onExaminationDatesPage.expectTotalExaminationDatesCount(9); onExaminationDatesPage.expectSelectedExaminationDatesCount(5); - onToast.expectText('Tutkintopäivä 18.11.2021 poistettu'); + onToast.expectText( + `Tutkintopäivä ${examinationDateToDelete.dateLabel} poistettu`, + ); }); it('should show an error toast if examination date is chosen to be deleted, but an API error occurs', () => { onExaminationDatesPage.filterByStatus(ExaminationDateStatus.Passed); - onExaminationDatesPage.clickDeleteRowIcon(1); + onExaminationDatesPage.deleteExaminationDate( + examinationDateToDelete.dateLabel, + ); cy.intercept( 'DELETE', - `${APIEndpoints.ExaminationDate}/${examinationDateToDelete}`, + `${APIEndpoints.ExaminationDate}/${examinationDateToDelete.id}`, createAPIErrorResponse(APIError.ExaminationDateDeleteHasAuthorisations), ).as('deleteWithError'); onDialog.clickButtonByText('Kyllä'); diff --git a/frontend/packages/akr/src/tests/cypress/integration/clerk/meeting_dates.spec.ts b/frontend/packages/akr/src/tests/cypress/integration/clerk/meeting_dates.spec.ts index 7f1f73e1d..0f8aa56c1 100644 --- a/frontend/packages/akr/src/tests/cypress/integration/clerk/meeting_dates.spec.ts +++ b/frontend/packages/akr/src/tests/cypress/integration/clerk/meeting_dates.spec.ts @@ -13,8 +13,7 @@ const meetingDateToAdd = { version: 0, date: '2030-10-04', }; -const meetingDateToBeDeleted = 5; - +const meetingDateToBeDeleted = { id: 5, dateLabel: '18.11.2021' }; beforeEach(() => { cy.fixture('meeting_dates_10.json').then((dates) => { meetingDates = dates; @@ -93,7 +92,8 @@ describe('MeetingDatesPage', () => { }); it('should open a confirmation dialog when row delete icon is clicked, and do no changes if user backs out', () => { - onMeetingDatesPage.clickDeleteRowIcon(1); + onMeetingDatesPage.filterByStatus(MeetingDateStatus.Passed); + onMeetingDatesPage.deleteMeetingDate(meetingDateToBeDeleted.dateLabel); onDialog.expectText('Haluatko varmasti poistaa kokouspäivän?'); onDialog.clickButtonByText('Takaisin'); @@ -102,19 +102,18 @@ describe('MeetingDatesPage', () => { }); it('should open a confirmation dialog when row delete icon is clicked, and delete the selected meeting date if user confirms', () => { - const newMeetingDates = meetingDates.filter( - (m) => m.id !== meetingDateToBeDeleted, - ); - - cy.intercept('GET', APIEndpoints.MeetingDate, [...newMeetingDates]); onMeetingDatesPage.filterByStatus(MeetingDateStatus.Passed); - onMeetingDatesPage.clickDeleteRowIcon(1); + onMeetingDatesPage.deleteMeetingDate(meetingDateToBeDeleted.dateLabel); cy.intercept( 'DELETE', - `${APIEndpoints.MeetingDate}/${meetingDateToBeDeleted}`, + `${APIEndpoints.MeetingDate}/${meetingDateToBeDeleted.id}`, {}, ).as('delete'); + const newMeetingDates = meetingDates.filter( + (m) => m.id !== meetingDateToBeDeleted.id, + ); + cy.intercept('GET', APIEndpoints.MeetingDate, [...newMeetingDates]); onDialog.clickButtonByText('Kyllä'); @@ -123,16 +122,18 @@ describe('MeetingDatesPage', () => { onMeetingDatesPage.expectTotalMeetingDatesCount(9); onMeetingDatesPage.expectSelectedMeetingDatesCount(5); - onToast.expectText('Kokouspäivä 18.11.2021 poistettu'); + onToast.expectText( + `Kokouspäivä ${meetingDateToBeDeleted.dateLabel} poistettu`, + ); }); it('should show an error toast if meeting date is chosen to be deleted, but an API error occurs', () => { onMeetingDatesPage.filterByStatus(MeetingDateStatus.Passed); - onMeetingDatesPage.clickDeleteRowIcon(1); + onMeetingDatesPage.deleteMeetingDate(meetingDateToBeDeleted.dateLabel); cy.intercept( 'DELETE', - `${APIEndpoints.MeetingDate}/${meetingDateToBeDeleted}`, + `${APIEndpoints.MeetingDate}/${meetingDateToBeDeleted.id}`, createAPIErrorResponse(APIError.MeetingDateDeleteHasAuthorisations), ).as('deleteWithError'); onDialog.clickButtonByText('Kyllä'); diff --git a/frontend/packages/akr/src/tests/cypress/integration/public_translator.spec.ts b/frontend/packages/akr/src/tests/cypress/integration/public_translator.spec.ts index a12a4bdbd..df8084c45 100644 --- a/frontend/packages/akr/src/tests/cypress/integration/public_translator.spec.ts +++ b/frontend/packages/akr/src/tests/cypress/integration/public_translator.spec.ts @@ -111,8 +111,8 @@ describe('PublicTranslatorFilters', () => { it('it should show a toast notification when language pair is defined, a translator is selected, and user tries to change from lang', () => { onPublicTranslatorFilters.filterByLanguagePair(isPhone, 'suomi', 'ruotsi'); onPublicTranslatorsListing.clickTranslatorRow('1940'); - onPublicTranslatorFilters.clickFromLang(); - + const force = true; + onPublicTranslatorFilters.clickFromLang(force); onToast.expectText('Voit valita vain yhden kieliparin yhteydenottoon'); }); diff --git a/frontend/packages/akr/src/tests/cypress/support/page-objects/examinationDatesPage.ts b/frontend/packages/akr/src/tests/cypress/support/page-objects/examinationDatesPage.ts index 48e9f2c74..f3199dc9b 100644 --- a/frontend/packages/akr/src/tests/cypress/support/page-objects/examinationDatesPage.ts +++ b/frontend/packages/akr/src/tests/cypress/support/page-objects/examinationDatesPage.ts @@ -9,6 +9,12 @@ class ExaminationDatesPage { addButton: () => cy.findByTestId('examination-dates-page__add-btn'), tableRow: (i: number) => cy.get('.examination-dates__listing > tbody > tr').eq(i), + examinationDateRow: (date: string) => + cy + .get('.examination-dates__listing > tbody > tr') + .contains(date) + .first() + .parentsUntil('tr'), }; expectTotalExaminationDatesCount(count: number) { @@ -39,8 +45,13 @@ class ExaminationDatesPage { this.elements.addButton().should('be.visible').click(); } - clickDeleteRowIcon(i: number) { - this.elements.tableRow(i).find('button').should('be.visible').click(); + deleteExaminationDate(date: string) { + this.elements + .examinationDateRow(date) + .siblings() + .find('button') + .should('be.visible') + .click(); } } diff --git a/frontend/packages/akr/src/tests/cypress/support/page-objects/meetingDatesPage.ts b/frontend/packages/akr/src/tests/cypress/support/page-objects/meetingDatesPage.ts index 765fd38e2..6125cc65c 100644 --- a/frontend/packages/akr/src/tests/cypress/support/page-objects/meetingDatesPage.ts +++ b/frontend/packages/akr/src/tests/cypress/support/page-objects/meetingDatesPage.ts @@ -9,6 +9,12 @@ class MeetingDatesPage { addButton: () => cy.findByTestId('meeting-dates-page__add-btn'), tableRow: (i: number) => cy.get('.meeting-dates__listing > tbody > tr').eq(i), + meetingDateRow: (date: string) => + cy + .get('.meeting-dates__listing > tbody > tr') + .contains(date) + .first() + .parentsUntil('tr'), }; expectTotalMeetingDatesCount(count: number) { @@ -39,8 +45,13 @@ class MeetingDatesPage { this.elements.addButton().should('be.visible').click(); } - clickDeleteRowIcon(i: number) { - this.elements.tableRow(i).find('button').should('be.visible').click(); + deleteMeetingDate(date: string) { + this.elements + .meetingDateRow(date) + .siblings() + .find('button') + .should('be.visible') + .click(); } } diff --git a/frontend/packages/akr/src/tests/cypress/support/page-objects/publicTranslatorFilters.ts b/frontend/packages/akr/src/tests/cypress/support/page-objects/publicTranslatorFilters.ts index c0778d55b..f37595463 100644 --- a/frontend/packages/akr/src/tests/cypress/support/page-objects/publicTranslatorFilters.ts +++ b/frontend/packages/akr/src/tests/cypress/support/page-objects/publicTranslatorFilters.ts @@ -79,12 +79,12 @@ class PublicTranslatorFilters { this.elements.search().should('be.visible').click(); } - clickFromLang() { - this.elements.fromLangComboBox().should('be.visible').click(); + clickFromLang(force?: boolean) { + this.elements.fromLangComboBox().should('be.visible').click({ force }); } - clickToLang() { - this.elements.toLangComboBox().should('be.visible').click(); + clickToLang(force?: boolean) { + this.elements.toLangComboBox().should('be.visible').click({ force }); } expectSearchButtonTo(assert: string) {