Files
speckle-server/packages/server/modules/gatekeeper/tests/helpers/workspacePlan.ts
T
Daniel Gak Anagrov 51d6a8dd67 feat(activity): added user info to checkout_subscription and subscription upgrade (#4967)
* feat: added userId to checkout_subscription
* feat: add update intent to subscription
2025-06-24 15:34:26 +02:00

68 lines
1.7 KiB
TypeScript

import { WorkspacePlan } from '@speckle/shared'
import cryptoRandomString from 'crypto-random-string'
import { assign } from 'lodash'
import {
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
)