Skip to content

Commit 297c855

Browse files
committed
CCM-10893 Update tests
1 parent 16ddf58 commit 297c855

File tree

34 files changed

+369
-114
lines changed

34 files changed

+369
-114
lines changed

frontend/src/__tests__/components/molecules/Header.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('Header component', () => {
2121
it('should contain an authentication link', () => {
2222
render(<NHSNotifyHeader />);
2323

24-
expect(screen.getByTestId('auth-link')).toBeInTheDocument();
24+
expect(screen.getByTestId('sign-in-link')).toBeInTheDocument();
2525
});
2626

2727
it('should render correctly', () => {

frontend/src/__tests__/components/molecules/HeaderWithAccount.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('NhsNotifyHeaderWithAccount', () => {
5656
it(`renders the authentication link as 'sign in'`, async () => {
5757
render(<NhsNotifyHeaderWithAccount />);
5858

59-
expect(await screen.findByTestId('auth-link')).toHaveTextContent(
59+
expect(await screen.findByTestId('sign-in-link')).toHaveTextContent(
6060
'Sign in'
6161
);
6262
});
@@ -116,7 +116,7 @@ describe('NhsNotifyHeaderWithAccount', () => {
116116
it(`renders auth link as 'Sign out'`, async () => {
117117
render(<NhsNotifyHeaderWithAccount />);
118118

119-
expect(await screen.findByTestId('auth-link')).toHaveTextContent(
119+
expect(await screen.findByTestId('sign-out-link')).toHaveTextContent(
120120
'Sign out'
121121
);
122122
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`AuthLink renders Sign in link when authStatus is configuring 1`] = `
44
<DocumentFragment>
55
<a
66
class="auth-link"
7-
data-testid="auth-link"
7+
data-testid="sign-in-link"
88
href="/auth?redirect=%2Ftemplates%2Fcreate-and-submit-templates"
99
id="sign-in-link"
1010
>
@@ -17,7 +17,7 @@ exports[`AuthLink renders Sign in link when authStatus is unauthenticated 1`] =
1717
<DocumentFragment>
1818
<a
1919
class="auth-link"
20-
data-testid="auth-link"
20+
data-testid="sign-in-link"
2121
href="/auth?redirect=%2Ftemplates%2Fcreate-and-submit-templates"
2222
id="sign-in-link"
2323
>
@@ -30,7 +30,7 @@ exports[`AuthLink renders Sign out link when authStatus is authenticated 1`] = `
3030
<DocumentFragment>
3131
<a
3232
class="auth-link"
33-
data-testid="auth-link"
33+
data-testid="sign-out-link"
3434
href="/auth/signout"
3535
id="sign-out-link"
3636
>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ exports[`Header component should render correctly 1`] = `
5454
>
5555
<a
5656
class="auth-link"
57-
data-testid="auth-link"
57+
data-testid="sign-in-link"
5858
href="/auth?redirect=%2Ftemplates%2Fcreate-and-submit-templates"
5959
id="sign-in-link"
6060
>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ exports[`NhsNotifyHeaderWithAccount when authenticated matches snapshot (authent
7979
>
8080
<a
8181
class="auth-link nhsuk-header__account-link"
82-
data-testid="auth-link"
82+
data-testid="sign-out-link"
8383
href="/auth/signout"
8484
id="sign-out-link"
8585
>
@@ -173,7 +173,7 @@ exports[`NhsNotifyHeaderWithAccount when unauthenticated matches snapshot (unaut
173173
>
174174
<a
175175
class="auth-link nhsuk-header__account-link"
176-
data-testid="auth-link"
176+
data-testid="sign-in-link"
177177
href="/auth?redirect=%2Ftemplates%2Fcreate-and-submit-templates"
178178
id="sign-in-link"
179179
>

frontend/src/components/molecules/AuthLink/AuthLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const AuthLink = ({ className }: { className?: string }) => {
2121
<a
2222
id={id}
2323
className={classNames(styles['auth-link'], className)}
24-
data-testid='auth-link'
24+
data-testid={id}
2525
href={linkContent.href}
2626
>
2727
{linkContent.text}

tests/test-team/helpers/client/client-helper.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
type ClientConfiguration = {
88
features: {
99
proofing: boolean;
10+
routing: boolean;
1011
};
1112
campaignId?: string;
1213
};
@@ -20,21 +21,23 @@ type TestClients = Record<
2021

2122
export const testClients = {
2223
/**
23-
* Client1 has proofing enabled
24+
* Client1 has proofing and routing enabled
2425
*/
2526
Client1: {
2627
campaignId: 'Campaign1',
2728
features: {
2829
proofing: true,
30+
routing: true,
2931
},
3032
},
3133
/**
32-
* Client2 has proofing disabled
34+
* Client2 has proofing and routing disabled
3335
*/
3436
Client2: {
3537
campaignId: 'Campaign2',
3638
features: {
3739
proofing: false,
40+
routing: false,
3841
},
3942
},
4043
/**
@@ -48,6 +51,7 @@ export const testClients = {
4851
campaignId: undefined,
4952
features: {
5053
proofing: false,
54+
routing: false,
5155
},
5256
},
5357
} satisfies TestClients as TestClients & { NONE: undefined };
@@ -58,7 +62,7 @@ export class ClientConfigurationHelper {
5862
constructor(
5963
private readonly clientSSMKeyPrefix: string,
6064
private readonly runId: string
61-
) {}
65+
) { }
6266

6367
async setup() {
6468
return Promise.all(

tests/test-team/pages/template-mgmt-base-page.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ export abstract class TemplateMgmtBasePage {
77

88
static readonly pageUrlSegment: string;
99

10-
readonly notifyBannerLink: Locator;
10+
readonly header: Locator;
11+
12+
readonly headerLogoLink: Locator;
13+
14+
readonly headerAccountDisplayName: Locator;
15+
16+
readonly headerAccountClientName: Locator;
1117

1218
readonly signInLink: Locator;
1319

1420
readonly signOutLink: Locator;
1521

22+
readonly headerNavigationLinks: Locator;
23+
1624
readonly goBackLink: Locator;
1725

18-
readonly pageHeader: Locator;
26+
readonly pageHeading: Locator;
1927

2028
readonly errorSummary: Locator;
2129

@@ -28,23 +36,22 @@ export abstract class TemplateMgmtBasePage {
2836
constructor(page: Page) {
2937
this.page = page;
3038

31-
this.notifyBannerLink = page.locator(
32-
'[class="nhsuk-header__link nhsuk-header__link--service"]'
33-
);
39+
this.header = page.getByTestId('page-header');
40+
this.headerLogoLink = page.getByTestId('header-logo-service-link');
41+
42+
this.headerAccountDisplayName = page.getByTestId('account-display-name');
43+
this.headerAccountClientName = page.getByTestId('account-client-name');
3444

35-
this.signInLink = page
36-
.locator('[data-testid="auth-link"]')
37-
.and(page.getByText('Sign in'));
45+
this.signInLink = page.getByTestId('sign-in-link');
46+
this.signOutLink = page.getByTestId('sign-out-link');
3847

39-
this.signOutLink = page
40-
.locator('[data-testid="auth-link"]')
41-
.and(page.getByText('Sign out'));
48+
this.headerNavigationLinks = page.getByTestId('navigation-links');
4249

4350
this.goBackLink = page
4451
.locator('.nhsuk-back-link__link')
4552
.and(page.getByText('Go back'));
4653

47-
this.pageHeader = page.getByRole('heading', { level: 1 });
54+
this.pageHeading = page.getByRole('heading', { level: 1 });
4855

4956
this.errorSummary = page.getByRole('alert', { name: 'There is a problem' });
5057

@@ -66,8 +73,8 @@ export abstract class TemplateMgmtBasePage {
6673
await this.page.goto(url);
6774
}
6875

69-
async clickNotifyBannerLink() {
70-
await this.notifyBannerLink.click();
76+
async clickHeaderLogoLink() {
77+
await this.headerLogoLink.click();
7178
}
7279

7380
async clickSignInLink() {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
assertFooterLinks,
66
assertGoBackLink,
77
assertSignOutLink,
8-
assertNotifyBannerLink,
8+
assertHeaderLogoLink,
99
assertSkipToMainContent,
1010
} from '../template-mgmt-common.steps';
1111
import {
@@ -36,7 +36,7 @@ test.describe('Create Email message template Page', () => {
3636

3737
await expect(page).toHaveURL(`${baseURL}/templates/create-email-template`);
3838

39-
await expect(createEmailTemplatePage.pageHeader).toHaveText(
39+
await expect(createEmailTemplatePage.pageHeading).toHaveText(
4040
'Create email template'
4141
);
4242
});
@@ -49,7 +49,7 @@ test.describe('Create Email message template Page', () => {
4949
};
5050

5151
await assertSkipToMainContent(props);
52-
await assertNotifyBannerLink(props);
52+
await assertHeaderLogoLink(props);
5353
await assertSignOutLink(props);
5454
await assertFooterLinks(props);
5555
await assertGoBackLink({

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
assertFooterLinks,
77
assertSignOutLink,
88
assertGoBackLinkNotPresent,
9-
assertNotifyBannerLink,
9+
assertHeaderLogoLink,
1010
assertSkipToMainContent,
1111
} from '../template-mgmt-common.steps';
1212
import {
@@ -72,7 +72,7 @@ test.describe('Edit Email message template Page', () => {
7272
`${baseURL}/templates/edit-email-template/${templates.valid.id}`
7373
);
7474

75-
await expect(editEmailTemplatePage.pageHeader).toHaveText(
75+
await expect(editEmailTemplatePage.pageHeading).toHaveText(
7676
'Edit email template'
7777
);
7878
});
@@ -86,7 +86,7 @@ test.describe('Edit Email message template Page', () => {
8686
};
8787

8888
await assertSkipToMainContent(props);
89-
await assertNotifyBannerLink(props);
89+
await assertHeaderLogoLink(props);
9090
await assertSignOutLink(props);
9191
await assertFooterLinks(props);
9292
await assertGoBackLinkNotPresent(props);

0 commit comments

Comments
 (0)