Skip to content

Commit 113a5cc

Browse files
committed
Merge remote-tracking branch 'origin' into feature/CCM-7079_nhsapp_review_template_page_automation
2 parents d7e54c9 + 27a4d00 commit 113a5cc

File tree

52 files changed

+1480
-1817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1480
-1817
lines changed

jest.setup.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// https://nextjs.org/docs/app/building-your-application/testing/jest#optional-extend-jest-with-custom-matchers
22
import '@testing-library/jest-dom';
33
import { TextEncoder, TextDecoder } from 'node:util';
4+
/*
5+
* A polyfill for fetch API which includes the Request object
6+
* this helps solve the issue of the test throwing an error if the `getAmplifyBackendClient` is not mocked out.
7+
* https://github.com/vercel/next.js/discussions/59041#discussioncomment-10043081
8+
*/
9+
import 'whatwg-fetch';
410

511
Object.assign(global, { TextDecoder, TextEncoder });

package-lock.json

Lines changed: 787 additions & 472 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"tsx": "^4.19.1",
7676
"typescript": "^5.5.4",
7777
"wait-on": "^8.0.0",
78+
"whatwg-fetch": "^3.6.20",
7879
"nhs-notify-web-template-management-ui-tests": "file:tests/test-team"
7980
},
8081
"overrides": {

src/__tests__/app/create-email-template/__snapshots__/page.test.tsx.snap

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/__tests__/app/create-email-template/page.test.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,12 @@ import { Session, TemplateType } from '@utils/types';
44
import { redirect } from 'next/navigation';
55
import { CreateEmailTemplate } from '@forms/CreateEmailTemplate/CreateEmailTemplate';
66

7-
jest.mock('@utils/amplify-utils', () => ({
8-
getAmplifyBackendClient: () => ({
9-
models: {
10-
SessionStorage: {
11-
update: () => ({ data: {} }),
12-
},
13-
},
14-
}),
15-
}));
167
jest.mock('@utils/form-actions');
178
jest.mock('next/navigation');
189
jest.mock('@forms/CreateEmailTemplate/CreateEmailTemplate');
1910

2011
const getSessionMock = jest.mocked(getSession);
2112
const redirectMock = jest.mocked(redirect);
22-
const CreateEmailTemplateMock = jest.mocked(CreateEmailTemplate);
2313

2414
const initialState: Session = {
2515
id: 'session-id',
@@ -56,14 +46,13 @@ describe('CreateEmailTemplatePage', () => {
5646

5747
it('should render CreateEmailTemplatePage component when session is found', async () => {
5848
getSessionMock.mockResolvedValueOnce(initialState);
59-
CreateEmailTemplateMock.mockImplementationOnce(() => <p>rendered</p>);
6049

6150
const page = await CreateEmailTemplatePage({
6251
params: { sessionId: 'session-id' },
6352
});
6453

6554
expect(getSessionMock).toHaveBeenCalledWith('session-id');
6655

67-
expect(page).toMatchSnapshot();
56+
expect(page).toEqual(<CreateEmailTemplate initialState={initialState} />);
6857
});
6958
});

0 commit comments

Comments
 (0)