From b77783ed9581cd5af7f107982db11a04519125bd Mon Sep 17 00:00:00 2001 From: Antigravity Date: Sat, 30 May 2026 11:04:49 +0000 Subject: [PATCH] =?UTF-8?q?fix(test):=20mettre=20=C3=A0=20jour=20entitleme?= =?UTF-8?q?nts.test.ts=20=E2=80=94=20BASIC=20a=20chat=3D10=20(pas=20FEATUR?= =?UTF-8?q?E=5FNOT=5FAVAILABLE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- memento-note/tests/unit/entitlements.test.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/memento-note/tests/unit/entitlements.test.ts b/memento-note/tests/unit/entitlements.test.ts index 0340ac6..62f5d4b 100644 --- a/memento-note/tests/unit/entitlements.test.ts +++ b/memento-note/tests/unit/entitlements.test.ts @@ -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 () => {