Skip to content

Commit d9cf0c8

Browse files
committed
test: add test for custom identifier
1 parent 34481b1 commit d9cf0c8

2 files changed

Lines changed: 58 additions & 1 deletion

File tree

testing/e2e/src/2.3-start-session.spec.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test.describe('start session', () => {
88
expect(startSessionPage.sessionForm).toBeDefined();
99
});
1010

11-
test('should fill subject identification input', async ({ getPageModel, page }) => {
11+
test('should fill subject personal information input', async ({ getPageModel, page }) => {
1212
await page.addInitScript(() => {
1313
localStorage.setItem(
1414
'app',
@@ -51,3 +51,39 @@ test.describe('start session', () => {
5151
await expect(startSessionPage.successMessage).toBeVisible();
5252
});
5353
});
54+
55+
test.describe('start session', () => {
56+
test('should fill custom identifier input', async ({ getPageModel, page }) => {
57+
await page.addInitScript(() => {
58+
localStorage.setItem(
59+
'app',
60+
JSON.stringify({ state: { isDisclaimerAccepted: true, isWalkthroughComplete: true }, version: 1 })
61+
);
62+
});
63+
64+
const startSessionPage = await getPageModel('/session/start-session');
65+
66+
await startSessionPage.sessionForm.waitFor({ state: 'visible' });
67+
await startSessionPage.selectIdentificationMethod('CUSTOM_ID');
68+
69+
// Verify the selection was made
70+
await expect(startSessionPage.selectField).toHaveValue('CUSTOM_ID');
71+
72+
// Fill the subject first name field
73+
await startSessionPage.fillCustomIdentifier('customIdentifierTest', 'Male');
74+
75+
// Verify the field was filled
76+
const subjectIdField = startSessionPage.sessionForm.locator('[name="subjectId"]');
77+
await expect(subjectIdField).toHaveValue('customIdentifierTest');
78+
79+
const sessionTypeSelector = startSessionPage.sessionForm.locator('[name="sessionType"]');
80+
await expect(sessionTypeSelector).toHaveValue('RETROSPECTIVE');
81+
82+
const sessionDate = startSessionPage.sessionForm.locator('[name="sessionDate"]');
83+
await expect(sessionDate).toHaveValue('2026-01-01');
84+
85+
await startSessionPage.submitForm();
86+
87+
await expect(startSessionPage.successMessage).toBeVisible();
88+
});
89+
});

testing/e2e/src/pages/start-session.page.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,27 @@ export class StartSessionPage extends AppPage {
4242
await sessionDate.fill('2026-01-01');
4343
}
4444

45+
async fillCustomIdentifier(customIdentifier: string, sex: string) {
46+
const subjectIdField = this.sessionForm.locator('[name="subjectId"]');
47+
const dateOfBirthField = this.sessionForm.locator('[name="subjectDateOfBirth"]');
48+
const sexSelector = this.sessionForm.locator('[name="subjectSex"]');
49+
const sessionTypeSelector = this.sessionForm.locator('[name="sessionType"]');
50+
const sessionDate = this.sessionForm.locator('[name="sessionDate"]');
51+
52+
await subjectIdField.waitFor({ state: 'visible' });
53+
await subjectIdField.fill(customIdentifier);
54+
55+
await dateOfBirthField.waitFor({ state: 'visible' });
56+
await dateOfBirthField.fill('1990-01-01');
57+
58+
await sexSelector.selectOption(sex);
59+
60+
await sessionTypeSelector.selectOption('Retrospective');
61+
62+
await sessionDate.waitFor({ state: 'visible' });
63+
await sessionDate.fill('2026-01-01');
64+
}
65+
4566
async selectIdentificationMethod(methodName: string) {
4667
await this.selectField.selectOption(methodName);
4768
}

0 commit comments

Comments
 (0)