Files
speckle-server/packages/server/test/speckle-helpers/workspaces.ts
T
Gergő Jedlicska 4a2d85d68c feat(server): web 3485 prevent accounts from creating new workspaces (#4913)
* feat(shared): rename user workspaces loader

* feat(gatekeeper): intoduce the enterprise plan

* chore(server): remove more "magic strings"

* refactor(shared): extract user is workspace admin to an auth fragment

* feat(shared): add can createWorkspacePolicy

* feat(workspaces): WIP block workspace creation

* feat(server): add can create workspace checks

* feat(workspaces): enforce canCreateWorkspace policy on the workspace
creation mutation

* feat(shared): allow workspace admins and guests to create workspaces
even if they are part of an exclusive workspace

* test(shared): use test fake properly

* fix(server): eligble workspace typing fixes

* test(shared): fix more workspace fakes

* fix(workspacesCore): add missing loader

* fix(shared): use proper exhaustive switch cases, they stop bugs from
happening

* feat(shared): introduce workspacePlanHasAccessToFeature function with tests

* chore(workspaces): fix more PR comments

* fix(workspaces): naming

* fix(workspaces): some more
2025-06-18 08:58:26 +01:00

29 lines
998 B
TypeScript

import { UpsertWorkspace } from '@/modules/workspaces/domain/operations'
import { Workspace } from '@/modules/workspacesCore/domain/types'
import cryptoRandomString from 'crypto-random-string'
export const createAndStoreTestWorkspaceFactory =
({ upsertWorkspace }: { upsertWorkspace: UpsertWorkspace }) =>
async (workspaceOverrides: Partial<Workspace> = {}) => {
const workspace: Omit<Workspace, 'domains'> = {
id: cryptoRandomString({ length: 10 }),
slug: cryptoRandomString({ length: 10 }),
name: cryptoRandomString({ length: 10 }),
createdAt: new Date(),
updatedAt: new Date(),
description: null,
logo: null,
isExclusive: false,
domainBasedMembershipProtectionEnabled: false,
discoverabilityEnabled: false,
discoverabilityAutoJoinEnabled: false,
defaultSeatType: null,
isEmbedSpeckleBrandingHidden: false,
...workspaceOverrides
}
await upsertWorkspace({ workspace })
return workspace
}