From 9adc7055eb2162384def8dd4bb8da52b1ba01f2a Mon Sep 17 00:00:00 2001 From: Udit Date: Mon, 16 Sep 2024 17:11:14 +0530 Subject: [PATCH] updated workspace schema in api-client as well --- apps/api/src/event/event.e2e.spec.ts | 24 +++++++++---------- .../workspace-membership.e2e.spec.ts | 8 +++---- .../workspace/service/workspace.service.ts | 9 ++++--- apps/api/src/workspace/workspace.e2e.spec.ts | 22 ++++++++--------- .../api-client/src/types/workspace.types.d.ts | 6 ++--- packages/api-client/tests/workspace.spec.ts | 2 +- packages/schema/src/workspace.ts | 2 +- 7 files changed, 36 insertions(+), 37 deletions(-) diff --git a/apps/api/src/event/event.e2e.spec.ts b/apps/api/src/event/event.e2e.spec.ts index 1ccb5e27..c2baa4b7 100644 --- a/apps/api/src/event/event.e2e.spec.ts +++ b/apps/api/src/event/event.e2e.spec.ts @@ -99,7 +99,7 @@ describe('Event Controller Tests', () => { it('should be able to fetch a workspace event', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) expect(workspace).toBeDefined() @@ -144,7 +144,7 @@ describe('Event Controller Tests', () => { it('should be able to fetch a project event', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) const project = (await projectService.createProject(user, workspace.slug, { @@ -198,7 +198,7 @@ describe('Event Controller Tests', () => { it('should be able to fetch an environment event', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) const project = await projectService.createProject(user, workspace.slug, { @@ -261,7 +261,7 @@ describe('Event Controller Tests', () => { it('should be able to fetch a secret event', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) const project = await projectService.createProject(user, workspace.slug, { @@ -340,7 +340,7 @@ describe('Event Controller Tests', () => { it('should be able to fetch a variable event', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) const project = await projectService.createProject(user, workspace.slug, { @@ -419,7 +419,7 @@ describe('Event Controller Tests', () => { it('should be able to fetch a workspace role event', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) const project = await projectService.createProject(user, workspace.slug, { @@ -485,7 +485,7 @@ describe('Event Controller Tests', () => { it('should be able to fetch all events', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) const response = await app.inject({ @@ -518,7 +518,7 @@ describe('Event Controller Tests', () => { it('should throw an error with wrong severity value', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) const response = await app.inject({ @@ -535,7 +535,7 @@ describe('Event Controller Tests', () => { it('should throw an error with wrong source value', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) const response = await app.inject({ @@ -552,7 +552,7 @@ describe('Event Controller Tests', () => { it('should throw an error if user is not provided in event creation for user-triggered event', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) try { @@ -577,7 +577,7 @@ describe('Event Controller Tests', () => { it('should throw an exception for invalid event source', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) try { @@ -602,7 +602,7 @@ describe('Event Controller Tests', () => { it('should throw an exception for invalid event type', async () => { const workspace = await workspaceService.createWorkspace(user, { name: 'My workspace', - icon: "🤓" + icon: '🤓' }) try { diff --git a/apps/api/src/workspace-membership/workspace-membership.e2e.spec.ts b/apps/api/src/workspace-membership/workspace-membership.e2e.spec.ts index 58afa863..01954cff 100644 --- a/apps/api/src/workspace-membership/workspace-membership.e2e.spec.ts +++ b/apps/api/src/workspace-membership/workspace-membership.e2e.spec.ts @@ -220,7 +220,7 @@ describe('Workspace Membership Controller Tests', () => { it('should not be able to transfer ownership to a non member', async () => { const newWorkspace = await workspaceService.createWorkspace(user1, { name: 'Workspace 2', - icon: "🤓" + icon: '🤓' }) const response = await app.inject({ @@ -241,7 +241,7 @@ describe('Workspace Membership Controller Tests', () => { it('should not be able to transfer ownership to a member who did not accept the invitation', async () => { const newWorkspace = await workspaceService.createWorkspace(user1, { name: 'Workspace 2', - icon: "🤓" + icon: '🤓' }) // Create membership @@ -265,7 +265,7 @@ describe('Workspace Membership Controller Tests', () => { it('should be able to transfer the ownership of the workspace', async () => { const newWorkspace = await workspaceService.createWorkspace(user1, { name: 'Workspace 2', - icon: "🤓" + icon: '🤓' }) // Create membership @@ -306,7 +306,7 @@ describe('Workspace Membership Controller Tests', () => { it('should not be able to transfer ownership if is not admin', async () => { const newWorkspace = await workspaceService.createWorkspace(user1, { name: 'Workspace 2', - icon: "🤓" + icon: '🤓' }) // Create membership diff --git a/apps/api/src/workspace/service/workspace.service.ts b/apps/api/src/workspace/service/workspace.service.ts index ff15dbb8..a13c2538 100644 --- a/apps/api/src/workspace/service/workspace.service.ts +++ b/apps/api/src/workspace/service/workspace.service.ts @@ -225,11 +225,10 @@ export class WorkspaceService { userId: user.id } }, - - name: { - contains: search - } - + + name: { + contains: search + } } }) diff --git a/apps/api/src/workspace/workspace.e2e.spec.ts b/apps/api/src/workspace/workspace.e2e.spec.ts index 09862091..ce019d1b 100644 --- a/apps/api/src/workspace/workspace.e2e.spec.ts +++ b/apps/api/src/workspace/workspace.e2e.spec.ts @@ -192,7 +192,7 @@ describe('Workspace Controller Tests', () => { url: '/workspace', payload: { name: 'Workspace 1', - icon: "🤓" + icon: '🤓' } }) @@ -201,7 +201,7 @@ describe('Workspace Controller Tests', () => { expect(body.name).toBe('Workspace 1') expect(body.slug).toBeDefined() - expect(body.icon).toBe("🤓") + expect(body.icon).toBe('🤓') expect(body.ownerId).toBe(user1.id) expect(body.isFreeTier).toBe(true) expect(body.isDefault).toBe(false) @@ -216,7 +216,7 @@ describe('Workspace Controller Tests', () => { url: '/workspace', payload: { name: 'My Workspace', - icon: "🤓" + icon: '🤓' } }) @@ -231,7 +231,7 @@ describe('Workspace Controller Tests', () => { it('should let other user to create workspace with same name', async () => { await workspaceService.createWorkspace(user1, { name: 'Workspace 1', - icon: "🤓" + icon: '🤓' }) const response = await app.inject({ @@ -242,7 +242,7 @@ describe('Workspace Controller Tests', () => { url: '/workspace', payload: { name: 'Workspace 1', - icon: "🤓" + icon: '🤓' } }) @@ -250,7 +250,7 @@ describe('Workspace Controller Tests', () => { workspace2 = response.json() expect(workspace2.name).toBe('Workspace 1') - expect(workspace2.icon).toBe("🤓") + expect(workspace2.icon).toBe('🤓') expect(workspace2.ownerId).toBe(user2.id) expect(workspace2.isFreeTier).toBe(true) expect(workspace2.isDefault).toBe(false) @@ -321,7 +321,7 @@ describe('Workspace Controller Tests', () => { url: `/workspace/${workspace1.slug}`, payload: { name: 'Workspace 1 Updated', - icon: "🔥" + icon: '🔥' } }) @@ -330,7 +330,7 @@ describe('Workspace Controller Tests', () => { expect(body.name).toBe('Workspace 1 Updated') expect(body.slug).not.toBe(workspace1.slug) - expect(body.icon).toBe("🔥") + expect(body.icon).toBe('🔥') }) it('should not be able to change the name to an existing workspace or same name', async () => { @@ -362,7 +362,7 @@ describe('Workspace Controller Tests', () => { url: `/workspace/${workspace1.slug}`, payload: { name: 'Workspace 1 Updated', - icon: "🤓" + icon: '🤓' } }) @@ -371,7 +371,7 @@ describe('Workspace Controller Tests', () => { it('should have created a WORKSPACE_UPDATED event', async () => { await workspaceService.updateWorkspace(user1, workspace1.slug, { - icon: "🤓" + icon: '🤓' }) const response = await fetchEvents( @@ -536,7 +536,7 @@ describe('Workspace Controller Tests', () => { it('should be able to delete the workspace', async () => { const newWorkspace = await workspaceService.createWorkspace(user1, { name: 'Workspace 2', - icon: "🤓" + icon: '🤓' }) const response = await app.inject({ diff --git a/packages/api-client/src/types/workspace.types.d.ts b/packages/api-client/src/types/workspace.types.d.ts index 9def521d..b9c190a1 100644 --- a/packages/api-client/src/types/workspace.types.d.ts +++ b/packages/api-client/src/types/workspace.types.d.ts @@ -4,7 +4,7 @@ interface Workspace { id: string name: string slug: string - description: string + icon: string isFreeTier: boolean createdAt: string updatedAt: string @@ -15,7 +15,7 @@ interface Workspace { export interface CreateWorkspaceRequest { name: string - description?: string + icon?: string } export interface CreateWorkspaceResponse extends Workspace {} @@ -50,7 +50,7 @@ export interface ExportDataRequest { export interface ExportDataResponse { name: string - description: string + icon: string workspaceRoles: { name: string description: string diff --git a/packages/api-client/tests/workspace.spec.ts b/packages/api-client/tests/workspace.spec.ts index a961ab77..3608fc24 100644 --- a/packages/api-client/tests/workspace.spec.ts +++ b/packages/api-client/tests/workspace.spec.ts @@ -78,7 +78,7 @@ describe('Workspaces Controller Tests', () => { await workspaceController.createWorkspace( { name: 'New Workspace', - description: 'This is a new workspace' + icon: '🤓' }, { 'x-e2e-user-email': email diff --git a/packages/schema/src/workspace.ts b/packages/schema/src/workspace.ts index 88d2e6c5..7164eee5 100644 --- a/packages/schema/src/workspace.ts +++ b/packages/schema/src/workspace.ts @@ -2,7 +2,7 @@ import { z } from 'zod' export const CreateWorkspaceSchema = z.object({ name: z.string(), - description: z.string().optional(), + icon: z.string().optional(), isDefault: z.boolean().optional() })