Skip to content

Commit

Permalink
✅ [open-formulieren/open-forms#4929] Test cosign submission summary page
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sergei-maertens committed Jan 13, 2025
1 parent bc7acd4 commit 8bda0e3
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/components/CoSign/Cosign.test.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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';

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';
Expand Down Expand Up @@ -60,10 +63,9 @@ const routes = [
},
];

const Wrapper = () => {
const Wrapper = ({relativeUrl}) => {
const router = createMemoryRouter(routes, {
initialEntries: ['/cosign/start'],
initialIndex: 0,
initialEntries: [`/cosign/${relativeUrl}`],
});
return (
<ConfigContext.Provider
Expand All @@ -85,7 +87,18 @@ const Wrapper = () => {
};

test('Cosign start route renders start/login page', async () => {
render(<Wrapper />);
render(<Wrapper relativeUrl="start" />);

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(<Wrapper relativeUrl="check?submission_uuid=458b29ae-5baa-4132-a0d7-8c7071b8152a" />);

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');
});

0 comments on commit 8bda0e3

Please sign in to comment.