Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4c9f1c9
CCM-11343: add proofingEnabled field to templates
bhansell1 Jul 28, 2025
5ee1304
Merge branch 'main' of https://github.com/NHSDigital/nhs-notify-web-t…
bhansell1 Jul 28, 2025
dc05c39
CCM-11343: add automated test
bhansell1 Jul 29, 2025
29aa2ea
CCM-11343: add supplier to letter templates
bhansell1 Jul 29, 2025
39531ae
CCM-11343: add event pipe filter
bhansell1 Jul 29, 2025
67a9fd1
CCM-11343: turn off lint rules
bhansell1 Jul 29, 2025
5bf6d7c
CCM-11343: fix typecheck
bhansell1 Jul 29, 2025
1dfd3d9
CCM-11343: update unit tests
bhansell1 Jul 30, 2025
1e65907
CCM-11343: update filter rules
bhansell1 Jul 30, 2025
dbf319e
Merge branch 'main' of https://github.com/NHSDigital/nhs-notify-web-t…
bhansell1 Jul 30, 2025
2d5de86
CCM-11343: remove filters from pipes and implement in code
bhansell1 Jul 31, 2025
028305e
CCM-11343: create a schema which is a subset of db template
bhansell1 Jul 31, 2025
c32ad32
Merge branch 'main' of https://github.com/NHSDigital/nhs-notify-web-t…
bhansell1 Jul 31, 2025
0ba6e90
CCM-11343: add unit tests to cover the Zod validator for inputSchema
bhansell1 Jul 31, 2025
8d02189
Merge branch 'main' of https://github.com/NHSDigital/nhs-notify-web-t…
bhansell1 Aug 4, 2025
0fdd914
CCM-11343: updatre create-env script
bhansell1 Aug 5, 2025
fca1042
add debug logs
bhansell1 Aug 5, 2025
a41d62c
Revert "add debug logs"
bhansell1 Aug 5, 2025
94c39fe
CCM-11343: add proofingEnabled to accessibility letters
bhansell1 Aug 5, 2025
2dfa854
CCM-11343: remove supplier
bhansell1 Aug 6, 2025
278b6ab
Merge branch 'main' of https://github.com/NHSDigital/nhs-notify-web-t…
bhansell1 Aug 7, 2025
38a0349
CCM-11343: fix function name conflict from merging in main
bhansell1 Aug 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
],
"security/detect-object-injection": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/todo-tag": "off",
"no-param-reassign": "off",
"no-useless-constructor": "off",
"sonarjs/no-small-switch": "off",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('RequestProofPage', () => {
name: 'template-name',
letterType: 'x0',
language: 'en',
proofingEnabled: true,
files: {
pdfTemplate: {
virusScanStatus: 'PASSED',
Expand Down Expand Up @@ -123,4 +124,41 @@ describe('RequestProofPage', () => {

expect(redirectMock).toHaveBeenCalledWith('/invalid-template', 'replace');
});

test('should forbid user from requesting a proof when proofingEnabled is false', async () => {
const state = {
id: 'template-id',
templateType: 'LETTER',
templateStatus: 'NOT_YET_SUBMITTED',
name: 'template-name',
letterType: 'x0',
language: 'ar',
proofingEnabled: false,
files: {
pdfTemplate: {
virusScanStatus: 'PASSED',
currentVersion: 'a',
fileName: 'a.pdf',
},
},
} satisfies Partial<TemplateDto>;

getTemplateMock.mockResolvedValue({
...state,
createdAt: 'today',
updatedAt: 'today',
});

await RequestProofPage({
params: Promise.resolve({
templateId: 'template-id',
}),
});

expect(await generateMetadata()).toEqual({
title: pageTitle,
});

expect(redirectMock).toHaveBeenCalledWith('/invalid-template', 'replace');
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { PreviewLetterTemplate } from '@organisms/PreviewLetterTemplate/PreviewLetterTemplate';
import { render } from '@testing-library/react';
import { isRightToLeft } from 'nhs-notify-web-template-management-utils/enum';

jest.mock('nhs-notify-web-template-management-utils/enum');

const isRightToLeftMock = jest.mocked(isRightToLeft);

describe('PreviewLetterTemplate component', () => {
beforeEach(() => {
jest.resetAllMocks();
isRightToLeftMock.mockReturnValueOnce(false);
});

it('matches snapshot when template status is VIRUS_SCAN_FAILED', () => {
const container = render(
<PreviewLetterTemplate
Expand All @@ -20,6 +30,7 @@ describe('PreviewLetterTemplate component', () => {
},
testDataCsv: undefined,
},
proofingEnabled: true,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
Expand All @@ -46,6 +57,7 @@ describe('PreviewLetterTemplate component', () => {
virusScanStatus: 'PASSED',
},
},
proofingEnabled: true,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
Expand All @@ -72,6 +84,7 @@ describe('PreviewLetterTemplate component', () => {
virusScanStatus: 'PASSED',
},
},
proofingEnabled: true,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
Expand Down Expand Up @@ -106,6 +119,7 @@ describe('PreviewLetterTemplate component', () => {
},
},
},
proofingEnabled: true,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
Expand Down Expand Up @@ -140,6 +154,7 @@ describe('PreviewLetterTemplate component', () => {
},
},
},
proofingEnabled: true,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
Expand Down Expand Up @@ -171,6 +186,7 @@ describe('PreviewLetterTemplate component', () => {
virusScanStatus: 'PASSED',
},
},
proofingEnabled: true,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
Expand All @@ -197,6 +213,7 @@ describe('PreviewLetterTemplate component', () => {
virusScanStatus: 'PENDING',
},
},
proofingEnabled: true,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
Expand All @@ -223,6 +240,46 @@ describe('PreviewLetterTemplate component', () => {
virusScanStatus: 'PASSED',
},
},
proofingEnabled: true,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
/>
);

expect(container.asFragment()).toMatchSnapshot();
});

it('matches snapshot when template language is Right to Left', () => {
isRightToLeftMock.mockReset();

isRightToLeftMock.mockReturnValueOnce(true);

const container = render(
<PreviewLetterTemplate
template={{
id: '0A097DCD-35F9-4DAD-A37E-AC358B71B74D',
owner: 'owner',
name: 'letter',
templateType: 'LETTER',
templateStatus: 'NOT_YET_SUBMITTED',
letterType: 'x0',
language: 'ar',
files: {
pdfTemplate: {
fileName: 'file.pdf',
currentVersion: 'b',
virusScanStatus: 'PASSED',
},
proofs: {
'your-proof.pdf': {
fileName: 'your-proof.pdf',
virusScanStatus: 'PASSED',
supplier: 'MBA',
},
},
},
proofingEnabled: false,
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
Expand Down
Loading