feat(subscription): add resource quota management for subscription plans and update related components
This commit is contained in:
@@ -15,20 +15,20 @@ import SubscriptionPage from './SubscriptionPage';
|
||||
const get = api.get as ReturnType<typeof vi.fn>;
|
||||
|
||||
const PLANS = [
|
||||
{ uuid: 'p-free', name: 'free', level: 0, max_secretaries: 1,
|
||||
{ uuid: 'p-free', name: 'free', level: 0, max_secretaries: 1, max_resources: 1,
|
||||
features: { patient_records: false, services: false, sms_panel: false }, active: true, periods: [] },
|
||||
{ uuid: 'p-basic', name: 'basic', level: 1, max_secretaries: 3,
|
||||
{ uuid: 'p-basic', name: 'basic', level: 1, max_secretaries: 3, max_resources: 3,
|
||||
features: { patient_records: true, services: true, sms_panel: false }, active: true,
|
||||
periods: [
|
||||
{ uuid: 'per-1m', label: 'یک ماهه', duration_months: 1, price_rials: 1000000, is_trial: false },
|
||||
{ uuid: 'per-12m', label: 'یک ساله', duration_months: 12, price_rials: 9000000, is_trial: false },
|
||||
] },
|
||||
{ uuid: 'p-pro', name: 'professional', level: 2, max_secretaries: 10,
|
||||
{ uuid: 'p-pro', name: 'professional', level: 2, max_secretaries: 10, max_resources: -1,
|
||||
features: { patient_records: true, services: true, sms_panel: true }, active: true, periods: [] },
|
||||
];
|
||||
|
||||
const DEFAULT_MY = {
|
||||
subscription: { plan: { name: 'basic', level: 1, max_secretaries: 3, features: {} }, is_trial: false, days_remaining: 25 },
|
||||
subscription: { plan: { name: 'basic', level: 1, max_secretaries: 3, max_resources: 3, features: {} }, is_trial: false, days_remaining: 25 },
|
||||
used_trial: true, effective_plan: null,
|
||||
};
|
||||
|
||||
@@ -54,6 +54,16 @@ describe('SubscriptionPage', () => {
|
||||
expect(proCard.getByText('محبوبترین')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
/** سقف منابع کنار سقف منشی روی هر کارت پلن مینشیند؛ `-1` یعنی «نامحدود». */
|
||||
it('shows the resource quota on every plan card', async () => {
|
||||
renderWithProviders(<SubscriptionPage />, { route: '/admin/subscription' });
|
||||
|
||||
await screen.findByText('پلن پایه');
|
||||
expect(within(screen.getByTestId('plan-card-free')).getByText('۱ منبع')).toBeInTheDocument();
|
||||
expect(within(screen.getByTestId('plan-card-basic')).getByText('۳ منبع')).toBeInTheDocument();
|
||||
expect(within(screen.getByTestId('plan-card-professional')).getByText('نامحدود منبع')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the current-plan card without an expiry warning when the plan is healthy', async () => {
|
||||
renderWithProviders(<SubscriptionPage />, { route: '/admin/subscription' });
|
||||
expect(await screen.findByText('پلن فعلی شما:')).toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user