Skip to content

Commit

Permalink
updated workspace schema in api-client as well
Browse files Browse the repository at this point in the history
  • Loading branch information
unamdev0 committed Sep 16, 2024
1 parent 44e11d2 commit 9adc705
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 37 deletions.
24 changes: 12 additions & 12 deletions apps/api/src/event/event.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions apps/api/src/workspace/service/workspace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,10 @@ export class WorkspaceService {
userId: user.id
}
},

name: {
contains: search
}


name: {
contains: search
}
}
})

Expand Down
22 changes: 11 additions & 11 deletions apps/api/src/workspace/workspace.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ describe('Workspace Controller Tests', () => {
url: '/workspace',
payload: {
name: 'Workspace 1',
icon: "🤓"
icon: '🤓'
}
})

Expand All @@ -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)
Expand All @@ -216,7 +216,7 @@ describe('Workspace Controller Tests', () => {
url: '/workspace',
payload: {
name: 'My Workspace',
icon: "🤓"
icon: '🤓'
}
})

Expand All @@ -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({
Expand All @@ -242,15 +242,15 @@ describe('Workspace Controller Tests', () => {
url: '/workspace',
payload: {
name: 'Workspace 1',
icon: "🤓"
icon: '🤓'
}
})

expect(response.statusCode).toBe(201)
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)
Expand Down Expand Up @@ -321,7 +321,7 @@ describe('Workspace Controller Tests', () => {
url: `/workspace/${workspace1.slug}`,
payload: {
name: 'Workspace 1 Updated',
icon: "🔥"
icon: '🔥'
}
})

Expand All @@ -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 () => {
Expand Down Expand Up @@ -362,7 +362,7 @@ describe('Workspace Controller Tests', () => {
url: `/workspace/${workspace1.slug}`,
payload: {
name: 'Workspace 1 Updated',
icon: "🤓"
icon: '🤓'
}
})

Expand All @@ -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(
Expand Down Expand Up @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/types/workspace.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface Workspace {
id: string
name: string
slug: string
description: string
icon: string
isFreeTier: boolean
createdAt: string
updatedAt: string
Expand All @@ -15,7 +15,7 @@ interface Workspace {

export interface CreateWorkspaceRequest {
name: string
description?: string
icon?: string
}

export interface CreateWorkspaceResponse extends Workspace {}
Expand Down Expand Up @@ -50,7 +50,7 @@ export interface ExportDataRequest {

export interface ExportDataResponse {
name: string
description: string
icon: string
workspaceRoles: {
name: string
description: string
Expand Down
2 changes: 1 addition & 1 deletion packages/api-client/tests/workspace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down

0 comments on commit 9adc705

Please sign in to comment.