1. replaceAll (Find & Replace) — une seule transaction ProseMirror au lieu d'un forEach cassé. Tous les matchs sont maintenant remplacés. 2. Link Preview unwrap — deleteNode() au lieu de clearer les attrs qui laissaient un nœud fantôme invisible dans le document. 3. Conversion Markdown → richtext — breaks: true dans marked.parse() Les simple newlines sont maintenant convertis en <br>. + préserve les blocs custom (toggle, callout, math, columns, outline, link-preview) en commentaires HTML lors de l'export MD. 4. emitNoteChange exercices — shape corrigée (type:'created' attend un objet Note, pas noteId/notebookId séparés). 5. Raccourcis clavier sans conflit : Cmd+Shift+C → Cmd+Alt+C (callout, avant: copier) Cmd+Shift+O → Cmd+Alt+O (outline, avant: historique/signets) Cmd+Shift+L → Cmd+Alt+L (colonnes, avant: lock screen macOS)
82 lines
2.7 KiB
TypeScript
82 lines
2.7 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
import { resolvePriceId, priceIdToTier } from '@/lib/billing/stripe-prices';
|
|
|
|
vi.mock('@/lib/prisma', () => ({
|
|
default: {
|
|
systemConfig: {
|
|
findMany: vi.fn().mockResolvedValue([]),
|
|
},
|
|
},
|
|
}));
|
|
|
|
describe('billing-price-map', () => {
|
|
const originalEnv = process.env;
|
|
|
|
beforeEach(() => {
|
|
process.env = {
|
|
...originalEnv,
|
|
STRIPE_PRICE_PRO_MONTHLY: 'price_pro_monthly_test',
|
|
STRIPE_PRICE_PRO_ANNUAL: 'price_pro_annual_test',
|
|
STRIPE_PRICE_BUSINESS_MONTHLY: 'price_business_monthly_test',
|
|
STRIPE_PRICE_BUSINESS_ANNUAL: 'price_business_annual_test',
|
|
};
|
|
});
|
|
|
|
afterEach(() => {
|
|
process.env = originalEnv;
|
|
});
|
|
|
|
describe('resolvePriceId', () => {
|
|
it('returns PRO monthly price ID', async () => {
|
|
expect(await resolvePriceId('PRO', 'month')).toBe('price_pro_monthly_test');
|
|
});
|
|
|
|
it('returns PRO annual price ID', async () => {
|
|
expect(await resolvePriceId('PRO', 'year')).toBe('price_pro_annual_test');
|
|
});
|
|
|
|
it('returns BUSINESS monthly price ID', async () => {
|
|
expect(await resolvePriceId('BUSINESS', 'month')).toBe('price_business_monthly_test');
|
|
});
|
|
|
|
it('returns BUSINESS annual price ID', async () => {
|
|
expect(await resolvePriceId('BUSINESS', 'year')).toBe('price_business_annual_test');
|
|
});
|
|
|
|
it('throws if env variable is not set', async () => {
|
|
delete process.env.STRIPE_PRICE_PRO_MONTHLY;
|
|
await expect(resolvePriceId('PRO', 'month')).rejects.toThrow();
|
|
});
|
|
});
|
|
|
|
describe('priceIdToTier', () => {
|
|
it('resolves PRO monthly price ID to PRO tier', async () => {
|
|
expect(await priceIdToTier('price_pro_monthly_test')).toBe('PRO');
|
|
});
|
|
|
|
it('resolves PRO annual price ID to PRO tier', async () => {
|
|
expect(await priceIdToTier('price_pro_annual_test')).toBe('PRO');
|
|
});
|
|
|
|
it('resolves BUSINESS monthly price ID to BUSINESS tier', async () => {
|
|
expect(await priceIdToTier('price_business_monthly_test')).toBe('BUSINESS');
|
|
});
|
|
|
|
it('resolves BUSINESS annual price ID to BUSINESS tier', async () => {
|
|
expect(await priceIdToTier('price_business_annual_test')).toBe('BUSINESS');
|
|
});
|
|
|
|
it('returns null for unknown price ID', async () => {
|
|
expect(await priceIdToTier('price_unknown_xyz')).toBeNull();
|
|
});
|
|
|
|
it('returns null when env variables are not set', async () => {
|
|
delete process.env.STRIPE_PRICE_PRO_MONTHLY;
|
|
delete process.env.STRIPE_PRICE_PRO_ANNUAL;
|
|
delete process.env.STRIPE_PRICE_BUSINESS_MONTHLY;
|
|
delete process.env.STRIPE_PRICE_BUSINESS_ANNUAL;
|
|
expect(await priceIdToTier('price_pro_monthly_test')).toBeNull();
|
|
});
|
|
});
|
|
});
|