Skip to content

Commit ec56e09

Browse files
committed
CCM-11492 Pass message plan ID through for URLs
1 parent e2bb74f commit ec56e09

File tree

9 files changed

+344
-214
lines changed

9 files changed

+344
-214
lines changed

frontend/src/__tests__/components/molecules/MessagePlanBlock.test.tsx

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ describe('MessagePlanBlock', () => {
2424
const channelItem = buildCascadeItem('EMAIL');
2525

2626
const { container } = render(
27-
<MessagePlanBlock index={0} channelItem={channelItem} />
27+
<MessagePlanBlock
28+
index={0}
29+
channelItem={channelItem}
30+
routingConfigId='test-routing-config-id'
31+
/>
2832
);
2933

3034
const stepNumber = container.querySelector('.message-plan-block-number');
@@ -39,7 +43,11 @@ describe('MessagePlanBlock', () => {
3943
const channelItem = buildCascadeItem('NHSAPP');
4044

4145
const { container } = render(
42-
<MessagePlanBlock index={2} channelItem={channelItem} />
46+
<MessagePlanBlock
47+
index={2}
48+
channelItem={channelItem}
49+
routingConfigId='test-routing-config-id'
50+
/>
4351
);
4452

4553
const stepNumber = container.querySelector('.message-plan-block-number');
@@ -52,7 +60,13 @@ describe('MessagePlanBlock', () => {
5260
it('should render the channel template section with the correct channel subheading', () => {
5361
const channelItem = buildCascadeItem('EMAIL');
5462

55-
render(<MessagePlanBlock index={0} channelItem={channelItem} />);
63+
render(
64+
<MessagePlanBlock
65+
index={0}
66+
channelItem={channelItem}
67+
routingConfigId='test-routing-config-id'
68+
/>
69+
);
5670

5771
expect(
5872
screen.getByRole('heading', { level: 3, name: 'Email' })
@@ -68,6 +82,7 @@ describe('MessagePlanBlock', () => {
6882
index={0}
6983
channelItem={channelItem}
7084
template={mockTemplate}
85+
routingConfigId='test-routing-config-id'
7186
/>
7287
);
7388
expect(screen.getByText('Test email template')).toBeInTheDocument();
@@ -81,14 +96,15 @@ describe('MessagePlanBlock', () => {
8196
index={0}
8297
channelItem={channelItem}
8398
template={mockTemplate}
99+
routingConfigId='test-routing-config-id'
84100
/>
85101
);
86102

87103
expect(
88104
screen.getByRole('link', { name: 'Change Email template' })
89105
).toBeInTheDocument();
90106
expect(
91-
screen.getByRole('link', { name: 'Remove Email template' })
107+
screen.getByRole('button', { name: 'Remove Email template' })
92108
).toBeInTheDocument();
93109
expect(
94110
screen.queryByRole('link', { name: 'Choose Email template' })
@@ -100,7 +116,13 @@ describe('MessagePlanBlock', () => {
100116
it('should show Choose link (and no Change/Remove links)', () => {
101117
const channelItem = buildCascadeItem('SMS');
102118

103-
render(<MessagePlanBlock index={0} channelItem={channelItem} />);
119+
render(
120+
<MessagePlanBlock
121+
index={0}
122+
channelItem={channelItem}
123+
routingConfigId='test-routing-config-id'
124+
/>
125+
);
104126

105127
expect(
106128
screen.getByRole('link', { name: 'Choose Text message (SMS) template' })
@@ -128,6 +150,7 @@ describe('MessagePlanBlock', () => {
128150
index={0}
129151
channelItem={channelItem}
130152
template={mockTemplate}
153+
routingConfigId='test-routing-config-id'
131154
/>
132155
);
133156
expect(asFragment()).toMatchSnapshot();
@@ -141,7 +164,11 @@ describe('MessagePlanBlock', () => {
141164
it('should match snapshot', async () => {
142165
const channelItem = buildCascadeItem(channel);
143166
const { asFragment } = render(
144-
<MessagePlanBlock index={0} channelItem={channelItem} />
167+
<MessagePlanBlock
168+
index={0}
169+
channelItem={channelItem}
170+
routingConfigId='test-routing-config-id'
171+
/>
145172
);
146173
expect(asFragment()).toMatchSnapshot();
147174
});

frontend/src/__tests__/components/molecules/MessagePlanChannelTemplate.test.tsx

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ import { MessagePlanChannelTemplate } from '@molecules/MessagePlanChannelTemplat
33
import type { TemplateDto } from 'nhs-notify-backend-client';
44

55
describe('MessagePlanChannelTemplate', () => {
6+
const routingConfigId = 'test-routing-config-id';
7+
68
it('should display the channel heading', () => {
7-
render(<MessagePlanChannelTemplate channel='EMAIL' />);
9+
render(
10+
<MessagePlanChannelTemplate
11+
channel='EMAIL'
12+
routingConfigId={routingConfigId}
13+
/>
14+
);
815

916
expect(
1017
screen.getByRole('heading', { level: 3, name: 'Email' })
@@ -13,7 +20,13 @@ describe('MessagePlanChannelTemplate', () => {
1320

1421
describe('when the channel is not required', () => {
1522
beforeEach(() => {
16-
render(<MessagePlanChannelTemplate channel='LETTER' required={false} />);
23+
render(
24+
<MessagePlanChannelTemplate
25+
channel='LETTER'
26+
required={false}
27+
routingConfigId={routingConfigId}
28+
/>
29+
);
1730
});
1831

1932
it('should display the heading with the "(optional)" suffix', () => {
@@ -25,7 +38,12 @@ describe('MessagePlanChannelTemplate', () => {
2538

2639
describe('when no template is selected', () => {
2740
beforeEach(() => {
28-
render(<MessagePlanChannelTemplate channel='NHSAPP' />);
41+
render(
42+
<MessagePlanChannelTemplate
43+
channel='NHSAPP'
44+
routingConfigId={routingConfigId}
45+
/>
46+
);
2947
});
3048

3149
it('should show the "Choose template" link with accessible name and href', () => {
@@ -34,7 +52,7 @@ describe('MessagePlanChannelTemplate', () => {
3452
});
3553
expect(link).toHaveAttribute(
3654
'href',
37-
'/message-plans/choose-nhs-app-template'
55+
`/message-plans/choose-nhs-app-template/${routingConfigId}`
3856
);
3957
});
4058

@@ -56,7 +74,11 @@ describe('MessagePlanChannelTemplate', () => {
5674

5775
beforeEach(() => {
5876
render(
59-
<MessagePlanChannelTemplate channel='SMS' template={testTemplate} />
77+
<MessagePlanChannelTemplate
78+
channel='SMS'
79+
template={testTemplate}
80+
routingConfigId={routingConfigId}
81+
/>
6082
);
6183
});
6284

@@ -70,7 +92,7 @@ describe('MessagePlanChannelTemplate', () => {
7092
});
7193
expect(link).toHaveAttribute(
7294
'href',
73-
'/message-plans/choose-text-message-template'
95+
`/message-plans/choose-text-message-template/${routingConfigId}`
7496
);
7597
});
7698

@@ -95,7 +117,10 @@ describe('MessagePlanChannelTemplate', () => {
95117
'should match snapshot for empty state (%s)',
96118
(channel) => {
97119
const { container } = render(
98-
<MessagePlanChannelTemplate channel={channel} />
120+
<MessagePlanChannelTemplate
121+
channel={channel}
122+
routingConfigId={routingConfigId}
123+
/>
99124
);
100125

101126
expect(container).toMatchSnapshot();
@@ -111,7 +136,11 @@ describe('MessagePlanChannelTemplate', () => {
111136
} as TemplateDto;
112137

113138
const { container } = render(
114-
<MessagePlanChannelTemplate channel={channel} template={testTemplate} />
139+
<MessagePlanChannelTemplate
140+
channel={channel}
141+
template={testTemplate}
142+
routingConfigId={routingConfigId}
143+
/>
115144
);
116145
expect(container).toMatchSnapshot();
117146
}

0 commit comments

Comments
 (0)