feat: move user creation into modal flow

This commit is contained in:
2026-04-01 23:16:46 +03:00
parent f6262fa721
commit 23d36ddf3d
5 changed files with 213 additions and 67 deletions

View File

@@ -3,6 +3,12 @@ import userEvent from '@testing-library/user-event';
import { describe, expect, it } from 'vitest';
import App from './App';
async function loginIntoPanel(user: ReturnType<typeof userEvent.setup>) {
await user.type(screen.getByLabelText(/login/i), 'admin');
await user.type(screen.getByLabelText(/password/i), 'proxy-ui-demo');
await user.click(screen.getByRole('button', { name: /open panel/i }));
}
describe('App login gate', () => {
it('rejects wrong hardcoded credentials and keeps the panel locked', async () => {
const user = userEvent.setup();
@@ -20,11 +26,25 @@ describe('App login gate', () => {
const user = userEvent.setup();
render(<App />);
await user.type(screen.getByLabelText(/login/i), 'admin');
await user.type(screen.getByLabelText(/password/i), 'proxy-ui-demo');
await user.click(screen.getByRole('button', { name: /open panel/i }));
await loginIntoPanel(user);
expect(screen.getByRole('navigation', { name: /primary/i })).toBeInTheDocument();
expect(screen.getByText(/control panel/i)).toBeInTheDocument();
});
it('opens add-user flow in a modal and closes it on escape', async () => {
const user = userEvent.setup();
render(<App />);
await loginIntoPanel(user);
await user.click(screen.getByRole('button', { name: /users/i }));
await user.click(screen.getByRole('button', { name: /new user/i }));
expect(screen.getByRole('dialog', { name: /add user/i })).toBeInTheDocument();
expect(screen.getByPlaceholderText(/night-shift-01/i)).toBeInTheDocument();
await user.keyboard('{Escape}');
expect(screen.queryByRole('dialog', { name: /add user/i })).not.toBeInTheDocument();
});
});