Files
speckle-server/packages/server/modules/gatekeeper/tests/helpers.ts
T
Gergő Jedlicska 61ca128ce2 gergo/multiCurrency (#4379)
* feat(gatekeeper): support multiple currencies

* feat(helm): add new currency based prices to helm chart

* chore(env): add example currency based pricing values

* fix(ci): update price ids to the proper values

* feat(helm): rename price ids to fit multi currency

* feat(gatekeeper): currency input for checkout session

* Updated prices in the FE

* chore(gatekeeper): remove old checkout session flow

* Updated prices in the FE

* Fix FE

* Fix pipeline

---------

Co-authored-by: Mike Tasset <mike.tasset@gmail.com>
2025-04-11 17:37:47 +02:00

45 lines
1.3 KiB
TypeScript

import {
SubscriptionData,
WorkspaceSubscription
} from '@/modules/gatekeeper/domain/billing'
import cryptoRandomString from 'crypto-random-string'
import { assign } from 'lodash'
export const createTestSubscriptionData = (
overrides: Partial<SubscriptionData> = {}
): SubscriptionData => {
const aMonthFromNow = new Date()
aMonthFromNow.setMonth(new Date().getMonth() + 1)
const defaultValues = {
cancelAt: null,
customerId: cryptoRandomString({ length: 10 }),
products: [
{
priceId: cryptoRandomString({ length: 10 }),
productId: cryptoRandomString({ length: 10 }),
quantity: 3,
subscriptionItemId: cryptoRandomString({ length: 10 })
}
],
status: 'active',
subscriptionId: cryptoRandomString({ length: 10 }),
currentPeriodEnd: aMonthFromNow.toISOString()
}
return assign(defaultValues, overrides)
}
export const createTestWorkspaceSubscription = (
overrides: Partial<WorkspaceSubscription> = {}
): WorkspaceSubscription => {
const defaultValues: WorkspaceSubscription = {
billingInterval: 'monthly',
createdAt: new Date(),
updatedAt: new Date(),
currentBillingCycleEnd: new Date(),
subscriptionData: createTestSubscriptionData(),
currency: 'usd',
workspaceId: cryptoRandomString({ length: 10 })
}
return assign(defaultValues, overrides)
}