Skip to content

Commit cc6d37f

Browse files
committed
CCM-11492 Todos and test updates
1 parent 0a379f4 commit cc6d37f

File tree

16 files changed

+142
-126
lines changed

16 files changed

+142
-126
lines changed

frontend/src/__tests__/app/choose-templates/page.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
NHS_APP_TEMPLATE,
1818
SMS_TEMPLATE,
1919
} from '@testhelpers';
20-
import { redirect } from 'next/dist/server/api-utils';
20+
import { redirect } from 'next/navigation';
2121

2222
const { pageTitle } = content.pages.chooseTemplatesForMessagePlan;
2323

@@ -170,7 +170,7 @@ describe('ChooseTemplatesPage', () => {
170170
await ChooseTemplatesPage({
171171
params: Promise.resolve({ routingConfigId: 'missing-id' }),
172172
});
173-
// TODO: Update with real URL
173+
174174
expect(redirectMock).toHaveBeenCalledWith(
175175
'/message-plans/invalid',
176176
'replace'

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

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ describe('MessagePlanBlock', () => {
8585
);
8686

8787
expect(
88-
screen.getByRole('link', { name: 'Change template' })
88+
screen.getByRole('link', { name: 'Change Email template' })
8989
).toBeInTheDocument();
9090
expect(
91-
screen.getByRole('link', { name: 'Remove template' })
91+
screen.getByRole('link', { name: 'Remove Email template' })
9292
).toBeInTheDocument();
9393
expect(
94-
screen.queryByRole('link', { name: 'Choose template' })
94+
screen.queryByRole('link', { name: 'Choose Email template' })
9595
).not.toBeInTheDocument();
9696
});
9797
});
@@ -103,36 +103,21 @@ describe('MessagePlanBlock', () => {
103103
render(<MessagePlanBlock index={0} channelItem={channelItem} />);
104104

105105
expect(
106-
screen.getByRole('link', { name: 'Choose template' })
106+
screen.getByRole('link', { name: 'Choose Text message (SMS) template' })
107107
).toBeInTheDocument();
108108
expect(
109-
screen.queryByRole('link', { name: 'Change template' })
109+
screen.queryByRole('link', {
110+
name: 'Change Text message (SMS) template',
111+
})
110112
).not.toBeInTheDocument();
111113
expect(
112-
screen.queryByRole('link', { name: 'Remove template' })
114+
screen.queryByRole('link', {
115+
name: 'Remove Text message (SMS) template',
116+
})
113117
).not.toBeInTheDocument();
114118
});
115119
});
116120

117-
it('should render children inside a nested list when provided', () => {
118-
const channelItem = buildCascadeItem('LETTER');
119-
120-
const { container } = render(
121-
<MessagePlanBlock index={1} channelItem={channelItem}>
122-
<li>Child one</li>
123-
<li>Child two</li>
124-
</MessagePlanBlock>
125-
);
126-
127-
const nestedList = container.querySelector('li ul');
128-
expect(nestedList).toBeInTheDocument();
129-
130-
const nestedListItems = nestedList!.querySelectorAll('li');
131-
expect(nestedListItems.length).toBe(2);
132-
expect(nestedListItems[0]).toHaveTextContent('Child one');
133-
expect(nestedListItems[1]).toHaveTextContent('Child two');
134-
});
135-
136121
describe.each(['NHSAPP', 'EMAIL', 'SMS', 'LETTER'] as const)(
137122
'for channel %s with template',
138123
(channel) => {

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,20 @@ describe('MessagePlanChannelTemplate', () => {
3030

3131
it('should show the "Choose template" link with accessible name and href', () => {
3232
const link = screen.getByRole('link', {
33-
name: /choose\s*nhs app\s*template/i,
33+
name: 'Choose NHS App template',
3434
});
35-
36-
expect(link).toBeInTheDocument();
37-
expect(link).toHaveAttribute('href', ''); // TODO: CHANGE
35+
expect(link).toHaveAttribute(
36+
'href',
37+
'/message-plans/choose-nhs-app-template'
38+
);
3839
});
3940

4041
it('should not display the "Change template" or "Remove template" links', () => {
4142
expect(
42-
screen.queryByRole('link', { name: /change\s*nhs app\s*template/i })
43+
screen.queryByRole('link', { name: 'Change NHS App template' })
4344
).not.toBeInTheDocument();
4445
expect(
45-
screen.queryByRole('link', { name: /remove\s*nhs app\s*template/i })
46+
screen.queryByRole('link', { name: 'Remove NHS App template' })
4647
).not.toBeInTheDocument();
4748
});
4849
});
@@ -65,26 +66,26 @@ describe('MessagePlanChannelTemplate', () => {
6566

6667
it('should display the "Change template" link with accessible name and href', () => {
6768
const link = screen.getByRole('link', {
68-
name: /change\s*text message \(sms\)\s*template/i,
69+
name: 'Change Text message (SMS) template',
6970
});
70-
71-
expect(link).toBeInTheDocument();
72-
expect(link).toHaveAttribute('href', ''); // TODO: CHANGE
71+
expect(link).toHaveAttribute(
72+
'href',
73+
'/message-plans/choose-text-message-template'
74+
);
7375
});
7476

7577
it('should display the "Remove template" link with accessible name and href', () => {
7678
const link = screen.getByRole('link', {
77-
name: /remove\s*text message \(sms\)\s*template/i,
79+
name: 'Remove Text message (SMS) template',
7880
});
7981

80-
expect(link).toBeInTheDocument();
81-
expect(link).toHaveAttribute('href', ''); // TODO: CHANGE
82+
expect(link).toHaveAttribute('href', 'todo'); // TODO: CHANGE
8283
});
8384

8485
it('should not display the "Choose template" link', () => {
8586
expect(
8687
screen.queryByRole('link', {
87-
name: /choose\s*text message \(sms\)\s*template/i,
88+
name: 'Choose Text message (SMS) template',
8889
})
8990
).not.toBeInTheDocument();
9091
});

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exports[`MessagePlanBlock for channel EMAIL with no template should match snapsh
3030
</h3>
3131
<a
3232
class="nhsuk-link nhsuk-link--no-visited-state"
33-
href=""
33+
href="/message-plans/choose-email-template"
3434
>
3535
Choose
3636
<span
@@ -79,7 +79,7 @@ exports[`MessagePlanBlock for channel EMAIL with template should match snapshot
7979
<br />
8080
<a
8181
class="nhsuk-link nhsuk-link--no-visited-state"
82-
href=""
82+
href="/message-plans/choose-email-template"
8383
>
8484
Change
8585
<span
@@ -93,7 +93,7 @@ exports[`MessagePlanBlock for channel EMAIL with template should match snapshot
9393
<p>
9494
<a
9595
class="channel-template-link--remove nhsuk-link"
96-
href=""
96+
href="todo"
9797
>
9898
Remove
9999
<span
@@ -140,7 +140,7 @@ exports[`MessagePlanBlock for channel LETTER with no template should match snaps
140140
</h3>
141141
<a
142142
class="nhsuk-link nhsuk-link--no-visited-state"
143-
href=""
143+
href="/message-plans/choose-standard-english-letter-template"
144144
>
145145
Choose
146146
<span
@@ -189,7 +189,7 @@ exports[`MessagePlanBlock for channel LETTER with template should match snapshot
189189
<br />
190190
<a
191191
class="nhsuk-link nhsuk-link--no-visited-state"
192-
href=""
192+
href="/message-plans/choose-standard-english-letter-template"
193193
>
194194
Change
195195
<span
@@ -203,7 +203,7 @@ exports[`MessagePlanBlock for channel LETTER with template should match snapshot
203203
<p>
204204
<a
205205
class="channel-template-link--remove nhsuk-link"
206-
href=""
206+
href="todo"
207207
>
208208
Remove
209209
<span
@@ -250,7 +250,7 @@ exports[`MessagePlanBlock for channel NHSAPP with no template should match snaps
250250
</h3>
251251
<a
252252
class="nhsuk-link nhsuk-link--no-visited-state"
253-
href=""
253+
href="/message-plans/choose-nhs-app-template"
254254
>
255255
Choose
256256
<span
@@ -299,7 +299,7 @@ exports[`MessagePlanBlock for channel NHSAPP with template should match snapshot
299299
<br />
300300
<a
301301
class="nhsuk-link nhsuk-link--no-visited-state"
302-
href=""
302+
href="/message-plans/choose-nhs-app-template"
303303
>
304304
Change
305305
<span
@@ -313,7 +313,7 @@ exports[`MessagePlanBlock for channel NHSAPP with template should match snapshot
313313
<p>
314314
<a
315315
class="channel-template-link--remove nhsuk-link"
316-
href=""
316+
href="todo"
317317
>
318318
Remove
319319
<span
@@ -360,7 +360,7 @@ exports[`MessagePlanBlock for channel SMS with no template should match snapshot
360360
</h3>
361361
<a
362362
class="nhsuk-link nhsuk-link--no-visited-state"
363-
href=""
363+
href="/message-plans/choose-text-message-template"
364364
>
365365
Choose
366366
<span
@@ -409,7 +409,7 @@ exports[`MessagePlanBlock for channel SMS with template should match snapshot 1`
409409
<br />
410410
<a
411411
class="nhsuk-link nhsuk-link--no-visited-state"
412-
href=""
412+
href="/message-plans/choose-text-message-template"
413413
>
414414
Change
415415
<span
@@ -423,7 +423,7 @@ exports[`MessagePlanBlock for channel SMS with template should match snapshot 1`
423423
<p>
424424
<a
425425
class="channel-template-link--remove nhsuk-link"
426-
href=""
426+
href="todo"
427427
>
428428
Remove
429429
<span

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for empty state (EMAIL
1515
</h3>
1616
<a
1717
class="nhsuk-link nhsuk-link--no-visited-state"
18-
href=""
18+
href="/message-plans/choose-email-template"
1919
>
2020
Choose
2121
<span
@@ -46,7 +46,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for empty state (LETTE
4646
</h3>
4747
<a
4848
class="nhsuk-link nhsuk-link--no-visited-state"
49-
href=""
49+
href="/message-plans/choose-standard-english-letter-template"
5050
>
5151
Choose
5252
<span
@@ -77,7 +77,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for empty state (NHSAP
7777
</h3>
7878
<a
7979
class="nhsuk-link nhsuk-link--no-visited-state"
80-
href=""
80+
href="/message-plans/choose-nhs-app-template"
8181
>
8282
Choose
8383
<span
@@ -108,7 +108,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for empty state (SMS)
108108
</h3>
109109
<a
110110
class="nhsuk-link nhsuk-link--no-visited-state"
111-
href=""
111+
href="/message-plans/choose-text-message-template"
112112
>
113113
Choose
114114
<span
@@ -142,7 +142,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
142142
<br />
143143
<a
144144
class="nhsuk-link nhsuk-link--no-visited-state"
145-
href=""
145+
href="/message-plans/choose-email-template"
146146
>
147147
Change
148148
<span
@@ -157,7 +157,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
157157
<p>
158158
<a
159159
class="channel-template-link--remove nhsuk-link"
160-
href=""
160+
href="todo"
161161
>
162162
Remove
163163
<span
@@ -192,7 +192,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
192192
<br />
193193
<a
194194
class="nhsuk-link nhsuk-link--no-visited-state"
195-
href=""
195+
href="/message-plans/choose-standard-english-letter-template"
196196
>
197197
Change
198198
<span
@@ -207,7 +207,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
207207
<p>
208208
<a
209209
class="channel-template-link--remove nhsuk-link"
210-
href=""
210+
href="todo"
211211
>
212212
Remove
213213
<span
@@ -242,7 +242,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
242242
<br />
243243
<a
244244
class="nhsuk-link nhsuk-link--no-visited-state"
245-
href=""
245+
href="/message-plans/choose-nhs-app-template"
246246
>
247247
Change
248248
<span
@@ -257,7 +257,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
257257
<p>
258258
<a
259259
class="channel-template-link--remove nhsuk-link"
260-
href=""
260+
href="todo"
261261
>
262262
Remove
263263
<span
@@ -292,7 +292,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
292292
<br />
293293
<a
294294
class="nhsuk-link nhsuk-link--no-visited-state"
295-
href=""
295+
href="/message-plans/choose-text-message-template"
296296
>
297297
Change
298298
<span
@@ -307,7 +307,7 @@ exports[`MessagePlanChannelTemplate should match snapshot for selected template
307307
<p>
308308
<a
309309
class="channel-template-link--remove nhsuk-link"
310-
href=""
310+
href="todo"
311311
>
312312
Remove
313313
<span

frontend/src/__tests__/components/organisms/CreateEditMessagePlan.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('CreateEditMessagePlan', () => {
131131
const link = screen.getByTestId('change-message-plan-name-link');
132132
expect(link.textContent).toBe('Change name');
133133
expect(link.getAttribute('href')).toBe(
134-
'/templates/message-plans/change-name'
134+
'/message-plans/create-message-plan'
135135
);
136136
});
137137

@@ -167,4 +167,6 @@ describe('CreateEditMessagePlan', () => {
167167
);
168168
expect(asFragment()).toMatchSnapshot();
169169
});
170+
171+
// TODO: CCM-11495 Add tests for validation (ErrorSummary)
170172
});

0 commit comments

Comments
 (0)