Skip to content

Commit 6a1693a

Browse files
committed
CCM-11492 Hide fallback conditions for final channel and add routing config ID to URLs
1 parent 9b7283e commit 6a1693a

File tree

7 files changed

+460
-670
lines changed

7 files changed

+460
-670
lines changed

frontend/src/__tests__/components/organisms/CreateEditMessagePlan.test.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,15 @@ describe('CreateEditMessagePlan', () => {
9494
...(messagePlanChannelList.children as HTMLCollectionOf<HTMLElement>),
9595
].map((el) => el.dataset.testid);
9696

97-
expect(listItemsTestIds).toEqual([
98-
'message-plan-block-NHSAPP',
99-
'message-plan-fallback-conditions-NHSAPP',
100-
'message-plan-block-EMAIL',
101-
'message-plan-fallback-conditions-EMAIL',
102-
'message-plan-block-SMS',
103-
'message-plan-fallback-conditions-SMS',
104-
]);
97+
const expectedTestIds: string[] = [];
98+
for (const [id, channel] of channels.entries()) {
99+
expectedTestIds.push(`message-plan-block-${channel}`);
100+
if (id < channels.length - 1) {
101+
expectedTestIds.push(`message-plan-fallback-conditions-${channel}`);
102+
}
103+
}
104+
105+
expect(listItemsTestIds).toEqual(expectedTestIds);
105106
});
106107

107108
it('should render CTAs for both saving and moving to production', () => {
@@ -131,7 +132,7 @@ describe('CreateEditMessagePlan', () => {
131132
const link = screen.getByTestId('change-message-plan-name-link');
132133
expect(link.textContent).toBe('Change name');
133134
expect(link.getAttribute('href')).toBe(
134-
'/message-plans/create-message-plan'
135+
`/message-plans/edit-message-plan/${plan.id}`
135136
);
136137
});
137138

frontend/src/__tests__/components/organisms/MessagePlanChannelList.test.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('MessagePlanChannelList', () => {
5757
expect(container.querySelector('ul.channel-list')).toBeInTheDocument();
5858
});
5959

60-
it('should render a block and a fallback section for each cascade item', () => {
60+
it('should render a block and a fallback section for each cascade item, apart from the final channel', () => {
6161
const channels: Channel[] = ['NHSAPP', 'EMAIL', 'SMS'];
6262
const messagePlan = buildRoutingConfig(channels);
6363

@@ -68,14 +68,20 @@ describe('MessagePlanChannelList', () => {
6868
/>
6969
);
7070

71-
for (const channel of channels) {
72-
expect(
73-
screen.getByTestId(`message-plan-block-${channel}`)
74-
).toBeInTheDocument();
75-
expect(
76-
screen.getByTestId(`message-plan-fallback-conditions-${channel}`)
77-
).toBeInTheDocument();
78-
}
71+
expect(screen.getByTestId('message-plan-block-NHSAPP')).toBeInTheDocument();
72+
expect(
73+
screen.getByTestId('message-plan-fallback-conditions-NHSAPP')
74+
).toBeInTheDocument();
75+
76+
expect(screen.getByTestId('message-plan-block-EMAIL')).toBeInTheDocument();
77+
expect(
78+
screen.getByTestId('message-plan-fallback-conditions-EMAIL')
79+
).toBeInTheDocument();
80+
81+
expect(screen.getByTestId('message-plan-block-SMS')).toBeInTheDocument();
82+
expect(
83+
screen.queryByTestId('message-plan-fallback-conditions-SMS')
84+
).toBeNull();
7985
});
8086

8187
it('should render nothing inside the list when cascade is empty', () => {

0 commit comments

Comments
 (0)