From 5f7e21f1e769942b1f21e226964490930e4eb146 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Wed, 2 Oct 2024 09:50:38 +0200 Subject: [PATCH] chore: test that owners and roles are returned (#8319) Test that owners and roles are returned in the personal dashboard project details response as expected. --- .../personal-dashboard-controller.e2e.test.ts | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/lib/features/personal-dashboard/personal-dashboard-controller.e2e.test.ts b/src/lib/features/personal-dashboard/personal-dashboard-controller.e2e.test.ts index 55d5b8f89281..a89579031c7b 100644 --- a/src/lib/features/personal-dashboard/personal-dashboard-controller.e2e.test.ts +++ b/src/lib/features/personal-dashboard/personal-dashboard-controller.e2e.test.ts @@ -215,9 +215,20 @@ test('should return projects where users are part of a group', async () => { }); test('should return personal dashboard project details', async () => { - const { body: user } = await loginUser('new_user@test.com'); + const { body: user1 } = await loginUser('new_user@test.com'); + + const project = await createProject(`x${randomId()}`, user1); + const { body: user2 } = await loginUser('user2@test.com'); + await app.services.projectService.addAccess( + project.id, + [4], // owner role + [], + [user2.id], + user1, + ); + + await loginUser(user1.email); - const project = await createProject(`x${randomId()}`, user); await app.createFeature('log_feature_a', project.id); await app.createFeature('log_feature_b', project.id); await app.createFeature('log_feature_c', project.id); @@ -227,12 +238,30 @@ test('should return personal dashboard project details', async () => { ); expect(body).toMatchObject({ + owners: [ + { + email: user1.email, + name: user1.email, + ownerType: 'user', + }, + { + email: user2.email, + name: user2.email, + ownerType: 'user', + }, + ], + roles: [ + { + id: 4, + name: 'Owner', + type: 'project', + }, + ], insights: { avgHealthCurrentWindow: null, avgHealthPastWindow: null, }, - owners: [{}], - roles: [{}], + onboardingStatus: { status: 'first-flag-created', feature: 'log_feature_a', @@ -257,9 +286,9 @@ test('should return personal dashboard project details', async () => { ), }, { - createdBy: 'audit user', + createdBy: 'unknown', summary: expect.stringContaining( - `**audit user** created project **[${project.id}]`, + 'triggered **project-access-added**', ), }, ],