From 8c5d632533955814d2326086c0459bec8b774ff8 Mon Sep 17 00:00:00 2001 From: Pyry Koivisto Date: Thu, 14 Nov 2024 08:28:57 +0200 Subject: [PATCH] VKT(Frontend): Fix cypress tests [deploy] --- .../clerk_create_exam_event_page.spec.ts | 4 +-- ....ts => clerk_excellent_level_page.spec.ts} | 36 +++++++++---------- .../clerk_exam_event_details.spec.ts | 4 +-- .../vkt/src/tests/cypress/support/commands.ts | 4 +-- ...HomePage.ts => clerkExcellentLevelPage.ts} | 4 +-- .../tests/cypress/support/types/index.d.ts | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) rename frontend/packages/vkt/src/tests/cypress/integration/{clerk_home_page.spec.ts => clerk_excellent_level_page.spec.ts} (50%) rename frontend/packages/vkt/src/tests/cypress/support/page-objects/{clerkHomePage.ts => clerkExcellentLevelPage.ts} (93%) diff --git a/frontend/packages/vkt/src/tests/cypress/integration/clerk_create_exam_event_page.spec.ts b/frontend/packages/vkt/src/tests/cypress/integration/clerk_create_exam_event_page.spec.ts index 17da4af6d..1b5515150 100644 --- a/frontend/packages/vkt/src/tests/cypress/integration/clerk_create_exam_event_page.spec.ts +++ b/frontend/packages/vkt/src/tests/cypress/integration/clerk_create_exam_event_page.spec.ts @@ -30,8 +30,8 @@ describe('ClerkCreateExamEventPage', () => { onClerkExamEventCreatePage.saveButtonEnabledIs(true); }); - it('should allow navigating back to clerk homepage', () => { + it('should allow navigating back to clerk excellent level page', () => { onClerkExamEventCreatePage.clickBackButton(); - cy.isOnPage(AppRoutes.ClerkHomePage); + cy.isOnPage(AppRoutes.ClerkExcellentLevelPage); }); }); diff --git a/frontend/packages/vkt/src/tests/cypress/integration/clerk_home_page.spec.ts b/frontend/packages/vkt/src/tests/cypress/integration/clerk_excellent_level_page.spec.ts similarity index 50% rename from frontend/packages/vkt/src/tests/cypress/integration/clerk_home_page.spec.ts rename to frontend/packages/vkt/src/tests/cypress/integration/clerk_excellent_level_page.spec.ts index 97728deef..bfffac484 100644 --- a/frontend/packages/vkt/src/tests/cypress/integration/clerk_home_page.spec.ts +++ b/frontend/packages/vkt/src/tests/cypress/integration/clerk_excellent_level_page.spec.ts @@ -1,56 +1,56 @@ import { AppRoutes, ExamEventToggleFilter, ExamLanguage } from 'enums/app'; -import { onClerkHomePage } from 'tests/cypress/support/page-objects/clerkHomePage'; +import { onClerkExcellentLevelPage } from 'tests/cypress/support/page-objects/clerkExcellentLevelPage'; const examEventCounts = { [ExamEventToggleFilter.Upcoming]: 6, [ExamEventToggleFilter.Passed]: 3, }; -describe('ClerkHomePage', () => { +describe('ClerkExcellentLevelPage', () => { beforeEach(() => { - cy.openClerkHomePage(); + cy.openClerkExcellentLevelPage(); }); it('should split listed exam events under upcoming and passed tabs', () => { - onClerkHomePage.expectFilteredExamEventsCount( + onClerkExcellentLevelPage.expectFilteredExamEventsCount( examEventCounts[ExamEventToggleFilter.Upcoming], ); - onClerkHomePage.clickToggleFilter(ExamEventToggleFilter.Passed); - onClerkHomePage.expectFilteredExamEventsCount( + onClerkExcellentLevelPage.clickToggleFilter(ExamEventToggleFilter.Passed); + onClerkExcellentLevelPage.expectFilteredExamEventsCount( examEventCounts[ExamEventToggleFilter.Passed], ); - onClerkHomePage.clickToggleFilter(ExamEventToggleFilter.Upcoming); - onClerkHomePage.expectFilteredExamEventsCount( + onClerkExcellentLevelPage.clickToggleFilter(ExamEventToggleFilter.Upcoming); + onClerkExcellentLevelPage.expectFilteredExamEventsCount( examEventCounts[ExamEventToggleFilter.Upcoming], ); - onClerkHomePage.expectUnusedSeatsNotification(); + onClerkExcellentLevelPage.expectUnusedSeatsNotification(); }); it('should allow filtering exam events by language', () => { - onClerkHomePage.filterByLanguage(ExamLanguage.FI); - onClerkHomePage.expectFilteredExamEventsCount(4); + onClerkExcellentLevelPage.filterByLanguage(ExamLanguage.FI); + onClerkExcellentLevelPage.expectFilteredExamEventsCount(4); - onClerkHomePage.filterByLanguage(ExamLanguage.SV); - onClerkHomePage.expectFilteredExamEventsCount(2); + onClerkExcellentLevelPage.filterByLanguage(ExamLanguage.SV); + onClerkExcellentLevelPage.expectFilteredExamEventsCount(2); - onClerkHomePage.filterByLanguage(ExamLanguage.ALL); - onClerkHomePage.expectFilteredExamEventsCount( + onClerkExcellentLevelPage.filterByLanguage(ExamLanguage.ALL); + onClerkExcellentLevelPage.expectFilteredExamEventsCount( examEventCounts[ExamEventToggleFilter.Upcoming], ); }); it('should allow navigating to exam event page by clicking related row', () => { - onClerkHomePage.clickExamEventRow(1); + onClerkExcellentLevelPage.clickExamEventRow(1); cy.isOnPage( AppRoutes.ClerkExamEventOverviewPage.replace(/:examEventId$/, '1'), ); }); it('should allow navigating to create exam event by clicking create button', () => { - onClerkHomePage.clickCreateExamEvent(); + onClerkExcellentLevelPage.clickCreateExamEvent(); cy.isOnPage(AppRoutes.ClerkExamEventCreatePage); }); @@ -60,6 +60,6 @@ describe('ClerkHomePage', () => { cy.setCookie('noAuth', 'true'); cy.wait(10); cy.tick(6 * 1000); - onClerkHomePage.expectSessionExpiredModal(); + onClerkExcellentLevelPage.expectSessionExpiredModal(); }); }); diff --git a/frontend/packages/vkt/src/tests/cypress/integration/examEventOverview/clerk_exam_event_details.spec.ts b/frontend/packages/vkt/src/tests/cypress/integration/examEventOverview/clerk_exam_event_details.spec.ts index a225e87fd..71e96a261 100644 --- a/frontend/packages/vkt/src/tests/cypress/integration/examEventOverview/clerk_exam_event_details.spec.ts +++ b/frontend/packages/vkt/src/tests/cypress/integration/examEventOverview/clerk_exam_event_details.spec.ts @@ -126,7 +126,7 @@ describe('ClerkExamEventOverview:ClerkExamEventDetails', () => { // Ensure navigation protection is no longer enabled after saving. onClerkExamEventOverviewPage.navigateBackToRegister(); - cy.isOnPage(AppRoutes.ClerkHomePage); + cy.isOnPage(AppRoutes.ClerkExcellentLevelPage); }); it('should display a confirmation dialog if the back button is clicked and there are unsaved changes', () => { @@ -140,7 +140,7 @@ describe('ClerkExamEventOverview:ClerkExamEventDetails', () => { onDialog.expectText('Haluatko varmasti poistua sivulta?'); onDialog.clickButtonByText('Kyllä'); - cy.isOnPage(AppRoutes.ClerkHomePage); + cy.isOnPage(AppRoutes.ClerkExcellentLevelPage); }); it('should display headings for enrollment status lists', () => { diff --git a/frontend/packages/vkt/src/tests/cypress/support/commands.ts b/frontend/packages/vkt/src/tests/cypress/support/commands.ts index e0a75e627..711084f6a 100644 --- a/frontend/packages/vkt/src/tests/cypress/support/commands.ts +++ b/frontend/packages/vkt/src/tests/cypress/support/commands.ts @@ -24,9 +24,9 @@ Cypress.Commands.add( }, ); -Cypress.Commands.add('openClerkHomePage', () => { +Cypress.Commands.add('openClerkExcellentLevelPage', () => { cy.window().then((win) => win.sessionStorage.setItem('persist:root', '{}')); - cy.visit(AppRoutes.ClerkHomePage); + cy.visit(AppRoutes.ClerkExcellentLevelPage); }); Cypress.Commands.add('openClerkExamEventPage', (examEventId: number) => { diff --git a/frontend/packages/vkt/src/tests/cypress/support/page-objects/clerkHomePage.ts b/frontend/packages/vkt/src/tests/cypress/support/page-objects/clerkExcellentLevelPage.ts similarity index 93% rename from frontend/packages/vkt/src/tests/cypress/support/page-objects/clerkHomePage.ts rename to frontend/packages/vkt/src/tests/cypress/support/page-objects/clerkExcellentLevelPage.ts index 7275bb2fa..e4bed79fa 100644 --- a/frontend/packages/vkt/src/tests/cypress/support/page-objects/clerkHomePage.ts +++ b/frontend/packages/vkt/src/tests/cypress/support/page-objects/clerkExcellentLevelPage.ts @@ -2,7 +2,7 @@ import { ExamEventToggleFilter, ExamLanguage } from 'enums/app'; const row = (id: number) => `clerk-exam-events__id-${id}-row`; -class ClerkHomePage { +class ClerkExcellentLevelPage { elements = { examEventRow: (id: number) => cy.findByTestId(row(id)), languageFilter: () => cy.findByTestId('language-filter'), @@ -49,4 +49,4 @@ class ClerkHomePage { } } -export const onClerkHomePage = new ClerkHomePage(); +export const onClerkExcellentLevelPage = new ClerkExcellentLevelPage(); 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 ca8568052..e4776e3d2 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 @@ -10,7 +10,7 @@ declare global { examEventId: number, persistedState?: string, ): void; - openClerkHomePage(): void; + openClerkExcellentLevelPage(): void; openClerkExamEventPage(examEventId: number): void; openClerkCreateExamEventPage(): void; usePhoneViewport(): void;