Skip to content

Commit 3f81dea

Browse files
committed
CCM-11438 Update tests
1 parent 9811ffa commit 3f81dea

10 files changed

+335
-37
lines changed

tests/test-team/pages/email/template-mgmt-create-email-page.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export class TemplateMgmtCreateEmailPage extends TemplateMgmtBasePageNonDynamic
1313

1414
public readonly errorSummary: Locator;
1515

16-
public readonly personalisationFields: Locator;
16+
public readonly customPersonalisationFields: Locator;
17+
18+
public readonly pdsPersonalisationFields: Locator;
1719

1820
public readonly namingYourTemplate: Locator;
1921

@@ -29,8 +31,11 @@ export class TemplateMgmtCreateEmailPage extends TemplateMgmtBasePageNonDynamic
2931
this.subjectLineInput = page.locator('[id="emailTemplateSubjectLine"]');
3032
this.messageTextArea = page.locator('[id="emailTemplateMessage"]');
3133
this.errorSummary = page.locator('[class="nhsuk-error-summary"]');
32-
this.personalisationFields = page.locator(
33-
'[data-testid="personalisation-details"]'
34+
this.customPersonalisationFields = page.locator(
35+
'[data-testid="custom-personalisation-details"]'
36+
);
37+
this.pdsPersonalisationFields = page.locator(
38+
'[data-testid="pds-personalisation-details"]'
3439
);
3540
this.namingYourTemplate = page.locator(
3641
'[data-testid="how-to-name-your-template"]'

tests/test-team/pages/email/template-mgmt-edit-email-page.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export class TemplateMgmtEditEmailPage extends TemplateMgmtBasePageDynamic {
1313

1414
public readonly errorSummary: Locator;
1515

16-
public readonly personalisationFields: Locator;
16+
public readonly customPersonalisationFields: Locator;
17+
18+
public readonly pdsPersonalisationFields: Locator;
1719

1820
public readonly namingYourTemplate: Locator;
1921

@@ -27,8 +29,11 @@ export class TemplateMgmtEditEmailPage extends TemplateMgmtBasePageDynamic {
2729
this.subjectLineInput = page.locator('[id="emailTemplateSubjectLine"]');
2830
this.messageTextArea = page.locator('[id="emailTemplateMessage"]');
2931
this.errorSummary = page.locator('[class="nhsuk-error-summary"]');
30-
this.personalisationFields = page.locator(
31-
'[data-testid="personalisation-details"]'
32+
this.customPersonalisationFields = page.locator(
33+
'[data-testid="custom-personalisation-details"]'
34+
);
35+
this.pdsPersonalisationFields = page.locator(
36+
'[data-testid="pds-personalisation-details"]'
3237
);
3338
this.namingYourTemplate = page.locator(
3439
'[data-testid="how-to-name-your-template"]'

tests/test-team/pages/sms/template-mgmt-create-sms-page.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export class TemplateMgmtCreateSmsPage extends TemplateMgmtBasePageNonDynamic {
1111

1212
public readonly errorSummary: Locator;
1313

14-
public readonly personalisationFields: Locator;
14+
public readonly customPersonalisationFields: Locator;
15+
16+
public readonly pdsPersonalisationFields: Locator;
1517

1618
public readonly namingYourTemplate: Locator;
1719

@@ -30,8 +32,11 @@ export class TemplateMgmtCreateSmsPage extends TemplateMgmtBasePageNonDynamic {
3032
this.nameInput = page.locator('[id="smsTemplateName"]');
3133
this.messageTextArea = page.locator('[id="smsTemplateMessage"]');
3234
this.errorSummary = page.locator('[class="nhsuk-error-summary"]');
33-
this.personalisationFields = page.locator(
34-
'[data-testid="personalisation-details"]'
35+
this.customPersonalisationFields = page.locator(
36+
'[data-testid="custom-personalisation-details"]'
37+
);
38+
this.pdsPersonalisationFields = page.locator(
39+
'[data-testid="pds-personalisation-details"]'
3540
);
3641
this.namingYourTemplate = page.locator(
3742
'[data-testid="how-to-name-your-template"]'

tests/test-team/pages/sms/template-mgmt-edit-sms-page.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export class TemplateMgmtEditSmsPage extends TemplateMgmtBasePageDynamic {
1111

1212
public readonly errorSummary: Locator;
1313

14-
public readonly personalisationFields: Locator;
14+
public readonly customPersonalisationFields: Locator;
15+
16+
public readonly pdsPersonalisationFields: Locator;
1517

1618
public readonly namingYourTemplate: Locator;
1719

@@ -28,8 +30,11 @@ export class TemplateMgmtEditSmsPage extends TemplateMgmtBasePageDynamic {
2830
this.nameInput = page.locator('[id="smsTemplateName"]');
2931
this.messageTextArea = page.locator('[id="smsTemplateMessage"]');
3032
this.errorSummary = page.locator('[class="nhsuk-error-summary"]');
31-
this.personalisationFields = page.locator(
32-
'[data-testid="personalisation-details"]'
33+
this.customPersonalisationFields = page.locator(
34+
'[data-testid="custom-personalisation-details"]'
35+
);
36+
this.pdsPersonalisationFields = page.locator(
37+
'[data-testid="pds-personalisation-details"]'
3338
);
3439
this.namingYourTemplate = page.locator(
3540
'[data-testid="how-to-name-your-template"]'

tests/test-team/template-mgmt-component-tests/email/template-mgmt-create-email-page.component.spec.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ test.describe('Create Email message template Page', () => {
6565

6666
await createEmailTemplatePage.loadPage();
6767

68-
await createEmailTemplatePage.personalisationFields.click();
68+
await createEmailTemplatePage.customPersonalisationFields.click();
69+
await expect(
70+
createEmailTemplatePage.customPersonalisationFields
71+
).toHaveAttribute('open');
6972

73+
await createEmailTemplatePage.pdsPersonalisationFields.click();
7074
await expect(
71-
createEmailTemplatePage.personalisationFields
75+
createEmailTemplatePage.pdsPersonalisationFields
7276
).toHaveAttribute('open');
7377
});
7478

@@ -120,6 +124,47 @@ test.describe('Create Email message template Page', () => {
120124
});
121125
}
122126

127+
const personalisationInfoLinks = [
128+
{
129+
name: 'custom personalisation fields',
130+
url: 'using-nhs-notify/personalisation#custom-personalisation-fields',
131+
},
132+
{
133+
name: 'NHS Notify API',
134+
url: 'using-nhs-notify/api',
135+
},
136+
{
137+
name: 'NHS Notify MESH',
138+
url: 'using-nhs-notify/mesh',
139+
},
140+
];
141+
142+
for (const { name, url } of personalisationInfoLinks) {
143+
test(`custom personalisation info link: ${name}, navigates to correct page in new tab`, async ({
144+
page,
145+
baseURL,
146+
}) => {
147+
const createEmailTemplatePage = new TemplateMgmtCreateEmailPage(page);
148+
149+
await createEmailTemplatePage.loadPage();
150+
151+
const newTabPromise = page.waitForEvent('popup');
152+
153+
const summary = page.getByTestId('custom-personalisation-fields-summary');
154+
155+
await summary.click();
156+
await expect(
157+
page.getByTestId('custom-personalisation-fields-text')
158+
).toBeVisible();
159+
160+
await page.getByRole('link', { name }).click();
161+
162+
const newTab = await newTabPromise;
163+
164+
await expect(newTab).toHaveURL(`${baseURL}/${url}`);
165+
});
166+
}
167+
123168
test('when user clicks "Naming your templates" tool tips, then tool tips are displayed', async ({
124169
page,
125170
}) => {

tests/test-team/template-mgmt-component-tests/email/template-mgmt-edit-email-page.component.spec.ts

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,15 @@ test.describe('Edit Email message template Page', () => {
117117

118118
await editEmailTemplatePage.loadPage(templates.goBackAndReturn.id);
119119

120-
await editEmailTemplatePage.personalisationFields.click();
120+
await editEmailTemplatePage.customPersonalisationFields.click();
121+
await expect(
122+
editEmailTemplatePage.customPersonalisationFields
123+
).toHaveAttribute('open');
121124

122-
await expect(editEmailTemplatePage.personalisationFields).toHaveAttribute(
123-
'open'
124-
);
125+
await editEmailTemplatePage.pdsPersonalisationFields.click();
126+
await expect(
127+
editEmailTemplatePage.pdsPersonalisationFields
128+
).toHaveAttribute('open');
125129
});
126130

127131
test('when user clicks "Message formatting" tool tips, then tool tips are displayed', async ({
@@ -167,6 +171,49 @@ test.describe('Edit Email message template Page', () => {
167171
});
168172
}
169173

174+
const personalisationInfoLinks = [
175+
{
176+
name: 'custom personalisation fields',
177+
url: 'using-nhs-notify/personalisation#custom-personalisation-fields',
178+
},
179+
{
180+
name: 'NHS Notify API',
181+
url: 'using-nhs-notify/api',
182+
},
183+
{
184+
name: 'NHS Notify MESH',
185+
url: 'using-nhs-notify/mesh',
186+
},
187+
];
188+
189+
for (const { name, url } of personalisationInfoLinks) {
190+
test(`custom personalisation info link: ${name}, navigates to correct page in new tab`, async ({
191+
page,
192+
baseURL,
193+
}) => {
194+
const editEmailTemplatePage = new TemplateMgmtEditEmailPage(page);
195+
196+
await editEmailTemplatePage.loadPage(templates.goBackAndReturn.id);
197+
198+
const newTabPromise = page.waitForEvent('popup');
199+
200+
const summary = page.getByTestId(
201+
'custom-personalisation-fields-summary'
202+
);
203+
204+
await summary.click();
205+
await expect(
206+
page.getByTestId('custom-personalisation-fields-text')
207+
).toBeVisible();
208+
209+
await page.getByRole('link', { name }).click();
210+
211+
const newTab = await newTabPromise;
212+
213+
await expect(newTab).toHaveURL(`${baseURL}/${url}`);
214+
});
215+
}
216+
170217
test('when user clicks "Naming your templates" tool tips, then tool tips are displayed', async ({
171218
page,
172219
}) => {

tests/test-team/template-mgmt-component-tests/nhs-app/template-mgmt-create-nhs-app-template-page.component.spec.ts

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,13 @@ test.describe('Create NHS App Template Page', () => {
157157
});
158158

159159
const detailsSections = [
160-
'[data-testid="personalisation-details"]',
160+
'[data-testid="pds-personalisation-details"]',
161+
'[data-testid="custom-personalisation-details"]',
161162
'[data-testid="line-breaks-and-paragraphs-details"]',
162163
'[data-testid="headings-details"]',
163164
'[data-testid="bold-text-details"]',
165+
'[data-testid="bullet-points-details"]',
166+
'[data-testid="numbered-lists-details"]',
164167
'[data-testid="links-and-urls-details"]',
165168
'[data-testid="how-to-name-your-template"]',
166169
];
@@ -173,16 +176,21 @@ test.describe('Create NHS App Template Page', () => {
173176
const createTemplatePage = new TemplateMgmtCreateNhsAppPage(page);
174177
await createTemplatePage.loadPage();
175178

176-
await page.locator(`${section} > summary`).click();
177-
await expect(page.locator(section)).toHaveAttribute('open');
178-
await expect(page.locator(`${section} > div`)).toBeVisible();
179-
180-
await page.locator(`${section} > summary`).click();
181-
await expect(page.locator(section)).not.toHaveAttribute('open');
182-
await expect(page.locator(`${section} > div`)).toBeHidden();
179+
await page.getByTestId(`${section}-summary`).click();
180+
await expect(page.getByTestId(`${section}-details`)).toHaveAttribute(
181+
'open',
182+
''
183+
);
184+
await expect(page.getByTestId(`${section}-text`)).toBeVisible();
185+
186+
await page.getByTestId(`${section}-summary`).click();
187+
await expect(page.getByTestId(`${section}-details`)).not.toHaveAttribute(
188+
'open'
189+
);
190+
await expect(page.getByTestId(`${section}-text`)).toBeHidden();
183191
});
184192
}
185-
// TODO: Add personalisation links to test
193+
186194
const moreInfoLinks = [
187195
{
188196
name: 'NHS App messages (opens in a new tab)',
@@ -216,4 +224,45 @@ test.describe('Create NHS App Template Page', () => {
216224
await expect(newTab).toHaveURL(`${baseURL}/${url}`);
217225
});
218226
}
227+
228+
const personalisationInfoLinks = [
229+
{
230+
name: 'custom personalisation fields',
231+
url: 'using-nhs-notify/personalisation#custom-personalisation-fields',
232+
},
233+
{
234+
name: 'NHS Notify API',
235+
url: 'using-nhs-notify/api',
236+
},
237+
{
238+
name: 'NHS Notify MESH',
239+
url: 'using-nhs-notify/mesh',
240+
},
241+
];
242+
243+
for (const { name, url } of personalisationInfoLinks) {
244+
test(`custom personalisation info link: ${name}, navigates to correct page in new tab`, async ({
245+
page,
246+
baseURL,
247+
}) => {
248+
const createTemplatePage = new TemplateMgmtCreateNhsAppPage(page);
249+
250+
await createTemplatePage.loadPage();
251+
252+
const newTabPromise = page.waitForEvent('popup');
253+
254+
const summary = page.getByTestId('custom-personalisation-fields-summary');
255+
256+
await summary.click();
257+
await expect(
258+
page.getByTestId('custom-personalisation-fields-text')
259+
).toBeVisible();
260+
261+
await page.getByRole('link', { name }).click();
262+
263+
const newTab = await newTabPromise;
264+
265+
await expect(newTab).toHaveURL(`${baseURL}/${url}`);
266+
});
267+
}
219268
});

tests/test-team/template-mgmt-component-tests/nhs-app/template-mgmt-edit-nhs-app-template-page.component.spec.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,13 @@ test.describe('Edit NHS App Template Page', () => {
212212
});
213213

214214
const detailsSections = [
215-
'[data-testid="personalisation-details"]',
215+
'[data-testid="pds-personalisation-details"]',
216+
'[data-testid="custom-personalisation-details"]',
216217
'[data-testid="line-breaks-and-paragraphs-details"]',
217218
'[data-testid="headings-details"]',
218219
'[data-testid="bold-text-details"]',
220+
'[data-testid="bullet-points-details"]',
221+
'[data-testid="numbered-lists-details"]',
219222
'[data-testid="links-and-urls-details"]',
220223
'[data-testid="how-to-name-your-template"]',
221224
];
@@ -241,7 +244,7 @@ test.describe('Edit NHS App Template Page', () => {
241244
await expect(page.locator(`${section} > div`)).toBeHidden();
242245
});
243246
}
244-
// TODO: Add personalisation links
247+
245248
const moreInfoLinks = [
246249
{
247250
name: 'NHS App messages (opens in a new tab)',
@@ -271,6 +274,46 @@ test.describe('Edit NHS App Template Page', () => {
271274
});
272275
}
273276

277+
const personalisationInfoLinks = [
278+
{
279+
name: 'custom personalisation fields',
280+
url: 'using-nhs-notify/personalisation#custom-personalisation-fields',
281+
},
282+
{
283+
name: 'NHS Notify API',
284+
url: 'using-nhs-notify/api',
285+
},
286+
{
287+
name: 'NHS Notify MESH',
288+
url: 'using-nhs-notify/mesh',
289+
},
290+
];
291+
292+
for (const { name, url } of personalisationInfoLinks) {
293+
test(`custom personalisation info link: ${name}, navigates to correct page in new tab`, async ({
294+
page,
295+
baseURL,
296+
}) => {
297+
const editTemplatePage = new TemplateMgmtEditNhsAppPage(page);
298+
await editTemplatePage.loadPage(templates.valid.id);
299+
300+
const newTabPromise = page.waitForEvent('popup');
301+
302+
const summary = page.getByTestId('custom-personalisation-fields-summary');
303+
304+
await summary.click();
305+
await expect(
306+
page.getByTestId('custom-personalisation-fields-text')
307+
).toBeVisible();
308+
309+
await page.getByRole('link', { name }).click();
310+
311+
const newTab = await newTabPromise;
312+
313+
await expect(newTab).toHaveURL(`${baseURL}/${url}`);
314+
});
315+
}
316+
274317
test('Invalid template ID test', async ({ page, baseURL }) => {
275318
const editTemplatePage = new TemplateMgmtEditNhsAppPage(page);
276319
const invalidTemplateId = 'invalid-template-id';

0 commit comments

Comments
 (0)