feat(subscription): implement effective plan logic and update free plan features
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user