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 () => {