Skip to content

Commit dd644fa

Browse files
committed
CCM-11496: fix page test
1 parent 3224d9f commit dd644fa

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

tests/test-team/pages/template-mgmt-message-templates-page.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,16 @@ export class TemplateMgmtMessageTemplatesPage extends TemplateMgmtBasePageNonDyn
1818
async clickCreateTemplateButton() {
1919
await this.createTemplateButton.click();
2020
}
21+
22+
async getRowByTemplateId(id: string) {
23+
return this.page.locator(`tbody tr:has(td:nth-child(2):has-text("${id}"))`);
24+
}
25+
26+
async getTemplateStatus(templateId: string) {
27+
const row = await this.getRowByTemplateId(templateId);
28+
29+
const statusCell = row.locator('td:nth-child(4) .nhsuk-tag');
30+
31+
return statusCell.textContent();
32+
}
2133
}

tests/test-team/template-mgmt-routing-component-tests/move-to-production-page.routing-component.spec.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { randomUUID } from 'node:crypto';
12
import { test, expect } from '@playwright/test';
23
import {
34
createAuthHelper,
@@ -6,6 +7,7 @@ import {
67
} from 'helpers/auth/cognito-auth-helper';
78
import { RoutingConfigStorageHelper } from 'helpers/db/routing-config-storage-helper';
89
import { RoutingConfigFactory } from 'helpers/factories/routing-config-factory';
10+
import { TemplateFactory } from 'helpers/factories/template-factory';
911
import {
1012
assertFooterLinks,
1113
assertHeaderLogoLink,
@@ -14,8 +16,11 @@ import {
1416
} from 'helpers/template-mgmt-common.steps';
1517
import { RoutingMessagePlansPage } from 'pages/routing/message-plans-page';
1618
import { RoutingMoveToProductionPage } from 'pages/routing/move-to-production-page';
19+
import { TemplateStorageHelper } from 'helpers/db/template-storage-helper';
20+
import { TemplateMgmtMessageTemplatesPage } from 'pages/template-mgmt-message-templates-page';
1721

18-
const storageHelper = new RoutingConfigStorageHelper();
22+
const routingConfigStorage = new RoutingConfigStorageHelper();
23+
const templateStorage = new TemplateStorageHelper();
1924

2025
let user: TestUser;
2126

@@ -25,15 +30,15 @@ test.beforeAll(async () => {
2530
});
2631

2732
test.afterAll(async () => {
28-
await storageHelper.deleteSeeded();
33+
await routingConfigStorage.deleteSeeded();
2934
});
3035

3136
test.describe('Create Message Plan Page', () => {
3237
test('common page tests', async ({ page, baseURL }) => {
3338
const routingConfig =
3439
RoutingConfigFactory.create(user).withTemplates('NHSAPP');
3540

36-
await storageHelper.seed([routingConfig.dbEntry]);
41+
await routingConfigStorage.seed([routingConfig.dbEntry]);
3742

3843
const props = {
3944
page: new RoutingMoveToProductionPage(page),
@@ -51,10 +56,15 @@ test.describe('Create Message Plan Page', () => {
5156
baseURL,
5257
page,
5358
}) => {
54-
const routingConfig =
55-
RoutingConfigFactory.create(user).withTemplates('NHSAPP');
59+
const template = TemplateFactory.createNhsAppTemplate(randomUUID(), user);
60+
61+
await templateStorage.seedTemplateData([template]);
62+
63+
const routingConfig = RoutingConfigFactory.createWithChannels(user, [
64+
'NHSAPP',
65+
]).addTemplate('NHSAPP', template.id);
5666

57-
await storageHelper.seed([routingConfig.dbEntry]);
67+
await routingConfigStorage.seed([routingConfig.dbEntry]);
5868

5969
const moveToProductionPage = new RoutingMoveToProductionPage(page);
6070

@@ -82,6 +92,14 @@ test.describe('Create Message Plan Page', () => {
8292
expect(productionCellsText).toContainEqual(
8393
expect.stringContaining(routingConfig.dbEntry.id)
8494
);
95+
96+
const templatesPage = new TemplateMgmtMessageTemplatesPage(page);
97+
98+
await templatesPage.loadPage();
99+
100+
expect(await templatesPage.getTemplateStatus(template.id)).toEqual(
101+
'Locked'
102+
);
85103
});
86104

87105
test('links to preview page for the message plan', async ({
@@ -91,7 +109,7 @@ test.describe('Create Message Plan Page', () => {
91109
const routingConfig =
92110
RoutingConfigFactory.create(user).withTemplates('NHSAPP');
93111

94-
await storageHelper.seed([routingConfig.dbEntry]);
112+
await routingConfigStorage.seed([routingConfig.dbEntry]);
95113

96114
const moveToProductionPage = new RoutingMoveToProductionPage(page);
97115

@@ -115,7 +133,7 @@ test.describe('Create Message Plan Page', () => {
115133
const routingConfig =
116134
RoutingConfigFactory.create(user).withTemplates('NHSAPP');
117135

118-
await storageHelper.seed([routingConfig.dbEntry]);
136+
await routingConfigStorage.seed([routingConfig.dbEntry]);
119137

120138
const moveToProductionPage = new RoutingMoveToProductionPage(page);
121139

0 commit comments

Comments
 (0)