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
74
apps/web/e2e/billing-catalog.spec.ts
Normal file
74
apps/web/e2e/billing-catalog.spec.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import { expect, test } from '@playwright/test'
|
||||
import {
|
||||
formatBillingPrice,
|
||||
formatPlanCatalogPrice,
|
||||
parseBillingCatalog,
|
||||
} from '../src/lib/billing-catalog'
|
||||
|
||||
const catalogPayload = {
|
||||
schema_version: '1',
|
||||
plans: [
|
||||
{
|
||||
tier: 'pro',
|
||||
prices: [
|
||||
{ provider: 'payple', unit_amount: 9900, currency: 'KRW', interval: 'month', interval_count: 1 },
|
||||
{ provider: 'stripe', unit_amount: 999, currency: 'USD', interval: 'month', interval_count: 1 },
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 'pro_plus',
|
||||
prices: [
|
||||
{ provider: 'payple', unit_amount: 29900, currency: 'KRW', interval: 'month', interval_count: 1 },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
test.describe('billing catalog strict client contract', () => {
|
||||
test('parses provider prices and formats minor currency units', () => {
|
||||
const catalog = parseBillingCatalog(catalogPayload)
|
||||
expect(catalog).not.toBeNull()
|
||||
expect(formatBillingPrice(catalog!.plans.pro[0])).toContain('9,900')
|
||||
expect(formatBillingPrice(catalog!.plans.pro[1])).toContain('9.99')
|
||||
expect(formatPlanCatalogPrice('pro', catalog)).toContain('Payple')
|
||||
expect(formatPlanCatalogPrice('pro', catalog)).toContain('Stripe')
|
||||
expect(formatPlanCatalogPrice('free', catalog)).toBe('무료')
|
||||
})
|
||||
|
||||
test('rejects duplicate tiers/providers, malformed amounts, and unknown values', () => {
|
||||
const invalid = [
|
||||
null,
|
||||
{},
|
||||
{ ...catalogPayload, schema_version: '2' },
|
||||
{ ...catalogPayload, plans: [catalogPayload.plans[0], catalogPayload.plans[0]] },
|
||||
{
|
||||
...catalogPayload,
|
||||
plans: [{
|
||||
tier: 'pro',
|
||||
prices: [catalogPayload.plans[0].prices[0], catalogPayload.plans[0].prices[0]],
|
||||
}, catalogPayload.plans[1]],
|
||||
},
|
||||
{
|
||||
...catalogPayload,
|
||||
plans: [{ tier: 'pro', prices: [{ ...catalogPayload.plans[0].prices[0], unit_amount: 0 }] }, catalogPayload.plans[1]],
|
||||
},
|
||||
{
|
||||
...catalogPayload,
|
||||
plans: [{ tier: 'pro', prices: [{ ...catalogPayload.plans[0].prices[0], currency: 'KRW<script>' }] }, catalogPayload.plans[1]],
|
||||
},
|
||||
]
|
||||
for (const value of invalid) expect(parseBillingCatalog(value)).toBeNull()
|
||||
})
|
||||
|
||||
test('keeps an unavailable provider absent instead of inventing a price', () => {
|
||||
const catalog = parseBillingCatalog({
|
||||
schema_version: '1',
|
||||
plans: [
|
||||
{ tier: 'pro', prices: [] },
|
||||
{ tier: 'pro_plus', prices: [] },
|
||||
],
|
||||
})
|
||||
expect(catalog).not.toBeNull()
|
||||
expect(formatPlanCatalogPrice('pro', catalog)).toBeNull()
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue