Skip to content

Commit

Permalink
Merge branch 'fix/OPHKIOS-91_further-deps-upgrades' into feature/OPHK…
Browse files Browse the repository at this point in the history
…IOS-100
  • Loading branch information
jrkkp committed Sep 16, 2024
2 parents d445b64 + 09a56d7 commit 4977c03
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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');
Expand All @@ -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ä');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand All @@ -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ä');

Expand All @@ -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ä');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4977c03

Please sign in to comment.