Skip to content

Commit a9a79d9

Browse files
committed
Merge branch 'main' of https://github.com/NHSDigital/nhs-notify-web-template-management into feature/CCM-10048_flakey-tests
2 parents 92a2e66 + 4bb14c4 commit a9a79d9

File tree

56 files changed

+450
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+450
-522
lines changed

.github/workflows/reusable_internal_repo_build.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,20 @@ jobs:
8181
# Poll GitHub API to check the workflow status
8282
run_id=""
8383
for i in {1..12}; do
84-
run_id=$(curl -s \
84+
in_progress=$(curl -s \
8585
-H "Accept: application/vnd.github+json" \
8686
-H "Authorization: Bearer ${{ secrets.PR_TRIGGER_PAT }}" \
8787
-H "X-GitHub-Api-Version: 2022-11-28" \
88-
"https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/runs?event=workflow_dispatch&status=in_progress" \
89-
| jq -r '.workflow_runs[0].id')
88+
"https://api.github.com/repos/NHSDigital/nhs-notify-internal/actions/runs?event=workflow_dispatch&status=in_progress")
89+
90+
run_id=$(echo "$in_progress" | jq -r \
91+
--arg env "${{ inputs.targetEnvironment }}" \
92+
--arg component "${{ inputs.targetComponent }}" \
93+
--arg group "${{ inputs.targetAccountGroup }}" \
94+
--arg releaseVersion "${{ inputs.releaseVersion }}" \
95+
'.workflow_runs[]
96+
| select(.name | contains($env) and contains($component) and contains($group) and contains($releaseVersion))
97+
| .id' | head -n 1)
9098
9199
if [[ -n "$run_id" && "$run_id" != null ]]; then
92100
echo "Found workflow run with ID: $run_id"

frontend/jest.setup.ts

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

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

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

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

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: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -66,81 +66,7 @@ exports[`matches the snapshot 1`] = `
6666
<a
6767
aria-disabled="false"
6868
class="nhsuk-button"
69-
draggable="false"
70-
href="/templates/message-templates"
71-
role="button"
72-
>
73-
Start now
74-
</a>
75-
</div>
76-
</div>
77-
</main>
78-
</div>
79-
`;
80-
81-
exports[`matches the snapshot with letters feature flag disabled 1`] = `
82-
<div>
83-
<main
84-
class="nhsuk-main-wrapper"
85-
id="maincontent"
86-
role="main"
87-
>
88-
<div
89-
class="nhsuk-grid-row"
90-
data-testid="page-content-wrapper"
91-
>
92-
<div
93-
class="nhsuk-grid-column-two-thirds"
94-
>
95-
<h1
96-
class="nhsuk-heading-xl"
97-
data-testid="page-heading"
98-
>
99-
Create and submit a template to NHS Notify
100-
</h1>
101-
<p>
102-
Use this tool to create and submit templates you want to send as messages using NHS Notify.
103-
</p>
104-
<p>
105-
You can create templates for:
106-
</p>
107-
<ul
108-
class="nhsuk-list nhsuk-list--bullet"
109-
>
110-
<li>
111-
NHS App messages
112-
</li>
113-
<li>
114-
emails
115-
</li>
116-
<li>
117-
text messages (SMS)
118-
</li>
119-
</ul>
120-
<p>
121-
When you submit a template, it will be used by NHS Notify to set up the messages you want to send.
122-
</p>
123-
<h2
124-
class="nhsuk-heading-l"
125-
data-testid="page-sub-heading"
126-
>
127-
Before you start
128-
</h2>
129-
<p>
130-
Only use this tool if your message content has been approved by the relevant stakeholders in your team.
131-
</p>
132-
<p>
133-
You can save a template as a draft and edit it later.
134-
</p>
135-
<p>
136-
If you want to change a submitted template, you must create a new template to replace it.
137-
</p>
138-
<p>
139-
You can access this tool by signing in with your Care Identity.
140-
</p>
141-
<a
142-
aria-disabled="false"
143-
class="nhsuk-button"
69+
data-testid="start-now-button"
14470
draggable="false"
14571
href="/templates/message-templates"
14672
role="button"
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/__tests__/components/forms/ChooseTemplate/__snapshots__/ChooseTemplate.test.tsx.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports[`Choose template page Client-side validation triggers 1`] = `
77
>
88
<a
99
class="nhsuk-back-link__link"
10+
data-testid="back-to-templates-link"
1011
href="/templates/message-templates"
1112
>
1213
<svg
@@ -220,6 +221,7 @@ exports[`Choose template page renders error component 1`] = `
220221
>
221222
<a
222223
class="nhsuk-back-link__link"
224+
data-testid="back-to-templates-link"
223225
href="/templates/message-templates"
224226
>
225227
<svg
@@ -422,6 +424,7 @@ exports[`Choose template page selects one radio button at a time 1`] = `
422424
>
423425
<a
424426
class="nhsuk-back-link__link"
427+
data-testid="back-to-templates-link"
425428
href="/templates/message-templates"
426429
>
427430
<svg

0 commit comments

Comments
 (0)