Skip to content

Commit 6f1a2f3

Browse files
committed
add setup form
1 parent 81622ec commit 6f1a2f3

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

testing/e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"lint": "tsc && eslint --fix .",
88
"test": "env-cmd -f ../../.env playwright test",
9-
"test:dev": "playwright test --ui"
9+
"test:dev": "env-cmd -f ../../.env playwright test --ui"
1010
},
1111
"dependencies": {
1212
"@douglasneuroinformatics/libjs": "catalog:",

testing/e2e/src/global/global.setup.spec.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import type { LoginCredentials } from '@opendatacapture/schemas/auth';
55
import type { InitAppOptions } from '@opendatacapture/schemas/setup';
66
import { expect, test } from '@playwright/test';
77

8-
const initOptions: InitAppOptions = {
8+
const initOptions = {
99
admin: {
1010
firstName: 'Jane',
1111
lastName: 'Doe',
1212
password: 'DataCapture2025',
1313
username: 'admin'
1414
},
15+
dummySubjectCount: 10,
1516
enableExperimentalFeatures: false,
16-
initDemo: true
17-
};
17+
initDemo: true,
18+
recordsPerSubject: 10
19+
} satisfies InitAppOptions;
1820

1921
declare global {
2022
namespace NodeJS {
@@ -36,12 +38,20 @@ test.describe.serial(() => {
3638
expect(response.status()).toBe(200);
3739
await expect(response.json()).resolves.toMatchObject({ isSetup: false });
3840
});
39-
test('successful setup', async ({ request }) => {
40-
const response = await request.post('/api/v1/setup', {
41-
data: initOptions
42-
});
43-
expect(response.status()).toBe(201);
44-
await expect(response.json()).resolves.toStrictEqual({ success: true });
41+
test('successful setup', async ({ page }) => {
42+
await page.goto('/setup');
43+
await expect(page).toHaveURL('/setup');
44+
const setupForm = page.locator('form[data-cy="setup-form"]');
45+
await setupForm.locator('input[name="firstName"]').fill(initOptions.admin.firstName);
46+
await setupForm.locator('input[name="lastName"]').fill(initOptions.admin.lastName);
47+
await setupForm.locator('input[name="username"]').fill(initOptions.admin.username);
48+
await setupForm.locator('input[name="password"]').fill(initOptions.admin.password);
49+
await setupForm.locator('input[name="confirmPassword"]').fill(initOptions.admin.password);
50+
await setupForm.locator('#initDemo-true').click();
51+
await setupForm.locator('input[name="dummySubjectCount"]').fill(initOptions.dummySubjectCount.toString());
52+
await setupForm.locator('input[name="recordsPerSubject"]').fill(initOptions.recordsPerSubject.toString());
53+
await setupForm.getByLabel('Submit').click();
54+
await expect(page).toHaveURL('/dashboard');
4555
});
4656
test('setup state after initialization', async ({ request }) => {
4757
const response = await request.get('/api/v1/setup');

0 commit comments

Comments
 (0)