Skip to content

Commit 06e7386

Browse files
committed
CCM-1875: allow create without client
1 parent 0653c31 commit 06e7386

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/test-team/template-mgmt-api-tests/create-template.api.spec.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ test.describe('POST /v1/template', () => {
1616
const authHelper = createAuthHelper();
1717
const templateStorageHelper = new TemplateStorageHelper();
1818
let user1: TestUser;
19+
let userNoClient: TestUser;
1920
let userDirectOwner: TestUser;
2021

2122
test.beforeAll(async () => {
2223
user1 = await authHelper.getTestUser(testUsers.User1.userId);
24+
userNoClient = await authHelper.getTestUser(testUsers.User6.userId);
2325
userDirectOwner = await authHelper.getTestUser(testUsers.User8.userId);
2426
});
2527

@@ -819,6 +821,54 @@ test.describe('POST /v1/template', () => {
819821
});
820822

821823
test.describe('user-owned templates', () => {
824+
test('user without a clientId assigned can create a template', async ({
825+
request,
826+
}) => {
827+
const template = TemplateAPIPayloadFactory.getCreateTemplatePayload({
828+
templateType: 'NHS_APP',
829+
});
830+
831+
const start = new Date();
832+
833+
const response = await request.post(
834+
`${process.env.API_BASE_URL}/v1/template`,
835+
{
836+
headers: {
837+
Authorization: await userNoClient.getAccessToken(),
838+
},
839+
data: template,
840+
}
841+
);
842+
843+
expect(response.status()).toBe(201);
844+
845+
const created = await response.json();
846+
847+
templateStorageHelper.addAdHocTemplateKey({
848+
id: created.template.id,
849+
owner: userNoClient.userId,
850+
});
851+
852+
expect(created).toEqual({
853+
statusCode: 201,
854+
template: {
855+
createdAt: expect.stringMatching(isoDateRegExp),
856+
id: expect.stringMatching(uuidRegExp),
857+
message: template.message,
858+
name: template.name,
859+
templateStatus: 'NOT_YET_SUBMITTED',
860+
templateType: template.templateType,
861+
updatedAt: expect.stringMatching(isoDateRegExp),
862+
},
863+
});
864+
865+
expect(created.template.createdAt).toBeDateRoughlyBetween([
866+
start,
867+
new Date(),
868+
]);
869+
expect(created.template.createdAt).toEqual(created.template.updatedAt);
870+
});
871+
822872
test('can create a user-owned template', async ({ request }) => {
823873
const template = TemplateAPIPayloadFactory.getCreateTemplatePayload({
824874
templateType: 'NHS_APP',

0 commit comments

Comments
 (0)