Replace startup mocks with loading skeletons

This commit is contained in:
2026-04-02 04:14:56 +03:00
parent eb64f70269
commit db331e373e
5 changed files with 422 additions and 3 deletions

View File

@@ -9,6 +9,12 @@ 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 }));
await waitFor(() => expect(MockWebSocket.instances.length).toBeGreaterThan(0));
MockWebSocket.instances.at(-1)?.emitMessage({
type: 'snapshot.init',
snapshot: fallbackDashboardSnapshot,
});
await waitFor(() => expect(screen.getByRole('button', { name: /settings/i })).not.toBeDisabled());
}
function mockClipboardWriteText(writeText: ReturnType<typeof vi.fn>) {
@@ -64,6 +70,19 @@ describe('App login gate', () => {
expect(screen.queryByRole('button', { name: /open panel/i })).not.toBeInTheDocument();
});
it('shows loading skeletons instead of stale mock values before the first snapshot arrives', async () => {
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 }));
expect(screen.getByRole('navigation', { name: /primary/i })).toBeInTheDocument();
expect(screen.queryByText(/edge\.example\.net/i)).not.toBeInTheDocument();
expect(document.querySelectorAll('.skeleton-line').length).toBeGreaterThan(0);
});
it('stores panel language in localStorage and restores it after a remount', async () => {
const user = userEvent.setup();
const firstRender = render(<App />);