Skip to content

Commit bf08ed6

Browse files
committed
chore: e2e test for multi step form (toggled by cookie)
1 parent cf3db56 commit bf08ed6

File tree

3 files changed

+64
-6
lines changed

3 files changed

+64
-6
lines changed

e2e/actions/fhir-actions.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { expect, Page } from '@playwright/test'
1+
import { Page } from '@playwright/test'
22

33
export async function launchWithMock(page: Page): Promise<void> {
44
await page.goto(`/fhir/launch?iss=http://localhost:3000/api/mocks/fhir&launch=foo-bar-launch`)
5-
6-
await expect(page.getByRole('heading', { name: 'Opprett ny sykmelding' })).toBeVisible()
75
}

e2e/fhir-multi-step.spec.ts

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
import { ExpectedToggles } from '@toggles/toggles'
4+
5+
import { launchWithMock } from './actions/fhir-actions'
6+
import { pickHoveddiagnose } from './actions/user-actions'
7+
import { clickAndWait, waitForHttp } from './utils/request-utils'
8+
9+
test('can submit 100% sykmelding (multi step)', async ({ page, context }) => {
10+
await context.addCookies([
11+
// Enable multi-step form feature toggle
12+
{
13+
name: 'SYK_INN_MULTISTEP_FORM_V1' satisfies ExpectedToggles,
14+
value: 'true',
15+
domain: 'localhost',
16+
path: '/',
17+
},
18+
])
19+
await launchWithMock(page)
20+
21+
await expect(page.getByRole('heading', { name: 'Sykmelding for Espen Eksempel' })).toBeVisible()
22+
await expect(page.getByText(/ID-nummer(.*)21037712323/)).toBeVisible()
23+
24+
await page.getByRole('button', { name: 'Start sykmelding' }).click()
25+
26+
await page.getByRole('textbox', { name: 'Fra og med' }).fill('15.02.2024')
27+
await page.getByRole('textbox', { name: 'Til og med' }).fill('18.02.2024')
28+
29+
await page.getByRole('button', { name: 'Neste steg' }).click()
30+
31+
await pickHoveddiagnose({ search: 'Angst', select: /Angstlidelse/ })(page)
32+
33+
await page.getByRole('button', { name: 'Neste steg' }).click()
34+
35+
const request = await clickAndWait(
36+
page.getByRole('button', { name: 'Send inn' }).click(),
37+
waitForHttp('/fhir/resources/sykmelding/submit', 'POST')(page),
38+
)
39+
const payload = request.postDataJSON()
40+
41+
expect(payload).toEqual({
42+
behandlerHpr: '9144889',
43+
values: {
44+
pasient: '21037712323',
45+
diagnoser: {
46+
hoved: { code: 'P74', system: 'ICPC2' },
47+
},
48+
aktivitet: {
49+
type: 'AKTIVITET_IKKE_MULIG',
50+
fom: '2024-02-15',
51+
tom: '2024-02-18',
52+
},
53+
},
54+
})
55+
56+
await expect(page.getByRole('heading', { name: 'Kvittering på innsendt sykmelding' })).toBeVisible()
57+
})

src/components/ny-sykmelding-form-multi-step/diagnose/DiagnoseSection.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { PropsWithChildren, ReactElement, useEffect, useMemo } from 'react'
22
import { DefaultValues, useForm } from 'react-hook-form'
3-
import { BodyShort, Skeleton } from '@navikt/ds-react'
3+
import { BodyShort, Heading, Skeleton } from '@navikt/ds-react'
44
import { ExclamationmarkTriangleIcon } from '@navikt/aksel-icons'
55

66
import { DiagnoseSuggestion } from '@components/ny-sykmelding-form/diagnose/combobox/DiagnoseCombobox'
@@ -68,7 +68,10 @@ function DiagnoseSectionWithData({
6868
}, [defaultValues.hoved])
6969

7070
return (
71-
<div>
71+
<section aria-labelledby="diagnose-section-heading">
72+
<Heading level="3" size="small" id="diagnose-section-heading">
73+
Diagnose
74+
</Heading>
7275
<form
7376
onSubmit={form.handleSubmit((values) => {
7477
dispatch(
@@ -84,7 +87,7 @@ function DiagnoseSectionWithData({
8487
{children}
8588
<StepNavigation previous={2} />
8689
</form>
87-
</div>
90+
</section>
8891
)
8992
}
9093

0 commit comments

Comments
 (0)