Skip to content

Commit cea0012

Browse files
committed
CCM-10424 Add additional users to tests and login function for tests
1 parent d6b6792 commit cea0012

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

frontend/src/utils/server-features.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { logger } from 'nhs-notify-web-template-management-utils/logger';
1111
/*
1212
* Caches at the request context level. Not a global cache.
1313
*/
14-
const fetchClient = cache(async (accessToken: string) =>
14+
export const fetchClient = cache(async (accessToken: string) =>
1515
clientConfigurationApiClient.fetch(accessToken)
1616
);
1717

tests/test-team/helpers/auth/cognito-auth-helper.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ export const testUsers: Record<string, TestUserStaticDetails> = {
7777
userId: 'User6',
7878
clientKey: 'NONE',
7979
},
80+
/**
81+
* User7 has configuration but no campaignId
82+
*/
83+
User7: {
84+
userId: 'User7',
85+
clientKey: 'Client4',
86+
},
8087
};
8188

8289
export type TestUser = TestUserStaticDetails &
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Page } from '@playwright/test';
2+
import { TestUser } from './cognito-auth-helper';
3+
import { TemplateMgmtSignInPage } from '../../pages/templates-mgmt-login-page';
4+
5+
export const loginAsUser = async (user: TestUser, page: Page) => {
6+
const loginPage = new TemplateMgmtSignInPage(page);
7+
8+
await loginPage.loadPage();
9+
10+
await loginPage.cognitoSignIn(user);
11+
};

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type ClientConfiguration = {
1111
campaignId?: string;
1212
};
1313

14-
export type ClientKey = `Client${1 | 2 | 3}` | 'NONE';
14+
export type ClientKey = `Client${1 | 2 | 3 | 4}` | 'NONE';
1515

1616
type TestClients = Record<
1717
Exclude<ClientKey, 'NONE'>,
@@ -41,6 +41,15 @@ export const testClients = {
4141
* Client3 has no configuration
4242
*/
4343
Client3: undefined,
44+
/**
45+
* Client 4 has configuration but no campaignId set
46+
*/
47+
Client4: {
48+
campaignId: undefined,
49+
features: {
50+
proofing: false,
51+
},
52+
},
4453
} satisfies TestClients as TestClients & { NONE: undefined };
4554

4655
export class ClientConfigurationHelper {

0 commit comments

Comments
 (0)