Skip to content

Commit 71320e1

Browse files
committed
CCCM-11494 component test
1 parent 1423493 commit 71320e1

File tree

7 files changed

+275
-42
lines changed

7 files changed

+275
-42
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ function MessagePlanChannelTemplateBase({
4242
const hasTemplates = templateCount > 0;
4343

4444
return (
45-
<div className={styles['channel-template-outer']}>
45+
<div
46+
className={styles['channel-template-outer']}
47+
data-testid={`channel-template-${testIdSuffix}`}
48+
>
4649
<div className={styles['channel-template-inner']}>
4750
<h3 className='nhsuk-heading-s'>{`${channelTemplateType}${required ? '' : ' (optional)'}`}</h3>
4851

frontend/src/content/content.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { ContentBlock } from '@molecules/ContentRenderer/ContentRenderer';
22
import { getBasePath } from '@utils/get-base-path';
3-
import { TemplateStatus, TemplateType } from 'nhs-notify-backend-client';
3+
import {
4+
LetterType,
5+
TemplateStatus,
6+
TemplateType,
7+
} from 'nhs-notify-backend-client';
48

59
const generatePageTitle = (title: string): string => {
610
return `${title} - NHS Notify`;

tests/test-team/helpers/factories/routing-config-factory.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ export const RoutingConfigFactory = {
3131
defaultTemplateId: null,
3232
},
3333
],
34-
cascadeGroupOverrides: routingConfig.cascadeGroupOverrides ?? [
35-
{ name: 'standard' },
36-
],
34+
cascadeGroupOverrides: routingConfig.cascadeGroupOverrides ?? [],
3735
name: routingConfig.name ?? 'Test config',
3836
};
3937

tests/test-team/helpers/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const expectedChannelLabels: Record<Channel, string> = {
2424
NHSAPP: 'NHS App',
2525
SMS: 'Text message (SMS)',
2626
EMAIL: 'Email',
27-
LETTER: 'Letter',
27+
LETTER: 'Standard English letter',
2828
};
2929

3030
export const allChannels: Channel[] = ['NHSAPP', 'EMAIL', 'SMS', 'LETTER'];

tests/test-team/pages/routing/choose-templates-page.ts

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export class RoutingChooseTemplatesPage extends TemplateMgmtBasePageDynamic {
1818

1919
public readonly saveAndCloseButton: Locator;
2020

21+
public readonly conditionalLetterTemplates: Locator;
22+
2123
constructor(page: Page) {
2224
super(page);
2325
this.errorSummary = page.locator('.nhsuk-error-summary');
@@ -29,29 +31,29 @@ export class RoutingChooseTemplatesPage extends TemplateMgmtBasePageDynamic {
2931
this.channelBlocks = page.locator('[data-testid^="message-plan-block-"]');
3032
this.moveToProductionButton = page.getByTestId('move-to-production-cta');
3133
this.saveAndCloseButton = page.getByTestId('save-and-close-cta');
34+
this.conditionalLetterTemplates = page.getByTestId(
35+
'message-plan-conditional-templates'
36+
);
3237
}
3338

34-
public messagePlanChannel(channel: string) {
39+
public messagePlanItem(identifier: string) {
3540
return {
36-
block: this.page.getByTestId(`message-plan-block-${channel}`),
37-
number: this.page
38-
.getByTestId(`message-plan-block-${channel}`)
39-
.locator('[class*=message-plan-block-number]'),
41+
templateItem: this.page.getByTestId(`channel-template-${identifier}`),
4042
heading: this.page
41-
.getByTestId(`message-plan-block-${channel}`)
43+
.getByTestId(`channel-template-${identifier}`)
4244
.getByRole('heading', { level: 3 }),
43-
templateName: this.page.getByTestId(`template-name-${channel}`),
44-
fallbackConditions: this.page.getByTestId(
45-
`message-plan-fallback-conditions-${channel}`
46-
),
45+
templateName: this.page
46+
.getByTestId(`template-name-${identifier}`)
47+
.first(),
48+
templateNames: this.page.getByTestId(`template-name-${identifier}`),
4749
changeTemplateLink: this.page.getByTestId(
48-
`change-template-link-${channel}`
50+
`change-template-link-${identifier}`
4951
),
5052
chooseTemplateLink: this.page.getByTestId(
51-
`choose-template-link-${channel}`
53+
`choose-template-link-${identifier}`
5254
),
5355
removeTemplateLink: this.page.getByTestId(
54-
`remove-template-link-${channel}`
56+
`remove-template-link-${identifier}`
5557
),
5658
async clickChooseTemplateLink() {
5759
await this.chooseTemplateLink.click();
@@ -65,6 +67,19 @@ export class RoutingChooseTemplatesPage extends TemplateMgmtBasePageDynamic {
6567
};
6668
}
6769

70+
public messagePlanChannel(channel: string) {
71+
return {
72+
...this.messagePlanItem(channel),
73+
block: this.page.getByTestId(`message-plan-block-${channel}`),
74+
number: this.page
75+
.getByTestId(`message-plan-block-${channel}`)
76+
.locator('[class*=message-plan-block-number]'),
77+
fallbackConditions: this.page.getByTestId(
78+
`message-plan-fallback-conditions-${channel}`
79+
),
80+
};
81+
}
82+
6883
public readonly nhsApp = this.messagePlanChannel('NHSAPP');
6984

7085
public readonly sms = this.messagePlanChannel('SMS');
@@ -73,6 +88,23 @@ export class RoutingChooseTemplatesPage extends TemplateMgmtBasePageDynamic {
7388

7489
public readonly letter = this.messagePlanChannel('LETTER');
7590

91+
public alternativeLetterFormats() {
92+
const conditionalTemplates = this.page.getByTestId(
93+
'message-plan-conditional-templates'
94+
);
95+
return {
96+
conditionalTemplates,
97+
fallbackConditions: conditionalTemplates.getByTestId(
98+
'message-plan-fallback-conditions-LETTER'
99+
),
100+
listItems: conditionalTemplates.locator(
101+
'[class*=message-plan-conditional-templates__list-item]'
102+
),
103+
largePrint: this.messagePlanItem('x1'),
104+
otherLanguages: this.messagePlanItem('foreign-language'),
105+
};
106+
}
107+
76108
async clickMoveToProduction() {
77109
await this.moveToProductionButton.click();
78110
}

tests/test-team/template-mgmt-api-tests/create-routing-configuration.api.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ test.describe('POST /v1/routing-configuration', () => {
7777
}) => {
7878
const payload = RoutingConfigFactory.create(user1, {
7979
cascadeGroupOverrides: [
80-
{ name: 'standard' },
8180
{ name: 'translations', language: ['ar'] },
8281
{ name: 'accessible', accessibleFormat: ['x0'] },
8382
],

0 commit comments

Comments
 (0)