Skip to content

Commit

Permalink
VKT(Frontend): Fix cypress tests [deploy]
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoivisto committed Nov 14, 2024
1 parent aa841d8 commit 8c5d632
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Original file line number Diff line number Diff line change
@@ -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);
});

Expand All @@ -60,6 +60,6 @@ describe('ClerkHomePage', () => {
cy.setCookie('noAuth', 'true');
cy.wait(10);
cy.tick(6 * 1000);
onClerkHomePage.expectSessionExpiredModal();
onClerkExcellentLevelPage.expectSessionExpiredModal();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/packages/vkt/src/tests/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -49,4 +49,4 @@ class ClerkHomePage {
}
}

export const onClerkHomePage = new ClerkHomePage();
export const onClerkExcellentLevelPage = new ClerkExcellentLevelPage();
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ declare global {
examEventId: number,
persistedState?: string,
): void;
openClerkHomePage(): void;
openClerkExcellentLevelPage(): void;
openClerkExamEventPage(examEventId: number): void;
openClerkCreateExamEventPage(): void;
usePhoneViewport(): void;
Expand Down

0 comments on commit 8c5d632

Please sign in to comment.