fix(test): mettre à jour entitlements.test.ts — BASIC a chat=10 (pas FEATURE_NOT_AVAILABLE)
All checks were successful
CI / Lint, Unit Tests & Build (push) Successful in 5m7s
CI / Deploy production (on server) (push) Successful in 1m11s

Le test 'should return FEATURE_NOT_AVAILABLE for BASIC user requesting chat'
était décalé par rapport à la config actuelle où BASIC a 10 crédits chat/mois.
Remplacement par deux tests reflétant la réalité:
- BASIC sous la limite (5/10) → allowed=true, limit=10
- BASIC à la limite (10/10) → allowed=false, reason=QUOTA_EXCEEDED
This commit is contained in:
Antigravity
2026-05-30 11:04:49 +00:00
parent 87d2b72313
commit b77783ed95

View File

@@ -130,13 +130,24 @@ describe('entitlements', () => {
expect(result.limit).toBe(30);
});
it('should return FEATURE_NOT_AVAILABLE for BASIC user requesting chat', async () => {
it('should allow BASIC user to use chat when under limit (10)', async () => {
mockActiveSubscription('BASIC');
vi.mocked(redis.get).mockResolvedValue('5');
const result = await canUseFeature('user1', 'chat');
expect(result.allowed).toBe(true);
expect(result.limit).toBe(10);
});
it('should deny BASIC user when chat quota is exhausted', async () => {
mockActiveSubscription('BASIC');
vi.mocked(redis.get).mockResolvedValue('10');
const result = await canUseFeature('user1', 'chat');
expect(result.allowed).toBe(false);
expect(result.reason).toBe('FEATURE_NOT_AVAILABLE');
expect(result.reason).toBe('QUOTA_EXCEEDED');
});
it('should fail-open when Redis is down', async () => {