diff --git a/frontend/packages/vkt/src/tests/cypress/integration/mobile_public_excellent_level_page.spec.ts b/frontend/packages/vkt/src/tests/cypress/integration/mobile_public_excellent_level_page.spec.ts new file mode 100644 index 000000000..8ea824d12 --- /dev/null +++ b/frontend/packages/vkt/src/tests/cypress/integration/mobile_public_excellent_level_page.spec.ts @@ -0,0 +1,39 @@ +import { ExamLanguage } from 'enums/app'; +import { onPublicExcellentLevelPage } from 'tests/cypress/support/page-objects/publicExcellentLevelPage'; +import { publicExamEvents11 } from 'tests/msw/fixtures/publicExamEvents11'; + +describe('PublicExcellentLevelPage (mobile)', () => { + beforeEach(() => { + cy.viewport('iphone-x'); + cy.openPublicExcellentLevelPage(); + }); + + it('should allow filtering exam events based on exam language', () => { + onPublicExcellentLevelPage.expectFilteredExamEventsCount( + publicExamEvents11.length, + ); + + onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.FI); + onPublicExcellentLevelPage.expectFilteredExamEventsCount(6); + + onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.SV); + onPublicExcellentLevelPage.expectFilteredExamEventsCount(5); + + onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.ALL); + onPublicExcellentLevelPage.expectFilteredExamEventsCount( + publicExamEvents11.length, + ); + }); + + it('should display enroll button correctly based on enrollment status', () => { + onPublicExcellentLevelPage.expectEnrollButtonDisabled(1); + onPublicExcellentLevelPage.expectEnrollButtonText( + 1, + 'Ilmoittaudu myöhemmin', + ); + onPublicExcellentLevelPage.expectEnrollButtonEnabled(2); + onPublicExcellentLevelPage.expectEnrollButtonText(2, 'Ilmoittaudu'); + onPublicExcellentLevelPage.expectEnrollButtonEnabled(5); + onPublicExcellentLevelPage.expectEnrollButtonText(5, 'Ilmoittaudu jonoon'); + }); +}); diff --git a/frontend/packages/vkt/src/tests/cypress/integration/mobile_public_home_page.spec.ts b/frontend/packages/vkt/src/tests/cypress/integration/mobile_public_home_page.spec.ts deleted file mode 100644 index a915238dc..000000000 --- a/frontend/packages/vkt/src/tests/cypress/integration/mobile_public_home_page.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { ExamLanguage } from 'enums/app'; -import { onPublicHomePage } from 'tests/cypress/support/page-objects/publicHomePage'; -import { publicExamEvents11 } from 'tests/msw/fixtures/publicExamEvents11'; - -describe('PublicHomePage (mobile)', () => { - beforeEach(() => { - cy.viewport('iphone-x'); - cy.openPublicHomePage(); - }); - - it('should allow filtering exam events based on exam language', () => { - onPublicHomePage.expectFilteredExamEventsCount(publicExamEvents11.length); - - onPublicHomePage.filterByLanguage(ExamLanguage.FI); - onPublicHomePage.expectFilteredExamEventsCount(6); - - onPublicHomePage.filterByLanguage(ExamLanguage.SV); - onPublicHomePage.expectFilteredExamEventsCount(5); - - onPublicHomePage.filterByLanguage(ExamLanguage.ALL); - onPublicHomePage.expectFilteredExamEventsCount(publicExamEvents11.length); - }); - - it('should display enroll button correctly based on enrollment status', () => { - onPublicHomePage.expectEnrollButtonDisabled(1); - onPublicHomePage.expectEnrollButtonText(1, 'Ilmoittaudu myöhemmin'); - onPublicHomePage.expectEnrollButtonEnabled(2); - onPublicHomePage.expectEnrollButtonText(2, 'Ilmoittaudu'); - onPublicHomePage.expectEnrollButtonEnabled(5); - onPublicHomePage.expectEnrollButtonText(5, 'Ilmoittaudu jonoon'); - }); -}); diff --git a/frontend/packages/vkt/src/tests/cypress/integration/public_enrollment.spec.ts b/frontend/packages/vkt/src/tests/cypress/integration/public_enrollment.spec.ts index 086f80253..821c0ec71 100644 --- a/frontend/packages/vkt/src/tests/cypress/integration/public_enrollment.spec.ts +++ b/frontend/packages/vkt/src/tests/cypress/integration/public_enrollment.spec.ts @@ -3,7 +3,7 @@ import { HTTPStatusCode } from 'shared/enums'; import { APIEndpoints } from 'enums/api'; import { PublicReservationResponse } from 'interfaces/publicEnrollment'; import { onPublicEnrollmentPage } from 'tests/cypress/support/page-objects/publicEnrollmentPage'; -import { onPublicHomePage } from 'tests/cypress/support/page-objects/publicHomePage'; +import { onPublicExcellentLevelPage } from 'tests/cypress/support/page-objects/publicExcellentLevelPage'; import { onToast } from 'tests/cypress/support/page-objects/toast'; import { fixedDateForTests } from 'tests/cypress/support/utils/date'; @@ -14,11 +14,11 @@ beforeEach(() => { describe('Public enrollment', () => { describe('to exam event with room', () => { it('reservation should have timer', () => { - onPublicHomePage.expectReservationTimeLeft('30', '00'); + onPublicExcellentLevelPage.expectReservationTimeLeft('30', '00'); cy.tick(3000); - onPublicHomePage.expectReservationTimeLeft('29', '57'); + onPublicExcellentLevelPage.expectReservationTimeLeft('29', '57'); cy.tick(30 * 60 * 1000); - onPublicHomePage.expectReservationTimeLeft('00', '00'); + onPublicExcellentLevelPage.expectReservationTimeLeft('00', '00'); }); it('reservation should allow renewal', () => { @@ -35,17 +35,17 @@ describe('Public enrollment', () => { body: response, }).as('renewReservation'); - onPublicHomePage.expectReservationTimeLeft('30', '00'); + onPublicExcellentLevelPage.expectReservationTimeLeft('30', '00'); cy.tick(29 * 60 * 1000); - onPublicHomePage.clickReservationRenewButton(); + onPublicExcellentLevelPage.clickReservationRenewButton(); cy.wait('@renewReservation'); cy.tick(30 * 1000); - onPublicHomePage.expectReservationTimeLeft('29', '30'); + onPublicExcellentLevelPage.expectReservationTimeLeft('29', '30'); }); it('reservation expired should display info modal', () => { cy.tick(31 * 60 * 1000); - onPublicHomePage.expectReservationExpiredOkButtonEnabled(); + onPublicExcellentLevelPage.expectReservationExpiredOkButtonEnabled(); }); it('should show session expired modal', () => { @@ -54,7 +54,7 @@ describe('Public enrollment', () => { cy.setCookie('noAuth', 'true'); cy.wait(10); cy.tick(6 * 1000); - onPublicHomePage.expectSessionExpiredModal(); + onPublicExcellentLevelPage.expectSessionExpiredModal(); }); it('should be able to fill out enrollment info', () => { @@ -233,13 +233,13 @@ describe('Public enrollment', () => { // TODO: Enable again once auth flow is complete. describe('errors when enroll button is clicked on the home page', () => { it.skip('exam event received congestion after the home page was opened', () => { - onPublicHomePage.clickEnrollButton(10); + onPublicExcellentLevelPage.clickEnrollButton(10); onToast.expectText('Tutkintotilaisuus on ruuhkautunut'); }); it.skip('registration to exam event closed after the home page was opened', () => { - onPublicHomePage.clickEnrollButton(11); + onPublicExcellentLevelPage.clickEnrollButton(11); onToast.expectText( 'Tutkintotilaisuuteen ilmoittautuminen on sulkeutunut', diff --git a/frontend/packages/vkt/src/tests/cypress/integration/public_excellent_level_page.spec.ts b/frontend/packages/vkt/src/tests/cypress/integration/public_excellent_level_page.spec.ts new file mode 100644 index 000000000..6a244d2f5 --- /dev/null +++ b/frontend/packages/vkt/src/tests/cypress/integration/public_excellent_level_page.spec.ts @@ -0,0 +1,45 @@ +import { ExamLanguage } from 'enums/app'; +import { onCookieBanner } from 'tests/cypress/support/page-objects/cookieBanner'; +import { onPublicExcellentLevelPage } from 'tests/cypress/support/page-objects/publicExcellentLevelPage'; +import { publicExamEvents11 } from 'tests/msw/fixtures/publicExamEvents11'; + +describe('PublicExcellentLevelPage', () => { + beforeEach(() => { + cy.openPublicExcellentLevelPage(); + }); + + it('should close cookie banner', () => { + onCookieBanner.closeBanner(); + + onCookieBanner.getBanner().should('not.exist'); + }); + + it('should allow filtering exam events based on exam language', () => { + onPublicExcellentLevelPage.expectFilteredExamEventsCount( + publicExamEvents11.length, + ); + + onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.FI); + onPublicExcellentLevelPage.expectFilteredExamEventsCount(6); + + onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.SV); + onPublicExcellentLevelPage.expectFilteredExamEventsCount(5); + + onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.ALL); + onPublicExcellentLevelPage.expectFilteredExamEventsCount( + publicExamEvents11.length, + ); + }); + + it('should display enroll button correctly based on enrollment status', () => { + onPublicExcellentLevelPage.expectEnrollButtonDisabled(1); + onPublicExcellentLevelPage.expectEnrollButtonText( + 1, + 'Ilmoittaudu myöhemmin', + ); + onPublicExcellentLevelPage.expectEnrollButtonEnabled(2); + onPublicExcellentLevelPage.expectEnrollButtonText(2, 'Ilmoittaudu'); + onPublicExcellentLevelPage.expectEnrollButtonEnabled(5); + onPublicExcellentLevelPage.expectEnrollButtonText(5, 'Ilmoittaudu jonoon'); + }); +}); diff --git a/frontend/packages/vkt/src/tests/cypress/integration/public_home_page.spec.ts b/frontend/packages/vkt/src/tests/cypress/integration/public_home_page.spec.ts deleted file mode 100644 index fbc3046f8..000000000 --- a/frontend/packages/vkt/src/tests/cypress/integration/public_home_page.spec.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { ExamLanguage } from 'enums/app'; -import { onCookieBanner } from 'tests/cypress/support/page-objects/cookieBanner'; -import { onPublicHomePage } from 'tests/cypress/support/page-objects/publicHomePage'; -import { publicExamEvents11 } from 'tests/msw/fixtures/publicExamEvents11'; - -describe('PublicHomePage', () => { - beforeEach(() => { - cy.openPublicHomePage(); - }); - - it('should close cookie banner', () => { - onCookieBanner.closeBanner(); - - onCookieBanner.getBanner().should('not.exist'); - }); - - it('should allow filtering exam events based on exam language', () => { - onPublicHomePage.expectFilteredExamEventsCount(publicExamEvents11.length); - - onPublicHomePage.filterByLanguage(ExamLanguage.FI); - onPublicHomePage.expectFilteredExamEventsCount(6); - - onPublicHomePage.filterByLanguage(ExamLanguage.SV); - onPublicHomePage.expectFilteredExamEventsCount(5); - - onPublicHomePage.filterByLanguage(ExamLanguage.ALL); - onPublicHomePage.expectFilteredExamEventsCount(publicExamEvents11.length); - }); - - it('should display enroll button correctly based on enrollment status', () => { - onPublicHomePage.expectEnrollButtonDisabled(1); - onPublicHomePage.expectEnrollButtonText(1, 'Ilmoittaudu myöhemmin'); - onPublicHomePage.expectEnrollButtonEnabled(2); - onPublicHomePage.expectEnrollButtonText(2, 'Ilmoittaudu'); - onPublicHomePage.expectEnrollButtonEnabled(5); - onPublicHomePage.expectEnrollButtonText(5, 'Ilmoittaudu jonoon'); - }); -}); diff --git a/frontend/packages/vkt/src/tests/cypress/support/commands.ts b/frontend/packages/vkt/src/tests/cypress/support/commands.ts index 711084f6a..af74989d8 100644 --- a/frontend/packages/vkt/src/tests/cypress/support/commands.ts +++ b/frontend/packages/vkt/src/tests/cypress/support/commands.ts @@ -2,6 +2,13 @@ import { AppRoutes } from 'enums/app'; import { RouteUtils } from 'utils/routes'; Cypress.Commands.add('openPublicHomePage', () => { + cy.window().then((win) => { + win.sessionStorage.setItem('persist:root', '{}'); + }); + cy.visit(AppRoutes.PublicHomePage); +}); + +Cypress.Commands.add('openPublicExcellentLevelPage', () => { cy.window().then((win) => { win.sessionStorage.setItem('persist:root', '{}'); }); diff --git a/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicExcellentLevelPage.ts b/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicExcellentLevelPage.ts new file mode 100644 index 000000000..16d328839 --- /dev/null +++ b/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicExcellentLevelPage.ts @@ -0,0 +1,92 @@ +import { ExamLanguage } from 'enums/app'; + +const row = (id: number) => `public-exam-events__id-${id}-row`; + +class PublicExcellentLevelPage { + elements = { + enrollButton: (examEventId: number) => + cy.findByTestId(`public-exam-events-${examEventId}__enroll-btn`), + examEventRow: (id: number) => cy.findByTestId(row(id)), + examEventRowCheckbox: (id: number) => + cy.findByTestId(row(id)).find('input[type=checkbox]'), + examEventRows: () => + cy + .get('.public-homepage__grid-container__result-box') + .find('table > tbody > tr'), + languageFilter: () => cy.findByTestId('language-filter'), + reservationTimerText: () => + cy.findByTestId('public-enrollment__reservation-timer-text'), + reservationRenewButton: () => + cy.findByTestId('public-enrollment__renew-reservation-modal-button'), + reservationExpiredOkButton: () => + cy.findByTestId('public-enrollment__reservation-expired-ok-button'), + enrollAuthenticateButton: () => + cy.findByTestId('public-enrollment__authenticate-button'), + sessionExpiredModal: () => cy.findByTestId('session-expired-modal'), + }; + + clickExamEventRow(id: number) { + this.elements.examEventRow(id).should('be.visible').click(); + } + + filterByLanguage(language: ExamLanguage) { + this.elements + .languageFilter() + .should('be.visible') + .get('[type="radio"]') + .check(language); + } + + expectFilteredExamEventsCount(count: number) { + this.elements.examEventRows().should('have.length', count); + } + + expectEnrollButtonText(examEventId: number, text: string) { + this.elements.enrollButton(examEventId).should('have.text', text); + } + + expectEnrollButtonDisabled(examEventId: number) { + this.elements.enrollButton(examEventId).should('be.disabled'); + } + + expectEnrollButtonEnabled(examEventId: number) { + this.elements.enrollButton(examEventId).should('be.enabled'); + } + + expectCheckboxChecked(id: number) { + this.elements.examEventRowCheckbox(id).should('be.checked'); + } + + expectCheckboxNotChecked(id: number) { + this.elements.examEventRowCheckbox(id).should('not.be.checked'); + } + + clickEnrollButton(examEventId) { + this.elements.enrollButton(examEventId).should('be.visible').click(); + } + + expectReservationExpiredOkButtonEnabled() { + this.elements.reservationExpiredOkButton().should('be.visible.enabled'); + } + + expectSessionExpiredModal() { + this.elements.sessionExpiredModal().should('be.visible'); + } + + clickEnrollAuthenticateButton() { + this.elements.enrollAuthenticateButton().should('be.visible').click(); + } + + clickReservationRenewButton() { + this.elements.reservationRenewButton().should('be.visible').click(); + } + + expectReservationTimeLeft(minutes: string, seconds: string) { + this.elements + .reservationTimerText() + .should('be.visible') + .should('contain.text', `${minutes}:${seconds}`); + } +} + +export const onPublicExcellentLevelPage = new PublicExcellentLevelPage(); diff --git a/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicGoodAndSatisfactoryLevelPage.ts b/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicGoodAndSatisfactoryLevelPage.ts new file mode 100644 index 000000000..e69de29bb diff --git a/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicHomePage.ts b/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicHomePage.ts index e07461954..c1c200f84 100644 --- a/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicHomePage.ts +++ b/frontend/packages/vkt/src/tests/cypress/support/page-objects/publicHomePage.ts @@ -1,92 +1,5 @@ -import { ExamLanguage } from 'enums/app'; - -const row = (id: number) => `public-exam-events__id-${id}-row`; - class PublicHomePage { - elements = { - enrollButton: (examEventId: number) => - cy.findByTestId(`public-exam-events-${examEventId}__enroll-btn`), - examEventRow: (id: number) => cy.findByTestId(row(id)), - examEventRowCheckbox: (id: number) => - cy.findByTestId(row(id)).find('input[type=checkbox]'), - examEventRows: () => - cy - .get('.public-homepage__grid-container__result-box') - .find('table > tbody > tr'), - languageFilter: () => cy.findByTestId('language-filter'), - reservationTimerText: () => - cy.findByTestId('public-enrollment__reservation-timer-text'), - reservationRenewButton: () => - cy.findByTestId('public-enrollment__renew-reservation-modal-button'), - reservationExpiredOkButton: () => - cy.findByTestId('public-enrollment__reservation-expired-ok-button'), - enrollAuthenticateButton: () => - cy.findByTestId('public-enrollment__authenticate-button'), - sessionExpiredModal: () => cy.findByTestId('session-expired-modal'), - }; - - clickExamEventRow(id: number) { - this.elements.examEventRow(id).should('be.visible').click(); - } - - filterByLanguage(language: ExamLanguage) { - this.elements - .languageFilter() - .should('be.visible') - .get('[type="radio"]') - .check(language); - } - - expectFilteredExamEventsCount(count: number) { - this.elements.examEventRows().should('have.length', count); - } - - expectEnrollButtonText(examEventId: number, text: string) { - this.elements.enrollButton(examEventId).should('have.text', text); - } - - expectEnrollButtonDisabled(examEventId: number) { - this.elements.enrollButton(examEventId).should('be.disabled'); - } - - expectEnrollButtonEnabled(examEventId: number) { - this.elements.enrollButton(examEventId).should('be.enabled'); - } - - expectCheckboxChecked(id: number) { - this.elements.examEventRowCheckbox(id).should('be.checked'); - } - - expectCheckboxNotChecked(id: number) { - this.elements.examEventRowCheckbox(id).should('not.be.checked'); - } - - clickEnrollButton(examEventId) { - this.elements.enrollButton(examEventId).should('be.visible').click(); - } - - expectReservationExpiredOkButtonEnabled() { - this.elements.reservationExpiredOkButton().should('be.visible.enabled'); - } - - expectSessionExpiredModal() { - this.elements.sessionExpiredModal().should('be.visible'); - } - - clickEnrollAuthenticateButton() { - this.elements.enrollAuthenticateButton().should('be.visible').click(); - } - - clickReservationRenewButton() { - this.elements.reservationRenewButton().should('be.visible').click(); - } - expectReservationTimeLeft(minutes: string, seconds: string) { - this.elements - .reservationTimerText() - .should('be.visible') - .should('contain.text', `${minutes}:${seconds}`); - } } -export const onPublicHomePage = new PublicHomePage(); +export const onPublicHomePage = new PublicHomePage(); \ No newline at end of file diff --git a/frontend/packages/vkt/src/tests/cypress/support/types/index.d.ts b/frontend/packages/vkt/src/tests/cypress/support/types/index.d.ts index e4776e3d2..687cbb6d8 100644 --- a/frontend/packages/vkt/src/tests/cypress/support/types/index.d.ts +++ b/frontend/packages/vkt/src/tests/cypress/support/types/index.d.ts @@ -6,6 +6,7 @@ declare global { namespace Cypress { interface Chainable { openPublicHomePage(): void; + openPublicExcellentLevelPage(): void; openPublicEnrollmentPage( examEventId: number, persistedState?: string,