feat: qr codes
This commit is contained in:
@@ -6,6 +6,10 @@ import { AccountPage } from './AccountPage';
|
||||
import { api } from '../api/client';
|
||||
import { useAuthStore } from '../store/useStore';
|
||||
|
||||
vi.mock('qrcode', () => ({
|
||||
default: { toDataURL: () => Promise.resolve('data:image/png;base64,qr') },
|
||||
}));
|
||||
|
||||
vi.mock('../api/client', () => ({
|
||||
api: {
|
||||
getPlans: vi.fn(),
|
||||
@@ -112,6 +116,22 @@ describe('AccountPage', () => {
|
||||
expect(screen.getByRole('button', { name: /копировать/i })).toBeEnabled();
|
||||
});
|
||||
|
||||
it('opens and closes the subscription QR code dialog', async () => {
|
||||
vi.mocked(api.getMe).mockResolvedValue(ME);
|
||||
vi.mocked(api.getSubscription).mockResolvedValue(SUB);
|
||||
vi.mocked(api.getDevices).mockResolvedValue(DEVICES);
|
||||
const user = userEvent.setup();
|
||||
renderAccount();
|
||||
|
||||
await screen.findByText(SUB.subscription_link);
|
||||
await user.click(screen.getByRole('button', { name: /показать qr-код/i }));
|
||||
expect(await screen.findByRole('dialog', { name: /откройте на устройстве/i })).toBeInTheDocument();
|
||||
expect(await screen.findByAltText(/qr-код ссылки подписки/i)).toBeInTheDocument();
|
||||
|
||||
await user.click(screen.getByRole('button', { name: /закрыть/i }));
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders empty state when no devices', async () => {
|
||||
vi.mocked(api.getMe).mockResolvedValue(ME);
|
||||
vi.mocked(api.getSubscription).mockResolvedValue(SUB);
|
||||
|
||||
Reference in New Issue
Block a user