Skip to content

Commit 488c8aa

Browse files
authored
CCM-9751: enable letters (#496)
1 parent e3e2dad commit 488c8aa

File tree

27 files changed

+5
-455
lines changed

27 files changed

+5
-455
lines changed

frontend/jest.setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ Object.assign(global, {
3232
createMocks();
3333

3434
// set feature flag
35-
process.env.NEXT_PUBLIC_ENABLE_LETTERS = 'true';
3635
process.env.NEXT_PUBLIC_ENABLE_PROOFING = 'true';

frontend/src/__tests__/app/choose-a-template-type/__snapshots__/page.test.tsx.snap

Lines changed: 0 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,164 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`ChooseATemplateTypePage - LETTER option is hidden when feature flag is not enabled 1`] = `
4-
<DocumentFragment>
5-
<div
6-
class="nhsuk-back-link"
7-
>
8-
<a
9-
class="nhsuk-back-link__link"
10-
data-testid="back-to-templates-link"
11-
href="/templates/message-templates"
12-
>
13-
<svg
14-
aria-hidden="true"
15-
class="nhsuk-icon nhsuk-icon__chevron-left"
16-
height="24"
17-
viewBox="0 0 24 24"
18-
width="24"
19-
xmlns="http://www.w3.org/2000/svg"
20-
>
21-
<path
22-
d="M8.5 12c0-.3.1-.5.3-.7l5-5c.4-.4 1-.4 1.4 0s.4 1 0 1.4L10.9 12l4.3 4.3c.4.4.4 1 0 1.4s-1 .4-1.4 0l-5-5c-.2-.2-.3-.4-.3-.7z"
23-
/>
24-
</svg>
25-
Back to all templates
26-
</a>
27-
</div>
28-
<main
29-
class="nhsuk-main-wrapper"
30-
id="maincontent"
31-
role="main"
32-
>
33-
<form
34-
action="/action"
35-
>
36-
<input
37-
name="form-id"
38-
readonly=""
39-
type="hidden"
40-
value="choose-a-template-type"
41-
/>
42-
<input
43-
name="csrf_token"
44-
readonly=""
45-
type="hidden"
46-
value="no_token"
47-
/>
48-
<div
49-
class="nhsuk-form-group"
50-
>
51-
<fieldset
52-
class="nhsuk-fieldset"
53-
>
54-
<legend
55-
class="nhsuk-fieldset__legend nhsuk-fieldset__legend--l"
56-
data-testid="templateType-form__legend"
57-
>
58-
<h1
59-
class="nhsuk-fieldset__heading"
60-
>
61-
Choose a template type to create
62-
</h1>
63-
</legend>
64-
<p>
65-
<a
66-
href="/features"
67-
rel="noopener noreferrer"
68-
target="_blank"
69-
>
70-
Learn more about message channels (opens in a new tab)
71-
</a>
72-
</p>
73-
<div
74-
class="nhsuk-form-group"
75-
>
76-
<div
77-
class="nhsuk-hint"
78-
id="templateType--hint"
79-
>
80-
Select one option
81-
</div>
82-
<div
83-
aria-describedby="templateType--hint"
84-
class="nhsuk-radios"
85-
id="templateType"
86-
>
87-
<div
88-
class="nhsuk-radios__item"
89-
>
90-
<input
91-
class="nhsuk-radios__input"
92-
data-testid="NHS_APP-radio"
93-
id="templateType-NHS_APP"
94-
name="templateType"
95-
type="radio"
96-
value="NHS_APP"
97-
/>
98-
<label
99-
class="nhsuk-label nhsuk-radios__label"
100-
for="templateType-NHS_APP"
101-
id="templateType-NHS_APP--label"
102-
>
103-
NHS App message
104-
</label>
105-
</div>
106-
<div
107-
class="nhsuk-radios__item"
108-
>
109-
<input
110-
class="nhsuk-radios__input"
111-
data-testid="EMAIL-radio"
112-
id="templateType-EMAIL"
113-
name="templateType"
114-
type="radio"
115-
value="EMAIL"
116-
/>
117-
<label
118-
class="nhsuk-label nhsuk-radios__label"
119-
for="templateType-EMAIL"
120-
id="templateType-EMAIL--label"
121-
>
122-
Email
123-
</label>
124-
</div>
125-
<div
126-
class="nhsuk-radios__item"
127-
>
128-
<input
129-
class="nhsuk-radios__input"
130-
data-testid="SMS-radio"
131-
id="templateType-SMS"
132-
name="templateType"
133-
type="radio"
134-
value="SMS"
135-
/>
136-
<label
137-
class="nhsuk-label nhsuk-radios__label"
138-
for="templateType-SMS"
139-
id="templateType-SMS--label"
140-
>
141-
Text message (SMS)
142-
</label>
143-
</div>
144-
</div>
145-
</div>
146-
</fieldset>
147-
</div>
148-
<button
149-
aria-disabled="false"
150-
class="nhsuk-button"
151-
data-testid="submit-button"
152-
id="choose-a-template-type-submit-button"
153-
type="submit"
154-
>
155-
Continue
156-
</button>
157-
</form>
158-
</main>
159-
</DocumentFragment>
160-
`;
161-
1623
exports[`ChooseATemplateTypePage 1`] = `
1634
<DocumentFragment>
1645
<div

frontend/src/__tests__/app/choose-a-template-type/page.test.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,3 @@ test('ChooseATemplateTypePage', async () => {
4141
expect(await generateMetadata()).toEqual({ title: pageTitle });
4242
expect(container.asFragment()).toMatchSnapshot();
4343
});
44-
45-
test('ChooseATemplateTypePage - LETTER option is hidden when feature flag is not enabled', async () => {
46-
process.env.NEXT_PUBLIC_ENABLE_LETTERS = 'false';
47-
48-
const page = await ChooseATemplateTypePage();
49-
50-
const container = render(page);
51-
52-
expect(container.asFragment()).toMatchSnapshot();
53-
});

frontend/src/__tests__/app/create-and-submit-templates/__snapshots__/page.test.tsx.snap

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -78,79 +78,3 @@ exports[`matches the snapshot 1`] = `
7878
</main>
7979
</div>
8080
`;
81-
82-
exports[`matches the snapshot with letters feature flag disabled 1`] = `
83-
<div>
84-
<main
85-
class="nhsuk-main-wrapper"
86-
id="maincontent"
87-
role="main"
88-
>
89-
<div
90-
class="nhsuk-grid-row"
91-
data-testid="page-content-wrapper"
92-
>
93-
<div
94-
class="nhsuk-grid-column-two-thirds"
95-
>
96-
<h1
97-
class="nhsuk-heading-xl"
98-
data-testid="page-heading"
99-
>
100-
Create and submit a template to NHS Notify
101-
</h1>
102-
<p>
103-
Use this tool to create and submit templates you want to send as messages using NHS Notify.
104-
</p>
105-
<p>
106-
You can create templates for:
107-
</p>
108-
<ul
109-
class="nhsuk-list nhsuk-list--bullet"
110-
>
111-
<li>
112-
NHS App messages
113-
</li>
114-
<li>
115-
emails
116-
</li>
117-
<li>
118-
text messages (SMS)
119-
</li>
120-
</ul>
121-
<p>
122-
When you submit a template, it will be used by NHS Notify to set up the messages you want to send.
123-
</p>
124-
<h2
125-
class="nhsuk-heading-l"
126-
data-testid="page-sub-heading"
127-
>
128-
Before you start
129-
</h2>
130-
<p>
131-
Only use this tool if your message content has been approved by the relevant stakeholders in your team.
132-
</p>
133-
<p>
134-
You can save a template as a draft and edit it later.
135-
</p>
136-
<p>
137-
If you want to change a submitted template, you must create a new template to replace it.
138-
</p>
139-
<p>
140-
You can access this tool by signing in with your Care Identity.
141-
</p>
142-
<a
143-
aria-disabled="false"
144-
class="nhsuk-button"
145-
data-testid="start-now-button"
146-
draggable="false"
147-
href="/templates/message-templates"
148-
role="button"
149-
>
150-
Start now
151-
</a>
152-
</div>
153-
</div>
154-
</main>
155-
</div>
156-
`;
Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import { render } from '@testing-library/react';
22
import HomePage from '@app/create-and-submit-templates/page';
33

4-
const OLD_ENV = { ...process.env };
5-
64
beforeEach(() => {
75
jest.resetAllMocks();
8-
process.env.NEXT_PUBLIC_ENABLE_LETTERS = 'true';
9-
});
10-
11-
afterAll(() => {
12-
process.env = OLD_ENV;
136
});
147

158
it('matches the snapshot', () => {
169
const { container } = render(<HomePage />);
1710
expect(container).toMatchSnapshot();
1811
});
19-
20-
it('matches the snapshot with letters feature flag disabled', () => {
21-
process.env.NEXT_PUBLIC_ENABLE_LETTERS = 'false';
22-
23-
const { container } = render(<HomePage />);
24-
expect(container).toMatchSnapshot();
25-
});

frontend/src/__tests__/app/create-letter-template/page.test.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,14 @@
33
*/
44
import CreateLetterTemplatePage from '@app/create-letter-template/page';
55

6-
const OLD_ENV = { ...process.env };
7-
86
describe('CreateLetterTemplatePage', () => {
97
beforeEach(() => {
108
jest.resetAllMocks();
11-
process.env.NEXT_PUBLIC_ENABLE_LETTERS = 'true';
12-
});
13-
14-
afterAll(() => {
15-
process.env = OLD_ENV;
169
});
1710

1811
it('should render CreateLetterTemplatePage', async () => {
1912
const page = await CreateLetterTemplatePage();
2013

2114
expect(page).toMatchSnapshot();
2215
});
23-
24-
it('returns 404 when letters feature flag is not enabled', async () => {
25-
process.env.NEXT_PUBLIC_ENABLE_LETTERS = 'false';
26-
27-
await expect(CreateLetterTemplatePage()).rejects.toThrow(
28-
'NEXT_HTTP_ERROR_FALLBACK;404'
29-
);
30-
});
3116
});

frontend/src/app/choose-a-template-type/page.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ export async function generateMetadata(): Promise<Metadata> {
1414
}
1515

1616
const ChooseATemplateTypePage = async () => {
17-
const templateTypes = TEMPLATE_TYPE_LIST.filter(
18-
(t) => process.env.NEXT_PUBLIC_ENABLE_LETTERS === 'true' || t !== 'LETTER'
19-
);
20-
21-
return <ChooseTemplate templateTypes={templateTypes} />;
17+
return <ChooseTemplate templateTypes={TEMPLATE_TYPE_LIST} />;
2218
};
2319

2420
export default ChooseATemplateTypePage;

frontend/src/app/create-and-submit-templates/page.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ export const metadata: Metadata = {
1010
};
1111

1212
export default function HomePage() {
13-
const channelList =
14-
process.env.NEXT_PUBLIC_ENABLE_LETTERS === 'true'
15-
? [...homePageContent.list, 'letters']
16-
: homePageContent.list;
17-
1813
return (
1914
<NHSNotifyMain>
2015
<div className='nhsuk-grid-row' data-testid='page-content-wrapper'>
@@ -27,7 +22,7 @@ export default function HomePage() {
2722
<p>{homePageContent.text2}</p>
2823

2924
<ul className='nhsuk-list nhsuk-list--bullet'>
30-
{channelList.map((channel, i) => (
25+
{homePageContent.channelList.map((channel, i) => (
3126
<li key={`template${i + 1}`}>{channel}</li>
3227
))}
3328
</ul>

frontend/src/app/create-letter-template/page.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { notFound } from 'next/navigation';
21
import { CreateLetterTemplate } from 'nhs-notify-web-template-management-utils';
32
import { LetterTemplateForm } from '@forms/LetterTemplateForm/LetterTemplateForm';
43

54
const CreateLetterTemplatePage = async () => {
6-
if (process.env.NEXT_PUBLIC_ENABLE_LETTERS !== 'true') notFound();
7-
85
const initialState: CreateLetterTemplate = {
96
templateType: 'LETTER',
107
name: '',

frontend/src/content/content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const homePage = {
170170
text1:
171171
'Use this tool to create and submit templates you want to send as messages using NHS Notify.',
172172
text2: 'You can create templates for:',
173-
list: ['NHS App messages', 'emails', 'text messages (SMS)'],
173+
channelList: ['NHS App messages', 'emails', 'text messages (SMS)', 'letters'],
174174
text3:
175175
'When you submit a template, it will be used by NHS Notify to set up the messages you want to send.',
176176
pageSubHeading: 'Before you start',

0 commit comments

Comments
 (0)