Files
speckle-server/packages/server/modules/gatekeeper/tests/helpers/workspacePlan.ts
T
Kristaps Fabians Geikins 4b06f42db7 chore(server): run TS files directly (no compilation) (#5134)
* sort of works

* type fixes

* added option to run old way too
2025-07-23 11:20:40 +02:00

68 lines
1.7 KiB
TypeScript

import type { WorkspacePlan } from '@speckle/shared'
import cryptoRandomString from 'crypto-random-string'
import { assign } from 'lodash-es'
import type {
SubscriptionData,
SubscriptionProduct,
WorkspaceSubscription
} from '@/modules/gatekeeper/domain/billing'
export const buildTestWorkspacePlan = (
overrides?: Partial<WorkspacePlan>
): WorkspacePlan =>
assign(
{
workspaceId: cryptoRandomString({ length: 10 }),
createdAt: new Date(),
updatedAt: new Date(),
name: 'free',
status: 'valid'
},
overrides
)
export const buildTestWorkspaceSubscription = (
overrides?: Partial<WorkspaceSubscription>
): WorkspaceSubscription =>
assign(
{
workspaceId: cryptoRandomString({ length: 10 }),
createdAt: new Date(),
updatedAt: new Date(),
currentBillingCycleEnd: new Date(),
billingInterval: 'monthly',
updateIntent: {},
currency: 'usd',
subscriptionData: buildTestSubscriptionData()
},
overrides
)
export const buildTestSubscriptionData = (
overrides?: Partial<SubscriptionData>
): SubscriptionData =>
assign(
{
subscriptionId: cryptoRandomString({ length: 10 }),
customerId: cryptoRandomString({ length: 10 }),
cancelAt: new Date(),
status: 'active',
products: [],
currentPeriodEnd: new Date()
},
overrides
)
export const buildTestSubscriptionProduct = (
overrides?: Partial<SubscriptionProduct>
): SubscriptionProduct =>
assign(
{
productId: cryptoRandomString({ length: 10 }),
subscriptionItemId: cryptoRandomString({ length: 10 }),
priceId: cryptoRandomString({ length: 10 }),
quantity: 1
},
overrides
)