Skip to content

Commit

Permalink
✅ [open-formulieren/open-forms#4398] Tests for initialDataReference
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Oct 14, 2024
1 parent 3e283af commit 3a202c0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/components/FormStart/tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {buildSubmission} from 'api-mocks';
import useQuery from 'hooks/useQuery';

import FormStart from '.';
import {testForm} from './fixtures';
import {testForm, testLoginForm} from './fixtures';

jest.mock('hooks/useQuery');
let scrollIntoViewMock = jest.fn();
Expand Down Expand Up @@ -116,3 +116,26 @@ it('Form start page does not show login buttons if an active submission is prese
expect(screen.queryByRole('button', {name: 'Continue existing submission'})).toBeInTheDocument();
expect(screen.queryByRole('button', {name: 'Abort submission'})).toBeInTheDocument();
});

it('Form start page with initial_data_reference', () => {
useQuery.mockReturnValue(new URLSearchParams());
const onFormStart = jest.fn();
const onDestroySession = jest.fn();

renderTest(
<Wrap>
<FormStart
form={testLoginForm}
onFormStart={onFormStart}
onDestroySession={onDestroySession}
initialDataReference="1234"
/>
</Wrap>,
container
);
const loginLink = screen.getByRole('link', {name: 'Login with DigiD'});
expect(loginLink).toHaveAttribute(
'href',
'https://openforms.nl/auth/form-name/digid/start?initial_data_reference=1234&next=http%3A%2F%2Flocalhost%2F%3F_start%3D1'
);
});
13 changes: 13 additions & 0 deletions src/components/IntroductionPage/IntroductionPage.stories.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {expect, userEvent, within} from '@storybook/test';
import {withRouter} from 'storybook-addon-remix-react-router';

import {buildForm} from 'api-mocks';
Expand Down Expand Up @@ -48,3 +49,15 @@ export default {
export const Default = {
name: 'IntroductionPage',
};

export const IntroductionPageWithInitialDataReference = {
name: 'IntroductionPage with initial data reference',
args: {
extraParams: {initial_data_reference: '1234'},
},
play: async ({canvasElement}) => {
const canvas = within(canvasElement);
const continueLink = canvas.getByRole('link', {name: 'Continue'});
await expect(continueLink).toHaveAttribute('href', '/startpagina?initial_data_reference=1234');
},
};

0 comments on commit 3a202c0

Please sign in to comment.