Slefhostet und postgres
This commit is contained in:
@@ -196,4 +196,81 @@ describe('mockBackendService billing simulation', () => {
|
||||
|
||||
expect(second.billing.credits.topupBalance).toBe(25);
|
||||
});
|
||||
|
||||
it('ignores malformed pro entitlements coming from top-up customer info', async () => {
|
||||
const response = await mockBackendService.syncRevenueCatState({
|
||||
userId: 'test-user-rc-topup-misconfigured-entitlement',
|
||||
source: 'topup_purchase',
|
||||
customerInfo: {
|
||||
entitlements: {
|
||||
active: {
|
||||
pro: {
|
||||
productIdentifier: 'topup_small',
|
||||
expirationDate: '2026-04-30T00:00:00.000Z',
|
||||
},
|
||||
},
|
||||
},
|
||||
nonSubscriptions: {
|
||||
topup_small: [
|
||||
{
|
||||
productIdentifier: 'topup_small',
|
||||
transactionIdentifier: 'rc-topup-malformed-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.billing.entitlement.plan).toBe('free');
|
||||
expect(response.billing.entitlement.status).toBe('inactive');
|
||||
expect(response.billing.credits.topupBalance).toBe(25);
|
||||
expect(response.billing.credits.available).toBe(40);
|
||||
});
|
||||
|
||||
it('does not downgrade an existing pro user during a top-up sync', async () => {
|
||||
const userId = 'test-user-rc-pro-topup';
|
||||
|
||||
await mockBackendService.syncRevenueCatState({
|
||||
userId,
|
||||
source: 'subscription_purchase',
|
||||
customerInfo: {
|
||||
entitlements: {
|
||||
active: {
|
||||
pro: {
|
||||
productIdentifier: 'monthly_pro',
|
||||
expirationDate: '2026-04-30T00:00:00.000Z',
|
||||
},
|
||||
},
|
||||
},
|
||||
nonSubscriptions: {},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await mockBackendService.syncRevenueCatState({
|
||||
userId,
|
||||
source: 'topup_purchase',
|
||||
customerInfo: {
|
||||
entitlements: {
|
||||
active: {
|
||||
pro: {
|
||||
productIdentifier: 'topup_small',
|
||||
expirationDate: '2026-04-30T00:00:00.000Z',
|
||||
},
|
||||
},
|
||||
},
|
||||
nonSubscriptions: {
|
||||
topup_small: [
|
||||
{
|
||||
productIdentifier: 'topup_small',
|
||||
transactionIdentifier: 'rc-topup-pro-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.billing.entitlement.plan).toBe('pro');
|
||||
expect(response.billing.credits.available).toBe(275);
|
||||
expect(response.billing.credits.topupBalance).toBe(25);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user