Files
TREK/client/src/native/cloudOrders.test.ts
T
Maurice 857ce49962 fix(native): offer Start and Plus in the TREK Cloud catalog
Use storefront prices for purchases and allow existing subscribers to finish setup for retired products. Show the storage fair use policy and update the store descriptions for managed TREK.
2026-12-01 00:27:09 +01:00

55 lines
2.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { isNewCloudPlan, opensSoon, planForUnclaimedPurchase, refundedBeforeOpening } from './cloudOrders';
describe('opensSoon', () => {
const base = { available: true, closed: true, sandbox: false, onPlay: false };
it('FE-NATIVE-ORDERS-001: closed orders hide the purchase from an App Store build', () => {
expect(opensSoon(base)).toBe(true);
});
it('FE-NATIVE-ORDERS-002: a TestFlight build may buy while orders are closed', () => {
expect(opensSoon({ ...base, sandbox: true })).toBe(false);
});
it('FE-NATIVE-ORDERS-003: an Android release build keeps the purchase while orders are closed', () => {
expect(opensSoon({ ...base, onPlay: true })).toBe(false);
});
it('FE-NATIVE-ORDERS-004: open orders and a binary without a store never say "opens soon"', () => {
expect(opensSoon({ ...base, closed: false })).toBe(false);
expect(opensSoon({ ...base, available: false })).toBe(false);
});
});
describe('refundedBeforeOpening', () => {
it('FE-NATIVE-ORDERS-005: a purchase refused as ordering-closed on Android is the refunded one', () => {
expect(refundedBeforeOpening('ordering-closed', true)).toBe(true);
});
it('FE-NATIVE-ORDERS-006: other refusals, and ordering-closed on iOS, keep the general message', () => {
expect(refundedBeforeOpening('ordering-closed', false)).toBe(false);
expect(refundedBeforeOpening('redeem-failed', true)).toBe(false);
expect(refundedBeforeOpening(undefined, true)).toBe(false);
});
});
describe('Cloud catalog and purchase recovery', () => {
it('only offers Start and Plus even when the server still lists retired plans', () => {
expect(['start', 'basis', 'plus', 'pro'].filter(isNewCloudPlan)).toEqual(['start', 'plus']);
});
it('can finish setup for a verified purchase from a retired tier', () => {
expect(planForUnclaimedPurchase('cloud.pro.yearly', 'consent-deviations')).toEqual({
plan: { id: 'pro', name: 'Pro' },
interval: 'year',
});
expect(planForUnclaimedPurchase('cloud.basis.monthly', 'email-invalid')).toEqual({
plan: { id: 'basis', name: 'Basis' },
interval: 'month',
});
expect(planForUnclaimedPurchase('cloud.pro.yearly', 'ordering-closed')).toBeNull();
expect(planForUnclaimedPurchase('cloud.unknown.monthly', 'email-invalid')).toBeNull();
});
});