-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): Replace
projectId
with name
and slug
in workspace-ro…
…le response. (#432)
- Loading branch information
Showing
5 changed files
with
113 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ describe('Workspace Role Controller Tests', () => { | |
const email = '[email protected]' | ||
let workspaceSlug: string | null | ||
let workspaceRoleSlug: string | null | ||
let projectSlug: string | null | ||
|
||
beforeAll(async () => { | ||
// Create a workspace for the tests | ||
|
@@ -24,9 +25,26 @@ describe('Workspace Role Controller Tests', () => { | |
).json()) as any | ||
|
||
workspaceSlug = workspaceResponse.slug | ||
|
||
// Create a project for the tests | ||
const projectResponse = (await ( | ||
await client.post( | ||
`/api/workspace/${workspaceSlug}/projects`, | ||
{ name: 'My Project' }, | ||
{ 'x-e2e-user-email': email } | ||
) | ||
).json()) as any | ||
|
||
projectSlug = projectResponse.slug | ||
}) | ||
|
||
afterAll(async () => { | ||
await client.delete( | ||
`/api/workspace/${workspaceSlug}/projects/${projectSlug}`, | ||
{ | ||
'x-e2e-user-email': email | ||
} | ||
) | ||
// Delete the workspace after tests | ||
await client.delete(`/api/workspace/${workspaceSlug}`, { | ||
'x-e2e-user-email': email | ||
|
@@ -41,7 +59,7 @@ describe('Workspace Role Controller Tests', () => { | |
description: 'Role for developers', | ||
colorCode: '#FF0000', | ||
authorities: ['READ_WORKSPACE', 'READ_PROJECT'], | ||
projectSlugs: [] | ||
projectSlugs: [projectSlug!] | ||
} | ||
|
||
const createWorkspaceRoleResponse = ( | ||
|
@@ -177,4 +195,43 @@ describe('Workspace Role Controller Tests', () => { | |
|
||
expect(roleExists.exists).toBe(true) | ||
}) | ||
|
||
it('should create a new workspace role with a project', async () => { | ||
const createWorkspaceRoleRequest: CreateWorkspaceRoleRequest = { | ||
workspaceSlug: workspaceSlug!, | ||
name: 'ReadOnly', | ||
description: 'Role with project access', | ||
colorCode: '#0000FF', | ||
authorities: ['READ_WORKSPACE'], | ||
projectSlugs: [projectSlug!] | ||
} | ||
|
||
const createRoleResponse = ( | ||
await workspaceRoleController.createWorkspaceRole( | ||
createWorkspaceRoleRequest, | ||
{ 'x-e2e-user-email': email } | ||
) | ||
).data | ||
|
||
expect(createRoleResponse.name).toBe('ReadOnly') | ||
expect(createRoleResponse.projects[0].project[0].slug).toBe(projectSlug) | ||
|
||
// Delete the newly created role | ||
await workspaceRoleController.deleteWorkspaceRole( | ||
{ workspaceRoleSlug: createRoleResponse.slug }, | ||
{ 'x-e2e-user-email': email } | ||
) | ||
}) | ||
|
||
it('should fetch a workspace role with its assigned project', async () => { | ||
const role = ( | ||
await workspaceRoleController.getWorkspaceRole( | ||
{ workspaceRoleSlug: workspaceRoleSlug! }, | ||
{ 'x-e2e-user-email': email } | ||
) | ||
).data | ||
|
||
expect(role.slug).toBe(workspaceRoleSlug) | ||
expect(role.projects[0].project[0].slug).toBe(projectSlug) | ||
}) | ||
}) |