Skip to content

Commit

Permalink
🐛 [open-formulieren/open-forms#4827] Do not add initial_data_ref if e…
Browse files Browse the repository at this point in the history
…mpty

previously, initial_data_reference=null was added to the login URL next parameters, even in cases when no initial_data_reference was specified
  • Loading branch information
stevenbal committed Nov 18, 2024
1 parent 5a418c4 commit 4db5ead
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/FormStart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ const FormStart = ({form, submission, onFormStart, onDestroySession, initialData
);
}

const extraNextParams = initialDataReference
? {initial_data_reference: initialDataReference}

Check warning on line 109 in src/components/FormStart/index.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/FormStart/index.jsx#L109

Added line #L109 was not covered by tests
: {};

return (
<LiteralsProvider literals={form.literals}>
<Card title={form.name}>
Expand All @@ -121,11 +125,7 @@ const FormStart = ({form, submission, onFormStart, onDestroySession, initialData
isAuthenticated={isAuthenticated}
/>
) : (
<LoginOptions
form={form}
onFormStart={onFormStart}
extraNextParams={{initial_data_reference: initialDataReference}}
/>
<LoginOptions form={form} onFormStart={onFormStart} extraNextParams={extraNextParams} />
)}
</Card>
</LiteralsProvider>
Expand Down
23 changes: 23 additions & 0 deletions src/components/FormStart/tests.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,26 @@ it('Form start page with initial_data_reference', async () => {
'https://openforms.nl/auth/form-name/digid/start?next=http%3A%2F%2Flocalhost%2F%3F_start%3D1%26initial_data_reference%3D1234'
);
});

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

render(
<Wrap>
<FormStart
form={testLoginForm}
onFormStart={onFormStart}
onDestroySession={onDestroySession}
initialDataReference={null}
/>
</Wrap>
);

const loginLink = await screen.findByRole('link', {name: 'Login with DigiD'});
expect(loginLink).toHaveAttribute(
'href',
'https://openforms.nl/auth/form-name/digid/start?next=http%3A%2F%2Flocalhost%2F%3F_start%3D1'
);
});

0 comments on commit 4db5ead

Please sign in to comment.