-
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.
Merge pull request #633 from Opetushallitus/feature/OPHYKIKEH-246
YKI(Frontend): OPHYKIKEH-246 Tutkintoon ilmoittautumisen testejä
- Loading branch information
Showing
27 changed files
with
3,434 additions
and
60 deletions.
There are no files selected for viewing
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
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
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
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
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
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
131 changes: 131 additions & 0 deletions
131
frontend/packages/yki/src/tests/cypress/integration/exam_details_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,131 @@ | ||
import { APIEndpoints } from 'enums/api'; | ||
import { onExamDetailsPage } from 'tests/cypress/support/page-objects/examDetailsPage'; | ||
import { examSessions } from 'tests/msw/fixtures/examSession'; | ||
|
||
const examSessionResponse = examSessions.exam_sessions.find( | ||
(es) => es.id === 999, | ||
); | ||
|
||
const expectedSuomiFiRegistrationDetails = { | ||
first_name: 'Teuvo', | ||
last_name: 'Testitapaus', | ||
ssn: '030594W903B', | ||
post_office: 'Helsinki', | ||
zip: '00100', | ||
street_address: 'Unioninkatu 1', | ||
}; | ||
|
||
const getInitRegistrationResponse = (is_strongly_identified: boolean) => { | ||
if (is_strongly_identified) { | ||
const { first_name, last_name, ssn, post_office, zip, street_address } = | ||
expectedSuomiFiRegistrationDetails; | ||
|
||
return { | ||
is_strongly_identified, | ||
exam_session: examSessionResponse, | ||
registration_id: 1337, | ||
user: { | ||
first_name, | ||
last_name, | ||
ssn, | ||
post_office, | ||
zip, | ||
street_address, | ||
}, | ||
}; | ||
} else { | ||
return { | ||
is_strongly_identified, | ||
exam_session: examSessionResponse, | ||
registration_id: 1337, | ||
user: { | ||
email: '[email protected]', | ||
}, | ||
}; | ||
} | ||
}; | ||
|
||
const handleRedirect = () => { | ||
// When browser attempts to logout, send browser instead directly to | ||
// successful submission page. | ||
// Note that mocking the response with msw doesn't currently work, | ||
// as the request to logout is sent to an absolute URL (including hostname). | ||
cy.intercept( | ||
{ url: /^.*\/yki\/auth\/logout\?redirect=/, method: 'GET' }, | ||
(req) => { | ||
const { redirect } = req.query; | ||
req.continue((res) => { | ||
res.send(301, {}, { location: redirect as string }); | ||
}); | ||
}, | ||
); | ||
}; | ||
|
||
describe('ExamDetailsPage', () => { | ||
describe('allows filling registration form', () => { | ||
it('with credentials from Suomi.fi authentication', () => { | ||
cy.openExamSessionRegistrationForm(examSessionResponse.id); | ||
cy.intercept('POST', APIEndpoints.InitRegistration, { | ||
statusCode: 200, | ||
body: getInitRegistrationResponse(true), | ||
}).as('initRegistration'); | ||
cy.wait('@initRegistration'); | ||
onExamDetailsPage.isVisible(); | ||
onExamDetailsPage.fillFieldByLabel( | ||
'Sähköpostiosoite *', | ||
'[email protected]', | ||
); | ||
onExamDetailsPage.fillFieldByLabel( | ||
'Vahvista sähköpostiosoite *', | ||
'[email protected]', | ||
); | ||
onExamDetailsPage.fillFieldByLabel('Puhelinnumero *', '+358501234567'); | ||
onExamDetailsPage.selectNationality('Serbia'); | ||
onExamDetailsPage.selectCertificateLanguage('englanti'); | ||
|
||
onExamDetailsPage.acceptTermsOfRegistration(); | ||
onExamDetailsPage.acceptPrivacyPolicy(); | ||
|
||
handleRedirect(); | ||
|
||
onExamDetailsPage.submitForm(); | ||
onExamDetailsPage.isFormSubmitted(); | ||
}); | ||
|
||
it('by authenticating via a login link', () => { | ||
cy.openExamSessionRegistrationForm(examSessionResponse.id); | ||
cy.intercept('POST', APIEndpoints.InitRegistration, { | ||
statusCode: 200, | ||
body: getInitRegistrationResponse(false), | ||
}).as('initRegistration'); | ||
cy.wait('@initRegistration'); | ||
onExamDetailsPage.isVisible(); | ||
|
||
const { first_name, last_name, street_address, zip, post_office, ssn } = expectedSuomiFiRegistrationDetails; | ||
|
||
onExamDetailsPage.fillFieldByLabel('Etunimet *', first_name); | ||
onExamDetailsPage.fillFieldByLabel('Sukunimi *', last_name); | ||
|
||
onExamDetailsPage.fillFieldByLabel('Katuosoite *', street_address); | ||
onExamDetailsPage.fillFieldByLabel('Postinumero *', zip); | ||
onExamDetailsPage.fillFieldByLabel('Postitoimipaikka *', post_office); | ||
|
||
onExamDetailsPage.selectGender('Mies'); | ||
onExamDetailsPage.selectNationality('Serbia'); | ||
|
||
onExamDetailsPage.fillFieldByLabel('Puhelinnumero *', '+358501234567'); | ||
|
||
onExamDetailsPage.selectHasSSN(true); | ||
onExamDetailsPage.fillFieldByLabel('Henkilötunnus *', ssn); | ||
onExamDetailsPage.selectCertificateLanguage('englanti'); | ||
|
||
onExamDetailsPage.acceptTermsOfRegistration(); | ||
onExamDetailsPage.acceptPrivacyPolicy(); | ||
|
||
handleRedirect(); | ||
|
||
onExamDetailsPage.submitForm(); | ||
onExamDetailsPage.isFormSubmitted(); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.