Skip to content

Commit 698d1ff

Browse files
committed
CCM-11148: add accessibility test --no-verify
1 parent d2ec376 commit 698d1ff

File tree

11 files changed

+100
-14
lines changed

11 files changed

+100
-14
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ exports[`MessagePlans matches snapshot 1`] = `
8888
aria-disabled="false"
8989
class="nhsuk-button"
9090
draggable="false"
91-
href="/create-new-message-plan"
91+
href="/message-plans/choose-message-order"
92+
id="create-message-plan-button"
9293
role="button"
9394
>
9495
New message plan

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports[`MessagePlansList matches snapshot when data is available 1`] = `
44
<DocumentFragment>
55
<details
66
class="nhsuk-details nhsuk-expander"
7+
id="message-plans-list-draft"
78
>
89
<summary
910
class="nhsuk-details__summary nhsuk-heading-s nhsuk-u-margin-bottom-0"
@@ -115,6 +116,7 @@ exports[`MessagePlansList matches snapshot when no data is available 1`] = `
115116
<DocumentFragment>
116117
<details
117118
class="nhsuk-details nhsuk-expander"
119+
id="message-plans-list-draft"
118120
>
119121
<summary
120122
class="nhsuk-details__summary nhsuk-heading-s nhsuk-u-margin-bottom-0"

frontend/src/components/molecules/MessagePlans/MessagePlans.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@molecules/MessagePlansList/MessagePlansList';
99
import content from '@content/content';
1010
import classNames from 'classnames';
11+
import Link from 'next/link';
1112

1213
const {
1314
pages: { messagePlansPage },
@@ -91,7 +92,9 @@ export const MessagePlans = (props: MessagePlansProps) => {
9192
</p>
9293
</Details.Text>
9394
</Details>
94-
<Button href={button.link}>{button.text}</Button>
95+
<Link passHref legacyBehavior href={button.link}>
96+
<Button id='create-message-plan-button'>{button.text}</Button>
97+
</Link>
9598
<MessagePlansList
9699
planType='Draft'
97100
plans={props.draft.plans}

frontend/src/components/molecules/MessagePlansList/MessagePlansList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const MessagePlansList = (props: MessagePlansListProps) => {
5454
));
5555

5656
return (
57-
<Details expander>
57+
<Details expander id={`message-plans-list-${status.toLowerCase()}`}>
5858
<Details.Summary
5959
className={classNames('nhsuk-heading-s', 'nhsuk-u-margin-bottom-0')}
6060
>

frontend/src/content/content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ const messagePlansPage = {
10581058
},
10591059
button: {
10601060
text: 'New message plan',
1061-
link: '/create-new-message-plan',
1061+
link: '/message-plans/choose-message-order',
10621062
},
10631063
};
10641064

tests/accessibility/.pa11y-ci.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
emailTemplateSubmittedPage,
1515
letterTemplateSubmittedPage,
1616
messageTemplatesPage,
17+
messagePlansPage,
1718
nhsAppTemplateSubmittedPage,
1819
previewEmailTemplateErrorPage,
1920
previewEmailTemplatePage,
@@ -113,6 +114,10 @@ const letters = [
113114
previewSubmittedLetterTemplatePage(messageTemplatesUrl),
114115
];
115116

117+
const messagePlans = [
118+
messagePlansPage(`${baseUrl}/message-plans`)
119+
]
120+
116121
const landingPage = [{ url: startUrl, name: 'landing-page' }];
117122

118123
const errors = [
@@ -149,6 +154,7 @@ const allJourneys = {
149154
letters,
150155
userEmails,
151156
errors,
157+
messagePlans,
152158
};
153159

154160
const selectedJourney = process.env.JOURNEY && allJourneys[process.env.JOURNEY]

tests/accessibility/actions/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
...require('./email-template-submitted.actions'),
99
...require('./letter-template-submitted.actions'),
1010
...require('./message-templates.actions'),
11+
...require('./message-plans.actions'),
1112
...require('./nhs-app-template-submitted.actions'),
1213
...require('./preview-email-template.actions'),
1314
...require('./preview-letter-template.actions'),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { signInPageActions } = require('./sign-in-page.actions');
2+
3+
const pageActions = [
4+
...signInPageActions,
5+
'wait for element #create-message-plan-button to be visible',
6+
'click element #message-plans-list-draft',
7+
'click element #message-plans-list-production',
8+
];
9+
10+
const messagePlansPage = (url) => ({
11+
name: 'message-plans',
12+
url,
13+
actions: pageActions,
14+
});
15+
16+
module.exports = {
17+
pageActions,
18+
messagePlansPage,
19+
};

tests/accessibility/pa11y-setup.ts

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ const generateLetterTemplateData = (
6464
};
6565
};
6666

67+
const generateRoutingConfig = ({
68+
clientId,
69+
now,
70+
}: {
71+
clientId: string;
72+
now: string;
73+
}) => ({
74+
owner: `CLIENT#${clientId}`,
75+
id: randomUUID(),
76+
campaignId: 'campaignId',
77+
cascade: [
78+
{
79+
cascadeGroups: ['standard'],
80+
channel: 'EMAIL',
81+
channelType: 'primary',
82+
defaultTemplateId: 'email_id',
83+
},
84+
],
85+
cascadeGroupOverrides: [{ name: 'standard' }],
86+
clientId,
87+
createdAt: now,
88+
createdBy: 'Accessibility tests',
89+
name: 'Accessibility Test',
90+
status: 'DRAFT',
91+
updatedAt: now,
92+
updatedBy: 'Accessibility tests',
93+
});
94+
6795
const setup = async () => {
6896
const backendConfig = BackendConfigHelper.fromTerraformOutputsFile(
6997
path.join(__dirname, '..', '..', 'sandbox_tf_outputs.json')
@@ -148,25 +176,40 @@ const setup = async () => {
148176
),
149177
];
150178

151-
await Promise.all(
152-
templates.map((template) =>
179+
const routingConfigs = [
180+
generateRoutingConfig({ clientId, now: new Date().toISOString() }),
181+
];
182+
183+
await Promise.all([
184+
...templates.map((template) => {
153185
ddbDocClient.send(
154186
new PutCommand({
155187
TableName: backendConfig.templatesTableName,
156188
Item: template,
157189
})
190+
);
191+
}),
192+
...routingConfigs.map((rc) =>
193+
ddbDocClient.send(
194+
new PutCommand({
195+
TableName: backendConfig.routingConfigTableName,
196+
Item: rc,
197+
})
158198
)
159-
)
160-
);
199+
),
200+
]);
161201

162202
const templateIds = Object.fromEntries(
163203
templates.map((t) => [t.templateStatus, t.id])
164204
);
165205

206+
const routingConfigIds = routingConfigs.map((r) => r.id);
207+
166208
const fixtureData = {
167209
email: testEmail,
168210
password: testPassword,
169211
templateIds,
212+
routingConfigIds,
170213
userId,
171214
clientId,
172215
clientName,

tests/accessibility/pa11y-teardown.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DeleteCommand, DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
55
import { BackendConfigHelper } from 'nhs-notify-web-template-management-util-backend-config';
66
import path from 'node:path';
77

8-
const { email, templateIds, clientId } = JSON.parse(
8+
const { email, templateIds, clientId, routingConfigIds } = JSON.parse(
99
readFileSync('./pa11y-fixtures.json', 'utf8')
1010
);
1111

@@ -18,8 +18,8 @@ const teardown = async () => {
1818
path.join(__dirname, '..', '..', 'sandbox_tf_outputs.json')
1919
);
2020

21-
await Promise.all(
22-
Object.values(templateIds).map((id) =>
21+
await Promise.all([
22+
...Object.values(templateIds).map((id) =>
2323
ddbDocClient.send(
2424
new DeleteCommand({
2525
TableName: backendConfig.templatesTableName,
@@ -29,8 +29,19 @@ const teardown = async () => {
2929
},
3030
})
3131
)
32-
)
33-
);
32+
),
33+
...(routingConfigIds as string[]).map((id) =>
34+
ddbDocClient.send(
35+
new DeleteCommand({
36+
TableName: backendConfig.routingConfigTableName,
37+
Key: {
38+
owner: `CLIENT#${clientId}`,
39+
id,
40+
},
41+
})
42+
)
43+
),
44+
]);
3445

3546
await new TestUserClient(
3647
backendConfig.userPoolId,

0 commit comments

Comments
 (0)