Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
53e6105
CCM-11494 Routing utils
nicki-nhs Nov 25, 2025
6b1f877
CCM-11494 Update interpolate function
nicki-nhs Nov 25, 2025
a57c962
CCM-11494 Update arrow icons
nicki-nhs Nov 25, 2025
571a970
CCM-11494 URLs for choosing templates
nicki-nhs Nov 25, 2025
4df03bb
CCM-11494 ChannelTemplate supports accessible formats and translated …
nicki-nhs Nov 25, 2025
f07f45f
CCM-11494 Add additional class to fallback conditions
nicki-nhs Nov 25, 2025
000c260
CCm-11494 MessagePlanBlock supports alternative letter formats
nicki-nhs Nov 25, 2025
fc031b7
CCM-11494 get conditional templates for a cascade item
nicki-nhs Nov 25, 2025
39ac026
CCM-11494 Update MessagePlanChannelList to support conditional templates
nicki-nhs Nov 25, 2025
eb204ce
CCM-11494 MessagePlanConditionalTemplates
nicki-nhs Nov 25, 2025
3c696ce
CCM-11494 Conditional templates content
nicki-nhs Nov 25, 2025
f1f6c4f
CCM-11494 Update imports
nicki-nhs Nov 25, 2025
74fcb1c
CCM-11494 Update choose-templates snapshot
nicki-nhs Nov 25, 2025
b42cc08
CCM-11494 Update snapshot for CreateEditMessagePlan
nicki-nhs Nov 25, 2025
6caf062
CCM-11494 Update cascade group
nicki-nhs Nov 25, 2025
8edecff
CCM-11494 Update enum
nicki-nhs Nov 26, 2025
012007e
CCM-11494 Remove conditional templates action
nicki-nhs Nov 26, 2025
3b4d25d
CCM-11494 Update tests and snapshots
nicki-nhs Nov 26, 2025
b21525b
CCM-11494 Update unit tests and snapshots
nicki-nhs Nov 26, 2025
c2bda1f
CCM-11494 Update routing config factory to support conditional templates
nicki-nhs Nov 26, 2025
94bd4c1
CCM-11494 Update factory
nicki-nhs Nov 26, 2025
1423493
Merge branch 'main' of https://github.com/NHSDigital/nhs-notify-web-t…
nicki-nhs Nov 26, 2025
71320e1
CCCM-11494 component test
nicki-nhs Nov 26, 2025
3b38b7d
CCM-11494 Fix type issue
nicki-nhs Nov 27, 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
2 changes: 1 addition & 1 deletion frontend/public/lib/assets/icons/icon-arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/public/lib/assets/icons/icon-arrow-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/public/lib/assets/icons/icon-arrow-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions frontend/src/__tests__/app/choose-templates/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ describe('ChooseTemplatesPage', () => {
const appTemplateId = 'd3a2c6ba-438a-4bf4-b94a-7c64c6528e7f';
const smsTemplateId = '5f7c3e1d-9b1a-4d3a-8f3e-2c6b8e9f1a2b';
const letterTemplateId = '9a8b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d';
const frenchLetterTemplateId = '1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d';
const spanishLetterTemplateId = '6d5c4b3a-2f1e-0d9c-8b7a-6f5e4d3c2b1a';

const planWithMultiple: RoutingConfig = {
...routingConfig,
Expand Down Expand Up @@ -209,6 +211,16 @@ describe('ChooseTemplatesPage', () => {
channel: 'LETTER',
channelType: 'primary',
defaultTemplateId: letterTemplateId,
conditionalTemplates: [
{
language: 'fr',
templateId: frenchLetterTemplateId,
},
{
language: 'es',
templateId: spanishLetterTemplateId,
},
],
},
],
};
Expand All @@ -220,6 +232,16 @@ describe('ChooseTemplatesPage', () => {
...LETTER_TEMPLATE,
id: letterTemplateId,
},
[frenchLetterTemplateId]: {
...LETTER_TEMPLATE,
name: 'French Letter Template',
id: frenchLetterTemplateId,
},
[spanishLetterTemplateId]: {
...LETTER_TEMPLATE,
name: 'Spanish Letter Template',
id: spanishLetterTemplateId,
},
};

getMessagePlanMock.mockResolvedValueOnce(planWithMultiple);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { render, screen } from '@testing-library/react';
import { MessagePlanBlock } from '@molecules/MessagePlanBlock/MessagePlanBlock';
import type { CascadeItem, Channel } from 'nhs-notify-backend-client';
import type { TemplateDto } from 'nhs-notify-backend-client';
import { EMAIL_TEMPLATE } from '@testhelpers/helpers';
import { EMAIL_TEMPLATE, LETTER_TEMPLATE } from '@testhelpers/helpers';
import { MessagePlanTemplates } from '@utils/routing-utils';

function buildCascadeItem(channel: Channel): CascadeItem {
return {
Expand All @@ -19,6 +20,8 @@ const mockTemplate: TemplateDto = {
name: 'Test email template',
};

const emptyConditionalTemplates: MessagePlanTemplates = {};

describe('MessagePlanBlock', () => {
it('should render the step number and the heading for the first cascade item', () => {
const channelItem = buildCascadeItem('EMAIL');
Expand All @@ -28,6 +31,7 @@ describe('MessagePlanBlock', () => {
index={0}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);

Expand All @@ -47,6 +51,7 @@ describe('MessagePlanBlock', () => {
index={2}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);

Expand All @@ -65,6 +70,7 @@ describe('MessagePlanBlock', () => {
index={0}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);

Expand All @@ -81,8 +87,9 @@ describe('MessagePlanBlock', () => {
<MessagePlanBlock
index={0}
channelItem={channelItem}
template={mockTemplate}
defaultTemplate={mockTemplate}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);
expect(screen.getByText('Test email template')).toBeInTheDocument();
Expand All @@ -95,8 +102,9 @@ describe('MessagePlanBlock', () => {
<MessagePlanBlock
index={0}
channelItem={channelItem}
template={mockTemplate}
defaultTemplate={mockTemplate}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);

Expand All @@ -121,6 +129,7 @@ describe('MessagePlanBlock', () => {
index={0}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);

Expand All @@ -133,13 +142,105 @@ describe('MessagePlanBlock', () => {
})
).not.toBeInTheDocument();
expect(
screen.queryByRole('link', {
screen.queryByRole('button', {
name: 'Remove Text message (SMS) template',
})
).not.toBeInTheDocument();
});
});

describe('when channel is LETTER', () => {
it('should render conditional templates section', () => {
const channelItem = buildCascadeItem('LETTER');

render(
<MessagePlanBlock
index={0}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);

expect(
screen.getByTestId('message-plan-conditional-templates')
).toBeInTheDocument();
});

it('should render accessible format templates', () => {
const channelItem = buildCascadeItem('LETTER');

render(
<MessagePlanBlock
index={0}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);

expect(
screen.getByRole('heading', {
level: 3,
name: 'Large print letter (optional)',
})
).toBeInTheDocument();
});

it('should render language templates section', () => {
const channelItem = buildCascadeItem('LETTER');

render(
<MessagePlanBlock
index={0}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);

expect(
screen.getByRole('heading', {
level: 3,
name: 'Other language letters (optional)',
})
).toBeInTheDocument();
});

it('should display conditional template names when provided', () => {
const largePrintTemplate: TemplateDto = {
...LETTER_TEMPLATE,
id: 'large-print-id',
name: 'Large print template',
};

const channelItem: CascadeItem = {
...buildCascadeItem('LETTER'),
conditionalTemplates: [
{
accessibleFormat: 'x1',
templateId: 'large-print-id',
},
],
};

const conditionalTemplates: MessagePlanTemplates = {
'large-print-id': largePrintTemplate,
};

render(
<MessagePlanBlock
index={0}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={conditionalTemplates}
/>
);

expect(screen.getByText('Large print template')).toBeInTheDocument();
});
});

describe.each(['NHSAPP', 'EMAIL', 'SMS', 'LETTER'] as const)(
'for channel %s with template',
(channel) => {
Expand All @@ -149,8 +250,9 @@ describe('MessagePlanBlock', () => {
<MessagePlanBlock
index={0}
channelItem={channelItem}
template={mockTemplate}
defaultTemplate={mockTemplate}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);
expect(asFragment()).toMatchSnapshot();
Expand All @@ -168,6 +270,7 @@ describe('MessagePlanBlock', () => {
index={0}
channelItem={channelItem}
routingConfigId='test-routing-config-id'
conditionalTemplates={emptyConditionalTemplates}
/>
);
expect(asFragment()).toMatchSnapshot();
Expand Down
Loading
Loading