From 567b29439168529dcd8698a93bbc1cedf80b9074 Mon Sep 17 00:00:00 2001 From: Steven Bal Date: Mon, 16 Dec 2024 15:35:53 +0100 Subject: [PATCH 1/2] :bug: [open-formulieren/open-forms#4918] Pass initial_data_reference when redirecting to formstart --- src/components/Form.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/Form.jsx b/src/components/Form.jsx index 0fbf47d97..85697e3c2 100644 --- a/src/components/Form.jsx +++ b/src/components/Form.jsx @@ -350,16 +350,18 @@ const Form = () => { ) : null; if (state.startingError) throw state.startingError; + + let startPageUrl = introductionPageContent ? 'introductie' : 'startpagina'; const extraStartUrlParams = {}; - if (initialDataReference) extraStartUrlParams.initial_data_reference = initialDataReference; + if (initialDataReference) { + extraStartUrlParams.initial_data_reference = initialDataReference; + startPageUrl = `${startPageUrl}?${new URLSearchParams(extraStartUrlParams).toString()}`; + } // Route the correct page based on URL const router = ( - } - /> + } /> Date: Mon, 16 Dec 2024 16:29:59 +0100 Subject: [PATCH 2/2] :white_check_mark: [open-formulieren/open-forms#4918] Add test for passing initial_data_reference when redirecting --- src/components/Form.spec.jsx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/components/Form.spec.jsx b/src/components/Form.spec.jsx index 14ffe3e1a..e2efd69b9 100644 --- a/src/components/Form.spec.jsx +++ b/src/components/Form.spec.jsx @@ -114,3 +114,36 @@ test('Start form with object reference query param', async () => { const requestBody = await startSubmissionRequest.json(); expect(requestBody.initialDataReference).toBe('foo'); }); + +// Regression test for https://github.com/open-formulieren/open-forms/issues/4918 +test.each([ + { + introductionPageContent: '', + buttonText: 'Login with DigiD', + expectedUrl: + 'http://mock-digid.nl/login?next=http%3A%2F%2Flocalhost%2F%3F_start%3D1%26initial_data_reference%3Dfoo', + }, + { + introductionPageContent: 'foo', + buttonText: 'Continue', + expectedUrl: '/startpagina?initial_data_reference=foo', + }, +])( + 'Redirect to start page or introduction page should preserve initial_data_reference param', + async ({introductionPageContent, buttonText, expectedUrl}) => { + mswServer.use(mockAnalyticsToolConfigGet(), mockSubmissionPost(), mockSubmissionStepGet()); + + render( + + ); + + const loginLink = await screen.findByRole('link', {name: buttonText}); + expect(loginLink).toHaveAttribute('href', expectedUrl); + } +);