fix(test): mettre à jour entitlements.test.ts — BASIC a chat=10 (pas FEATURE_NOT_AVAILABLE)
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:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user