From 6bcb34139b8c394830e86b4df793e5991b790291 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Tue, 7 Jan 2025 23:24:31 +0100 Subject: [PATCH] :white_check_mark: [open-formulieren/open-forms#4929] Test cosign submission summary page Added test to ensure that the check route with a submission ID in the query params results in the submission summary being disabled for verification. --- src/components/CoSign/Cosign.test.jsx | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/CoSign/Cosign.test.jsx b/src/components/CoSign/Cosign.test.jsx index 0b9ce83aa..b98d7c872 100644 --- a/src/components/CoSign/Cosign.test.jsx +++ b/src/components/CoSign/Cosign.test.jsx @@ -1,5 +1,4 @@ import {render, screen} from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; import messagesEN from 'i18n/compiled/en.json'; import {IntlProvider} from 'react-intl'; import {RouterProvider, createMemoryRouter} from 'react-router-dom'; @@ -7,7 +6,11 @@ import {RouterProvider, createMemoryRouter} from 'react-router-dom'; import {ConfigContext, FormContext} from 'Context'; import {BASE_URL, buildForm} from 'api-mocks'; import mswServer from 'api-mocks/msw-server'; -import {mockSubmissionPost, mockSubmissionStepGet} from 'api-mocks/submissions'; +import { + mockSubmissionGet, + mockSubmissionStepGet, + mockSubmissionSummaryGet, +} from 'api-mocks/submissions'; import Cosign from './Cosign'; import {default as nestedRoutes} from './routes'; @@ -60,10 +63,9 @@ const routes = [ }, ]; -const Wrapper = () => { +const Wrapper = ({relativeUrl}) => { const router = createMemoryRouter(routes, { - initialEntries: ['/cosign/start'], - initialIndex: 0, + initialEntries: [`/cosign/${relativeUrl}`], }); return ( { }; test('Cosign start route renders start/login page', async () => { - render(); + render(); expect(await screen.findByRole('link', {name: 'Login with DigiD Cosign'})).toBeVisible(); }); + +test('Load submission summary after backend authentication', async () => { + mswServer.use(mockSubmissionGet(), mockSubmissionSummaryGet()); + + // the submission ID is taken from the query params + render(); + + await screen.findByRole('heading', {name: 'Check and co-sign submission', level: 1}); + // wait for summary to load from the backend + await screen.findByText('Compnent 1 value'); +});