chore: land in-progress workspace changes before 1.16.2
The tree carried uncommitted work from several areas (web push, mobile screens, admin charts, test-hygiene cleanup, CI and map docs). It is landed as one commit so the release pipeline can start from a clean tree; the desktop transcript-correction behaviour shipped in the previous commit and is unchanged here.
This commit is contained in:
parent
9c2b6a9782
commit
7fe49c437e
144 changed files with 3760 additions and 4523 deletions
76
apps/web/tests/billing-catalog.test.ts
Normal file
76
apps/web/tests/billing-catalog.test.ts
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
import { describe, expect, test } from 'vitest'
|
||||
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 },
|
||||
],
|
||||
},
|
||||
{
|
||||
tier: 'pro_plus',
|
||||
prices: [
|
||||
{ provider: 'payple', unit_amount: 29900, currency: 'KRW', interval: 'month', interval_count: 1 },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
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(formatPlanCatalogPrice('pro', catalog)).toContain('9,900')
|
||||
expect(formatPlanCatalogPrice('pro_plus', catalog)).toContain('29,900')
|
||||
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]],
|
||||
},
|
||||
{
|
||||
...catalogPayload,
|
||||
plans: [{ tier: 'pro', prices: [{ ...catalogPayload.plans[0].prices[0], provider: 'google_play' }] }, 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