Skip to content

Commit 0d76c19

Browse files
committed
CCM-10893 Update test users and clients
1 parent cc10ab5 commit 0d76c19

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import {
1111
import { faker } from '@faker-js/faker';
1212
import { AuthContextFile } from './auth-context-file';
1313
import {
14+
ClientConfiguration,
1415
ClientConfigurationHelper,
16+
testClients,
1517
type ClientKey,
1618
} from '../client/client-helper';
1719

@@ -101,6 +103,13 @@ export const testUsers: Record<string, TestUserStaticDetails> = {
101103
userId: 'User7',
102104
clientKey: 'Client1',
103105
},
106+
/**
107+
* User8 has a client with no client name set
108+
*/
109+
User8: {
110+
userId: 'User8',
111+
clientKey: 'Client6',
112+
},
104113
};
105114

106115
export type TestUser = TestUserStaticDetails &
@@ -239,14 +248,15 @@ export class CognitoAuthHelper {
239248
const tempPassword = CognitoAuthHelper.generatePassword();
240249

241250
const clientId = `${userDetails.clientKey}--${this.runId}`;
242-
const clientName = `NHS Test ${userDetails.clientKey.replaceAll(/([a-z])([A-Z])/g, '$1 $2')}`;
251+
const clientConfig: ClientConfiguration | undefined =
252+
testClients[userDetails.clientKey];
253+
const clientName = clientConfig?.name;
243254

244255
const clientAttributes = [
245256
{ Name: 'custom:sbx_client_id', Value: clientId },
246-
{
247-
Name: 'custom:sbx_client_name',
248-
Value: clientName,
249-
},
257+
...(clientName
258+
? [{ Name: 'custom:sbx_client_name', Value: clientName }]
259+
: []),
250260
];
251261

252262
const {

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ import {
44
SSMClient,
55
} from '@aws-sdk/client-ssm';
66

7-
type ClientConfiguration = {
7+
export type ClientConfiguration = {
8+
campaignId?: string;
89
features: {
910
proofing: boolean;
1011
// TODO: CCM-11148 Make routing flag required
1112
routing?: boolean;
1213
};
13-
campaignId?: string;
14+
name?: string;
1415
};
1516

16-
export type ClientKey = `Client${1 | 2 | 3 | 4 | 5}`;
17+
export type ClientKey = `Client${1 | 2 | 3 | 4 | 5 | 6}`;
1718

1819
type TestClients = Record<ClientKey, ClientConfiguration | undefined>;
1920

@@ -23,6 +24,7 @@ export const testClients = {
2324
*/
2425
Client1: {
2526
campaignId: 'Campaign1',
27+
name: 'NHS Test Client 1',
2628
features: {
2729
proofing: true,
2830
routing: true,
@@ -33,6 +35,7 @@ export const testClients = {
3335
*/
3436
Client2: {
3537
campaignId: 'Campaign2',
38+
name: 'NHS Test Client 2',
3639
features: {
3740
proofing: false,
3841
routing: false,
@@ -47,16 +50,29 @@ export const testClients = {
4750
*/
4851
Client4: {
4952
campaignId: undefined,
53+
name: 'NHS Test Client 4',
5054
features: {
5155
proofing: true,
5256
routing: false,
5357
},
5458
},
5559
/**
56-
* Client5 has proofing enabled
60+
* Client5 is an alternate client to Client1
61+
* with proofing enabled
5762
*/
5863
Client5: {
5964
campaignId: 'Campaign5',
65+
name: 'NHS Test Client 5',
66+
features: {
67+
proofing: true,
68+
routing: false,
69+
},
70+
},
71+
/**
72+
* Client6 has no client name set
73+
*/
74+
Client6: {
75+
campaignId: 'Campaign6',
6076
features: {
6177
proofing: true,
6278
routing: false,
@@ -70,7 +86,7 @@ export class ClientConfigurationHelper {
7086
constructor(
7187
private readonly clientSSMKeyPrefix: string,
7288
private readonly runId: string
73-
) { }
89+
) {}
7490

7591
async setup() {
7692
return Promise.all(

tests/test-team/template-mgmt-component-tests/template-mgmt-header.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test.describe('Header component', () => {
2323
let userWithNoIdentityAttributes: TestUser;
2424
let userWithRoutingEnabled: TestUser;
2525
let userWithRoutingDisabled: TestUser;
26-
let userWithNoClient: TestUser;
26+
let userWithNoClientName: TestUser;
2727

2828
test.beforeAll(async () => {
2929
const authHelper = createAuthHelper();
@@ -41,7 +41,7 @@ test.describe('Header component', () => {
4141
userWithRoutingDisabled = await authHelper.getTestUser(
4242
testUsers.User3.userId
4343
); // Client2: routing disabled
44-
userWithNoClient = await authHelper.getTestUser(testUsers.User6.userId); // Client: NONE
44+
userWithNoClientName = await authHelper.getTestUser(testUsers.User8.userId); // Client5: No client name
4545
});
4646

4747
test.use({ storageState: { cookies: [], origins: [] } });
@@ -153,17 +153,17 @@ test.describe('Header component', () => {
153153
});
154154
});
155155

156-
test('when user belongs to no client, header still renders correctly without client name', async ({
156+
test('when user belongs to a client with no name set, header still renders correctly without client name', async ({
157157
page,
158158
}) => {
159159
const startPage = new TemplateMgmtStartPage(page);
160160

161-
await loginAsUser(userWithNoClient, page);
161+
await loginAsUser(userWithNoClientName, page);
162162

163163
await assertHeaderWhenSignedIn({
164164
page: startPage,
165165
expectedDisplayName:
166-
userWithNoClient.identityAttributes?.preferred_username ?? '',
166+
userWithNoClientName.identityAttributes?.preferred_username ?? '',
167167
expectedClientName: '',
168168
});
169169

0 commit comments

Comments
 (0)