Skip to content

Commit ee26210

Browse files
committed
CCM-11496: get ready to move
1 parent 8000d20 commit ee26210

File tree

25 files changed

+840
-266
lines changed

25 files changed

+840
-266
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
119119
>
120120
NHS App
121121
</span>
122-
122+
123123
template
124124
</a>
125125
</li>
@@ -147,7 +147,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
147147
>
148148
NHS App
149149
</span>
150-
150+
151151
template
152152
</button>
153153
</form>
@@ -292,7 +292,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
292292
>
293293
Text message (SMS)
294294
</span>
295-
295+
296296
template
297297
</a>
298298
</li>
@@ -320,7 +320,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
320320
>
321321
Text message (SMS)
322322
</span>
323-
323+
324324
template
325325
</button>
326326
</form>
@@ -459,7 +459,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
459459
>
460460
Email
461461
</span>
462-
462+
463463
template
464464
</a>
465465
</li>
@@ -603,7 +603,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
603603
>
604604
Letter
605605
</span>
606-
606+
607607
template
608608
</a>
609609
</li>
@@ -631,7 +631,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
631631
>
632632
Letter
633633
</span>
634-
634+
635635
template
636636
</button>
637637
</form>
@@ -650,7 +650,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
650650
class="nhsuk-button"
651651
data-testid="move-to-production-cta"
652652
draggable="false"
653-
href="/message-plans/move-to-production/fbb81055-79b9-4759-ac07-d191ae57be34"
653+
href="/message-plans/get-ready-to-move/fbb81055-79b9-4759-ac07-d191ae57be34"
654654
role="button"
655655
>
656656
Move to production

frontend/src/__tests__/app/message-plans/create-message-plan/server-action.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import type { CascadeItem, RoutingConfig } from 'nhs-notify-backend-client';
44
import type { MessageOrder } from 'nhs-notify-web-template-management-utils';
55
import { createMessagePlanServerAction } from '@app/message-plans/create-message-plan/server-action';
66
import { NextRedirectError } from '@testhelpers/next-redirect';
7-
import { createRoutingConfig } from '@utils/form-actions';
7+
import { createRoutingConfig } from '@utils/message-plans';
88

99
jest.mock('next/navigation');
1010
jest.mocked(redirect).mockImplementation((url, type) => {
1111
throw new NextRedirectError(url, type);
1212
});
1313

14-
jest.mock('@utils/form-actions');
14+
jest.mock('@utils/message-plans');
1515
jest.mocked(createRoutingConfig).mockResolvedValue(
1616
mock<RoutingConfig>({
1717
id: 'mock-routing-config-id',
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`matches snapshot 1`] = `
4+
<DocumentFragment>
5+
<main
6+
class="nhsuk-main-wrapper"
7+
id="maincontent"
8+
role="main"
9+
>
10+
<div
11+
class="nhsuk-grid-row"
12+
>
13+
<div
14+
class="nhsuk-grid-column-two-thirds"
15+
>
16+
<span
17+
class="nhsuk-caption-xl"
18+
>
19+
Step 1 of 2
20+
</span>
21+
<h1
22+
class="nhsuk-heading-xl"
23+
>
24+
Get ready to move message plan to production
25+
</h1>
26+
<table
27+
class="nhsuk-u-margin-bottom-6 table"
28+
>
29+
<tbody
30+
class="nhsuk-table__body"
31+
>
32+
<tr
33+
class="nhsuk-table__row"
34+
>
35+
<th
36+
class="nhsuk-table__cell"
37+
>
38+
Name
39+
</th>
40+
<td
41+
class="nhsuk-table__cell"
42+
>
43+
My Routing Config
44+
</td>
45+
</tr>
46+
</tbody>
47+
</table>
48+
<p>
49+
Moving message plans from draft to production means they are ready to send.
50+
</p>
51+
<p>
52+
Any templates used in these message plans will be locked.
53+
</p>
54+
<p>
55+
Messages will only be sent to recipients when you make a request with
56+
<a
57+
href="https://digital.nhs.uk/developer/api-catalogue/nhs-notify"
58+
rel="noopener noreferrer"
59+
target="_blank"
60+
>
61+
NHS Notify API
62+
</a>
63+
or
64+
<a
65+
href="https://digital.nhs.uk/developer/api-catalogue/nhs-notify-mesh"
66+
rel="noopener noreferrer"
67+
target="_blank"
68+
>
69+
NHS Notify MESH
70+
</a>
71+
.
72+
</p>
73+
<h2
74+
class="nhsuk-heading-m"
75+
id="before-you-continue"
76+
>
77+
Before you continue
78+
</h2>
79+
<p>
80+
Make sure:
81+
</p>
82+
<ul
83+
class="nhsuk-list nhsuk-list--bullet"
84+
>
85+
<li>
86+
the relevant stakeholders in your team have approved your templates and message plan
87+
</li>
88+
<li>
89+
your templates have no errors
90+
</li>
91+
</ul>
92+
<div
93+
class="nhsuk-warning-callout"
94+
>
95+
<h3
96+
class="nhsuk-warning-callout__label"
97+
>
98+
Important
99+
<span
100+
class="nhsuk-u-visually-hidden"
101+
>
102+
:
103+
</span>
104+
</h3>
105+
<p>
106+
You cannot edit anything that is in production.
107+
</p>
108+
<p>
109+
If you need to edit your templates or message plans, you can copy and replace them.
110+
</p>
111+
</div>
112+
<div
113+
class="nhsuk-form-group"
114+
>
115+
<a
116+
aria-disabled="false"
117+
class="nhsuk-button"
118+
data-testid="continue-link"
119+
draggable="false"
120+
href="/templates/message-plans/review-and-move-to-production/routing-config-id"
121+
role="button"
122+
>
123+
Continue
124+
</a>
125+
<a
126+
aria-disabled="false"
127+
class="nhsuk-button nhsuk-button--secondary nhsuk-u-margin-left-3"
128+
data-testid="cancel-link"
129+
draggable="false"
130+
href="/templates/message-plans"
131+
role="button"
132+
>
133+
Keep in draft
134+
</a>
135+
</div>
136+
</div>
137+
</div>
138+
</main>
139+
</DocumentFragment>
140+
`;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { render } from '@testing-library/react';
2+
import { mock } from 'jest-mock-extended';
3+
import { redirect, RedirectType } from 'next/navigation';
4+
import { RoutingConfig } from 'nhs-notify-backend-client';
5+
import { getRoutingConfig } from '@utils/message-plans';
6+
import Page, {
7+
metadata,
8+
} from '../../../../app/message-plans/get-ready-to-move/[routingConfigId]/page';
9+
10+
jest.mock('next/navigation');
11+
jest.mock('@utils/message-plans');
12+
13+
const routingConfig = mock<RoutingConfig>({
14+
name: 'My Routing Config',
15+
});
16+
17+
beforeEach(() => {
18+
jest.clearAllMocks();
19+
});
20+
21+
test('metadata', () => {
22+
expect(metadata).toEqual({
23+
title: 'Get ready to move message plan to production - NHS Notify',
24+
});
25+
});
26+
27+
test('matches snapshot', async () => {
28+
jest.mocked(getRoutingConfig).mockResolvedValueOnce(routingConfig);
29+
30+
const page = await Page({
31+
params: Promise.resolve({ routingConfigId: 'routing-config-id' }),
32+
});
33+
34+
const container = render(page);
35+
36+
expect(container.asFragment()).toMatchSnapshot();
37+
});
38+
39+
test('redirects if routing config is not found from path parameter', async () => {
40+
await Page({
41+
params: Promise.resolve({ routingConfigId: 'routing-config-id' }),
42+
});
43+
44+
expect(getRoutingConfig).toHaveBeenCalledWith('routing-config-id');
45+
46+
expect(redirect).toHaveBeenCalledWith(
47+
'/message-plans/invalid',
48+
RedirectType.replace
49+
);
50+
});

0 commit comments

Comments
 (0)