mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
- add a reusable subscription tier ranking helper + unit test - send pricing-table downgrades to the generic billing portal until backend proration is fixed ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7813-Guard-downgrades-via-billing-portal-2da6d73d365081f0a202dd5699143332) by [Unito](https://www.unito.io)
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { getPlanRank, isPlanDowngrade } from './subscriptionTierRank'
|
|
|
|
describe('subscriptionTierRank', () => {
|
|
it('returns consistent order for ranked plans', () => {
|
|
const yearlyPro = getPlanRank({ tierKey: 'pro', billingCycle: 'yearly' })
|
|
const monthlyStandard = getPlanRank({
|
|
tierKey: 'standard',
|
|
billingCycle: 'monthly'
|
|
})
|
|
|
|
expect(yearlyPro).toBeLessThan(monthlyStandard)
|
|
})
|
|
|
|
it('identifies downgrades correctly', () => {
|
|
const result = isPlanDowngrade({
|
|
current: { tierKey: 'pro', billingCycle: 'yearly' },
|
|
target: { tierKey: 'creator', billingCycle: 'monthly' }
|
|
})
|
|
|
|
expect(result).toBe(true)
|
|
})
|
|
|
|
it('treats lateral or upgrade moves as non-downgrades', () => {
|
|
expect(
|
|
isPlanDowngrade({
|
|
current: { tierKey: 'standard', billingCycle: 'monthly' },
|
|
target: { tierKey: 'creator', billingCycle: 'monthly' }
|
|
})
|
|
).toBe(false)
|
|
|
|
expect(
|
|
isPlanDowngrade({
|
|
current: { tierKey: 'creator', billingCycle: 'monthly' },
|
|
target: { tierKey: 'creator', billingCycle: 'monthly' }
|
|
})
|
|
).toBe(false)
|
|
})
|
|
|
|
it('treats unknown plans (e.g., founder) as non-downgrade cases', () => {
|
|
const result = isPlanDowngrade({
|
|
current: { tierKey: 'founder', billingCycle: 'monthly' },
|
|
target: { tierKey: 'standard', billingCycle: 'monthly' }
|
|
})
|
|
|
|
expect(result).toBe(false)
|
|
})
|
|
})
|