Skip to content

Commit

Permalink
VKT(Frontend): Rename publicHomePage -> publicExcellentLevelPage in C…
Browse files Browse the repository at this point in the history
…ypress tests
  • Loading branch information
pkoivisto committed Jan 3, 2025
1 parent d6904c9 commit 4f7bf57
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import { ExamLanguage } from 'enums/app';
import { onPublicHomePage } from 'tests/cypress/support/page-objects/publicHomePage';
import { onPublicExcellentLevelPage } from 'tests/cypress/support/page-objects/publicExcellentLevelPage';
import { publicExamEvents11 } from 'tests/msw/fixtures/publicExamEvents11';

describe('PublicHomePage (mobile)', () => {
beforeEach(() => {
cy.viewport('iphone-x');
cy.openPublicHomePage();
cy.openPublicExcellentLevelPage();
});

it('should allow filtering exam events based on exam language', () => {
onPublicHomePage.expectFilteredExamEventsCount(publicExamEvents11.length);
onPublicExcellentLevelPage.expectFilteredExamEventsCount(publicExamEvents11.length);

onPublicHomePage.filterByLanguage(ExamLanguage.FI);
onPublicHomePage.expectFilteredExamEventsCount(6);
onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.FI);
onPublicExcellentLevelPage.expectFilteredExamEventsCount(6);

onPublicHomePage.filterByLanguage(ExamLanguage.SV);
onPublicHomePage.expectFilteredExamEventsCount(5);
onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.SV);
onPublicExcellentLevelPage.expectFilteredExamEventsCount(5);

onPublicHomePage.filterByLanguage(ExamLanguage.ALL);
onPublicHomePage.expectFilteredExamEventsCount(publicExamEvents11.length);
onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.ALL);
onPublicExcellentLevelPage.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');
onPublicExcellentLevelPage.expectEnrollButtonDisabled(1);
onPublicExcellentLevelPage.expectEnrollButtonText(1, 'Ilmoittaudu myöhemmin');
onPublicExcellentLevelPage.expectEnrollButtonEnabled(2);
onPublicExcellentLevelPage.expectEnrollButtonText(2, 'Ilmoittaudu');
onPublicExcellentLevelPage.expectEnrollButtonEnabled(5);
onPublicExcellentLevelPage.expectEnrollButtonText(5, 'Ilmoittaudu jonoon');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ExamLanguage } from 'enums/app';
import { onCookieBanner } from 'tests/cypress/support/page-objects/cookieBanner';
import { onPublicHomePage } from 'tests/cypress/support/page-objects/publicHomePage';
import { onPublicExcellentLevelPage } from 'tests/cypress/support/page-objects/publicExcellentLevelPage';
import { publicExamEvents11 } from 'tests/msw/fixtures/publicExamEvents11';

describe('PublicHomePage', () => {
beforeEach(() => {
cy.openPublicHomePage();
cy.openPublicExcellentLevelPage();
});

it('should close cookie banner', () => {
Expand All @@ -15,24 +15,24 @@ describe('PublicHomePage', () => {
});

it('should allow filtering exam events based on exam language', () => {
onPublicHomePage.expectFilteredExamEventsCount(publicExamEvents11.length);
onPublicExcellentLevelPage.expectFilteredExamEventsCount(publicExamEvents11.length);

onPublicHomePage.filterByLanguage(ExamLanguage.FI);
onPublicHomePage.expectFilteredExamEventsCount(6);
onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.FI);
onPublicExcellentLevelPage.expectFilteredExamEventsCount(6);

onPublicHomePage.filterByLanguage(ExamLanguage.SV);
onPublicHomePage.expectFilteredExamEventsCount(5);
onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.SV);
onPublicExcellentLevelPage.expectFilteredExamEventsCount(5);

onPublicHomePage.filterByLanguage(ExamLanguage.ALL);
onPublicHomePage.expectFilteredExamEventsCount(publicExamEvents11.length);
onPublicExcellentLevelPage.filterByLanguage(ExamLanguage.ALL);
onPublicExcellentLevelPage.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');
onPublicExcellentLevelPage.expectEnrollButtonDisabled(1);
onPublicExcellentLevelPage.expectEnrollButtonText(1, 'Ilmoittaudu myöhemmin');
onPublicExcellentLevelPage.expectEnrollButtonEnabled(2);
onPublicExcellentLevelPage.expectEnrollButtonText(2, 'Ilmoittaudu');
onPublicExcellentLevelPage.expectEnrollButtonEnabled(5);
onPublicExcellentLevelPage.expectEnrollButtonText(5, 'Ilmoittaudu jonoon');
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AppRoutes } from 'enums/app';
import { RouteUtils } from 'utils/routes';

Cypress.Commands.add('openPublicHomePage', () => {
Cypress.Commands.add('openPublicExcellentLevelPage', () => {
cy.window().then((win) => {
win.sessionStorage.setItem('persist:root', '{}');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExamLanguage } from 'enums/app';

const row = (id: number) => `public-exam-events__id-${id}-row`;

class PublicHomePage {
class PublicExcellentLevelPage {
elements = {
enrollButton: (examEventId: number) =>
cy.findByTestId(`public-exam-events-${examEventId}__enroll-btn`),
Expand Down Expand Up @@ -89,4 +89,4 @@ class PublicHomePage {
}
}

export const onPublicHomePage = new PublicHomePage();
export const onPublicExcellentLevelPage = new PublicExcellentLevelPage();
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {};
declare global {
namespace Cypress {
interface Chainable {
openPublicHomePage(): void;
openPublicExcellentLevelPage(): void;
openPublicEnrollmentPage(
examEventId: number,
persistedState?: string,
Expand Down

0 comments on commit 4f7bf57

Please sign in to comment.