-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VKT(Frontend): PublicGoodAndSatisfactoryLevelPage cypress tests
- Loading branch information
Showing
6 changed files
with
201 additions
and
2 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...ackages/vkt/src/tests/cypress/integration/public_good_and_satisfactory_level_page.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { onCookieBanner } from 'tests/cypress/support/page-objects/cookieBanner'; | ||
import { onPublicGoodAndSatisfactoryLevelPage } from 'tests/cypress/support/page-objects/publicGoodAndSatisfactoryLevelPage'; | ||
import { AppRoutes, ExamLanguage } from 'enums/app'; | ||
import { publicExaminers } from 'tests/msw/fixtures/publicExaminer'; | ||
|
||
describe('PublicGoodAndSatisfactoryLevelPage', () => { | ||
beforeEach(() => { | ||
cy.openPublicGoodAndSatisfactoryLevelPage(); | ||
onCookieBanner.closeBanner(); | ||
}); | ||
|
||
it('should allow filtering examiners by exam language', () => { | ||
onPublicGoodAndSatisfactoryLevelPage.filterExaminersByExamLanguage( | ||
ExamLanguage.FI, | ||
); | ||
onPublicGoodAndSatisfactoryLevelPage.expectFilteredExaminersCount(2); | ||
|
||
onPublicGoodAndSatisfactoryLevelPage.filterExaminersByExamLanguage( | ||
ExamLanguage.SV, | ||
); | ||
onPublicGoodAndSatisfactoryLevelPage.expectFilteredExaminersCount(3); | ||
|
||
onPublicGoodAndSatisfactoryLevelPage.filterExaminersByExamLanguage( | ||
ExamLanguage.ALL, | ||
); | ||
onPublicGoodAndSatisfactoryLevelPage.expectFilteredExaminersCount(4); | ||
}); | ||
|
||
it('should redirect user to contact request form when clicking on examiner', () => { | ||
const lastName = 'Alanen'; | ||
const firstName = 'Anneli'; | ||
const examiner = publicExaminers.filter( | ||
(v) => v.lastName === lastName && v.firstName === firstName, | ||
)[0]; | ||
onPublicGoodAndSatisfactoryLevelPage.contactExaminer( | ||
`${firstName} ${lastName}`, | ||
); | ||
cy.url().should( | ||
'include', | ||
AppRoutes.PublicEnrollmentContactContactDetails.replace( | ||
/:examinerId/, | ||
`${examiner.id}`, | ||
), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ExamLanguage } from 'enums/app'; | ||
|
||
class PublicGoodAndSatisfactoryLevelPage { | ||
elements = { | ||
examinersTable: () => | ||
cy | ||
.findByRole('heading', { | ||
name: 'Ota yhteyttä tutkintosuorituksen vastaanottajiin', | ||
}) | ||
.siblings('table') | ||
.first(), | ||
examinerRow: (examinerName: string) => | ||
this.elements | ||
.examinersTable() | ||
.findAllByRole('cell', { name: examinerName }) | ||
.parent(), | ||
languageFilter: () => | ||
cy.findByRole('group', { name: 'Näytä seuraavien kielten tutkinnot:' }), | ||
}; | ||
|
||
filterExaminersByExamLanguage(language: ExamLanguage) { | ||
const label = | ||
language === ExamLanguage.FI | ||
? 'Suomi' | ||
: language === ExamLanguage.SV | ||
? 'Ruotsi' | ||
: 'Molemmat kielet'; | ||
this.elements.languageFilter().findByRole('radio', { name: label }).click(); | ||
} | ||
|
||
expectFilteredExaminersCount(count: number) { | ||
// Expect number of table rows to be count + 1, as the table header is also considered a row. | ||
this.elements | ||
.examinersTable() | ||
.findAllByRole('row') | ||
.should('have.length', count + 1); | ||
} | ||
|
||
contactExaminer(examinerName: string) { | ||
this.elements | ||
.examinerRow(examinerName) | ||
.findByRole('button', { name: /Ota yhteyttä/i }) | ||
.click(); | ||
} | ||
} | ||
|
||
export const onPublicGoodAndSatisfactoryLevelPage = | ||
new PublicGoodAndSatisfactoryLevelPage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
frontend/packages/vkt/src/tests/msw/fixtures/publicExaminer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { ExamLanguage } from 'enums/app'; | ||
import { PublicExaminerResponse } from 'interfaces/publicExaminer'; | ||
|
||
export const publicExaminers: Array<PublicExaminerResponse> = [ | ||
{ | ||
id: 3, | ||
lastName: 'Aaltonen', | ||
firstName: 'Antti', | ||
languages: [ExamLanguage.SV], | ||
municipalities: [ | ||
{ | ||
fi: 'Enonkoski', | ||
sv: 'Enonkoski', | ||
}, | ||
], | ||
examDates: [], | ||
}, | ||
{ | ||
id: 2, | ||
lastName: 'Alanen', | ||
firstName: 'Anneli', | ||
languages: [ExamLanguage.FI, ExamLanguage.SV], | ||
municipalities: [ | ||
{ | ||
fi: 'Alavieska', | ||
sv: 'Alavieska', | ||
}, | ||
{ | ||
fi: 'Alavus', | ||
sv: 'Alavo', | ||
}, | ||
{ | ||
fi: 'Hyvinkää', | ||
sv: 'Hyvinge', | ||
}, | ||
{ | ||
fi: 'Ii', | ||
sv: 'Ii', | ||
}, | ||
{ | ||
fi: 'Kihniö', | ||
sv: 'Kihniö', | ||
}, | ||
], | ||
examDates: [ | ||
{ | ||
examDate: '2026-01-10', | ||
isFull: false, | ||
}, | ||
{ | ||
examDate: '2026-01-22', | ||
isFull: false, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 1, | ||
lastName: 'Eskola', | ||
firstName: 'Eero', | ||
languages: [ExamLanguage.FI], | ||
municipalities: [ | ||
{ | ||
fi: 'Oulu', | ||
sv: 'Uleåborg', | ||
}, | ||
], | ||
examDates: [], | ||
}, | ||
{ | ||
id: 4, | ||
lastName: 'Hakala', | ||
firstName: 'Ella', | ||
languages: [ExamLanguage.SV], | ||
municipalities: [ | ||
{ | ||
fi: 'Aura', | ||
sv: 'Aura', | ||
}, | ||
], | ||
examDates: [ | ||
{ | ||
examDate: '2025-06-15', | ||
isFull: false, | ||
}, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters