Add a doctor/clinic settings sub-navigation shell (SettingsLayout) with "خرید اشتراک" as its first section, plus a mobile settings-list page. Rebuild the plan-selection page with a per-plan billing-period toggle, single price, most-popular badge and a current-plan status banner. Add a payment-success page that reads the gateway return params (?payment_uuid&status), shows the transaction receipt and the newly active plan, and redirects to the plans page with a toast on any non-success status. Frontend only — reuses the existing /api/v1/subscription/* and /api/v1/subscription-payment endpoints; no backend or API-doc changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { screen, fireEvent } from '@testing-library/react';
|
|
import { renderWithProviders } from '../../test/utils';
|
|
import SettingsLayout, { SETTINGS_MENU } from './SettingsLayout';
|
|
|
|
describe('SettingsLayout', () => {
|
|
it('renders every settings menu item and the section content', () => {
|
|
renderWithProviders(
|
|
<SettingsLayout active="subscription">
|
|
<div>محتوای اشتراک</div>
|
|
</SettingsLayout>,
|
|
);
|
|
|
|
for (const item of SETTINGS_MENU) {
|
|
expect(screen.getByText(item.label)).toBeInTheDocument();
|
|
}
|
|
expect(screen.getByText('محتوای اشتراک')).toBeInTheDocument();
|
|
});
|
|
|
|
it('marks the active item with aria-current=page', () => {
|
|
renderWithProviders(
|
|
<SettingsLayout active="subscription"><div /></SettingsLayout>,
|
|
);
|
|
const active = screen.getByText('خرید اشتراک').closest('a');
|
|
expect(active).toHaveAttribute('aria-current', 'page');
|
|
expect(active).toHaveAttribute('href', '/admin/subscription');
|
|
});
|
|
|
|
it('renders not-yet-implemented items as disabled placeholders', () => {
|
|
renderWithProviders(
|
|
<SettingsLayout active="subscription"><div /></SettingsLayout>,
|
|
);
|
|
// "حساب کاربری" has no route → disabled button with "بهزودی"
|
|
const account = screen.getByText('حساب کاربری').closest('button');
|
|
expect(account).toBeDisabled();
|
|
expect(screen.getAllByText('بهزودی').length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('filters the menu by the search query', () => {
|
|
renderWithProviders(
|
|
<SettingsLayout active="subscription"><div /></SettingsLayout>,
|
|
);
|
|
fireEvent.change(screen.getByLabelText('جستجو در تنظیمات'), { target: { value: 'اشتراک' } });
|
|
expect(screen.getByText('خرید اشتراک')).toBeInTheDocument();
|
|
expect(screen.queryByText('خدمات')).not.toBeInTheDocument();
|
|
});
|
|
});
|