Skip to content

CCM-14758: Preview approved letter template#885

Open
chris-elliott-nhsd wants to merge 3 commits intomainfrom
feature/CCM-14758_approved-letter-template
Open

CCM-14758: Preview approved letter template#885
chris-elliott-nhsd wants to merge 3 commits intomainfrom
feature/CCM-14758_approved-letter-template

Conversation

@chris-elliott-nhsd
Copy link
Contributor

Description

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming
  • If I have used the 'skip-trivy-package' label I have done so responsibly and in the knowledge that this is being fixed as part of a separate ticket/PR.

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@chris-elliott-nhsd chris-elliott-nhsd requested a review from a team as a code owner March 19, 2026 09:25
@chris-elliott-nhsd chris-elliott-nhsd force-pushed the feature/CCM-14758_approved-letter-template branch from 448013d to e05c63d Compare March 19, 2026 09:30
@chris-elliott-nhsd chris-elliott-nhsd force-pushed the feature/CCM-14758_approved-letter-template branch from 2a38e87 to 45da131 Compare March 19, 2026 15:00
title: content.pageTitle,
};

const getPreviewURL = (template: TemplateDto) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this function be moved into utils?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might also be looking at alongside / utilising the ones in enum

export const previewTemplatePages = (type: TemplateType) =>
  `preview-${legacyTemplateTypeToUrlTextMappings(type)}-template`;
export const previewSubmittedTemplatePages = (type: TemplateType) =>
  `preview-submitted-${legacyTemplateTypeToUrlTextMappings(type)}-template`;

so we dont have this sort of thing spread about the place :)

await expect(page).toHaveURL(`${baseURL}/templates/invalid-template`);
});

test('when user visits page with a fake template, then an invalid template error is displayed', async ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-existant?

'VALIDATION_FAILED'
);

const letterProofApproved = TemplateFactory.createAuthoringLetterTemplate(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should have long and short renders, and a letter variant

@@ -0,0 +1,60 @@
'use client';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary?

language: 'en',
updatedAt: '2021-02-01T00:00:00.000Z',
lockNumber: 1,
files: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be worth adding campaignId, letterVariantId, files.shortFormRender and files.longFormRender, just to make the example more coherent

import { AuthoringLetterTemplate } from 'nhs-notify-web-template-management-utils';

const mockTemplate: AuthoringLetterTemplate = {
...AUTHORING_LETTER_TEMPLATE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't realistic for an approved template, because it's lacking personalised renders and campaign.

>
<iframe
aria-label="PDF preview of letter template with long example personalisation data"
src="/templates/files/undefined/renders/authoring-letter-template-id/render.pdf"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client ID is missing - it's being made required in Michael's PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be the long form render filename, not the initial render

});

describe('previewApprovedTemplatePages', () => {
test('EMAIL', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this test called 'EMAIL' ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a test.each here?

{ template: templates.EMAIL, expectedStatus: 'Draft' },
{ template: templates.SMS, expectedStatus: 'Draft' },
{ template: templates.LETTER, expectedStatus: 'Proof approved' },
{ template: templates.LETTER, expectedStatus: 'Approved' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have we got e2e tests that are running with authoring off or not?


export function LetterRender({
template,
hideEditActions,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opinionated, feel free to ignore
editable?

const messageTemplatesContent = content.pages.messageTemplates;

const generateViewTemplateLink = (template: TemplateDto): string => {
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of interest, if these links went to the normal preview page, would it then redirect to the correct approved/submitted page anyway?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think preview-letter page should redirect to preview-approved

const template = await getTemplate(templateId);

const validatedTemplate = validateSubmittedLetterTemplate(template);
const validatedTemplate = zodValidate(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to update the zod validators so that they differentiate between versions of letters? or is the pdf stuff temporary enough its not worth it?

@@ -23,6 +24,14 @@ import { useFeatureFlags } from '@providers/client-config-provider';
const messageTemplatesContent = content.pages.messageTemplates;

const generateViewTemplateLink = (template: TemplateDto): string => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not the same as your getPreviewURL elsewhere?

title: content.pageTitle,
};

const getPreviewURL = (template: TemplateDto) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as the other page

);
});

test('redirects to preview submitted template page if template is submitted', async ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test('redirects to preview approved template page if template is submitted', async ({

);
});

test('redirects to preview submitted template page if template is submitted', async ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test('redirects to preview approved template page if template is submitted', async ({

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants