feat(release): prepare 1.1.0 candidate
This commit is contained in:
parent
5a34f66981
commit
5205dcdfa9
736 changed files with 115667 additions and 12203 deletions
59
server/supabase/functions/_shared/billing-catalog.test.ts
Normal file
59
server/supabase/functions/_shared/billing-catalog.test.ts
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import {
|
||||
createBillingCatalog,
|
||||
parseStripeCatalogPrice,
|
||||
} from './billing-catalog.ts'
|
||||
|
||||
function assert(condition: unknown, message: string): asserts condition {
|
||||
if (!condition) throw new Error(message)
|
||||
}
|
||||
|
||||
Deno.test('Stripe catalog accepts only the exact active recurring price', () => {
|
||||
const parsed = parseStripeCatalogPrice({
|
||||
id: 'price_pro',
|
||||
active: true,
|
||||
type: 'recurring',
|
||||
unit_amount: 990,
|
||||
currency: 'usd',
|
||||
recurring: { interval: 'month', interval_count: 1 },
|
||||
}, 'price_pro')
|
||||
assert(parsed?.unit_amount === 990, 'amount must be preserved')
|
||||
assert(parsed?.currency === 'USD', 'currency must be normalized')
|
||||
assert(parsed?.interval === 'month', 'interval must be preserved')
|
||||
})
|
||||
|
||||
Deno.test('Stripe catalog rejects mismatched, inactive, free, malformed, and one-time prices', () => {
|
||||
const base = {
|
||||
id: 'price_pro',
|
||||
active: true,
|
||||
type: 'recurring',
|
||||
unit_amount: 990,
|
||||
currency: 'usd',
|
||||
recurring: { interval: 'month', interval_count: 1 },
|
||||
}
|
||||
const invalid = [
|
||||
{ ...base, id: 'price_other' },
|
||||
{ ...base, active: false },
|
||||
{ ...base, type: 'one_time', recurring: null },
|
||||
{ ...base, unit_amount: 0 },
|
||||
{ ...base, currency: 'US$' },
|
||||
{ ...base, recurring: { interval: 'minute', interval_count: 1 } },
|
||||
{ ...base, recurring: { interval: 'month', interval_count: 0 } },
|
||||
]
|
||||
for (const value of invalid) {
|
||||
assert(parseStripeCatalogPrice(value, 'price_pro') === null, 'invalid Stripe price must fail closed')
|
||||
}
|
||||
})
|
||||
|
||||
Deno.test('catalog exposes only configured provider prices and never invents a fallback', () => {
|
||||
const catalog = createBillingCatalog({
|
||||
payple: { pro: 9900, pro_plus: 29900 },
|
||||
stripe: {
|
||||
pro: { unit_amount: 990, currency: 'USD', interval: 'month', interval_count: 1 },
|
||||
},
|
||||
})
|
||||
assert(catalog.plans[0].prices.length === 2, 'pro must expose two verified providers')
|
||||
assert(catalog.plans[1].prices.length === 1, 'pro plus must omit unavailable Stripe')
|
||||
|
||||
const unavailable = createBillingCatalog({})
|
||||
assert(unavailable.plans.every((plan) => plan.prices.length === 0), 'missing configuration must stay unavailable')
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue