Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(api): add test for workspace #141

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/api/src/api-key/api-key.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ describe('Api Key Role Controller Tests', () => {
})
})

it('should be defined', async () => {
expect(app).toBeDefined()
expect(prisma).toBeDefined()
})

it('should be able to create api key', async () => {
const response = await app.inject({
method: 'POST',
Expand Down
5 changes: 5 additions & 0 deletions apps/api/src/event/event.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ describe('Event Controller Tests', () => {
})
})

it('should be defined', async () => {
expect(app).toBeDefined()
expect(prisma).toBeDefined()
})

it('should be able to fetch a user event', async () => {
const updatedUser = await userService.updateSelf(user, {
isOnboardingFinished: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Warnings:

- The values [TRANSFER_OWNERSHIP] on the enum `Authority` will be removed. If these variants are still used in the database, this will fail.

*/
-- AlterEnum
BEGIN;
CREATE TYPE "Authority_new" AS ENUM ('CREATE_PROJECT', 'READ_USERS', 'ADD_USER', 'REMOVE_USER', 'UPDATE_USER_ROLE', 'READ_WORKSPACE', 'UPDATE_WORKSPACE', 'DELETE_WORKSPACE', 'CREATE_WORKSPACE_ROLE', 'READ_WORKSPACE_ROLE', 'UPDATE_WORKSPACE_ROLE', 'DELETE_WORKSPACE_ROLE', 'WORKSPACE_ADMIN', 'READ_PROJECT', 'UPDATE_PROJECT', 'DELETE_PROJECT', 'CREATE_SECRET', 'READ_SECRET', 'UPDATE_SECRET', 'DELETE_SECRET', 'CREATE_ENVIRONMENT', 'READ_ENVIRONMENT', 'UPDATE_ENVIRONMENT', 'DELETE_ENVIRONMENT', 'CREATE_WORKSPACE', 'CREATE_API_KEY', 'READ_API_KEY', 'UPDATE_API_KEY', 'DELETE_API_KEY', 'UPDATE_PROFILE', 'READ_SELF', 'UPDATE_SELF', 'READ_EVENT');
ALTER TABLE "WorkspaceRole" ALTER COLUMN "authorities" TYPE "Authority_new"[] USING ("authorities"::text::"Authority_new"[]);
ALTER TABLE "ApiKey" ALTER COLUMN "authorities" TYPE "Authority_new"[] USING ("authorities"::text::"Authority_new"[]);
ALTER TYPE "Authority" RENAME TO "Authority_old";
ALTER TYPE "Authority_new" RENAME TO "Authority";
DROP TYPE "Authority_old";
COMMIT;
1 change: 0 additions & 1 deletion apps/api/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ enum Authority {
READ_WORKSPACE
UPDATE_WORKSPACE
DELETE_WORKSPACE
TRANSFER_OWNERSHIP
CREATE_WORKSPACE_ROLE
READ_WORKSPACE_ROLE
UPDATE_WORKSPACE_ROLE
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/workspace-role/workspace-role.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,9 @@ describe('Workspace Role Controller Tests', () => {
])
})

it('should be defined', () => {
it('should be defined', async () => {
expect(app).toBeDefined()
expect(prisma).toBeDefined()
})

it('should be able to get the auto generated admin role', async () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/workspace/controller/workspace.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class WorkspaceController {
}

@Put(':workspaceId/transfer-ownership/:userId')
@RequiredApiKeyAuthorities(Authority.TRANSFER_OWNERSHIP)
@RequiredApiKeyAuthorities(Authority.WORKSPACE_ADMIN)
async transferOwnership(
@CurrentUser() user: User,
@Param('workspaceId') workspaceId: Workspace['id'],
Expand Down Expand Up @@ -93,7 +93,7 @@ export class WorkspaceController {
@CurrentUser() user: User,
@Param('workspaceId') workspaceId: Workspace['id'],
@Param('userId') userId: User['id'],
@Query('roles') roleIds: WorkspaceRole['id'][]
@Body() roleIds: WorkspaceRole['id'][]
) {
return this.workspaceService.updateMemberRoles(
user,
Expand Down
Loading
Loading