feat(subscription): implement effective plan logic and update free plan features

This commit is contained in:
hamed
2026-07-05 10:46:31 +03:30
parent f3ca6d844f
commit 828e3552c0
10 changed files with 148 additions and 30 deletions
+18
View File
@@ -43,6 +43,24 @@ describe('useSubscription', () => {
expect(result.current.isExpiringSoon).toBe(true);
});
it('نبود اشتراک: امکانات را از effective_plan (پلن free) می‌گیرد', async () => {
useAuthStore.setState({ primaryRole: 'doctor' });
get.mockResolvedValue({
data: {
subscription: null,
effective_plan: { features: { patient_records: true, services: true, sms_panel: true }, max_secretaries: 1 },
},
});
const { result } = renderHookWithClient(() => useSubscription());
await waitFor(() => expect(result.current.hasFeature('patient_records')).toBe(true));
expect(result.current.hasFeature('services')).toBe(true);
expect(result.current.hasFeature('sms_panel')).toBe(true);
expect(result.current.hasPlan).toBe(false);
expect(result.current.maxSecretaries).toBe(1);
});
it('برای نقش admin غیرفعال است (query اجرا نمی‌شود)', async () => {
useAuthStore.setState({ primaryRole: 'admin' });
const { result } = renderHookWithClient(() => useSubscription());