test(redesign): establish preservation baseline
Map 57 capability groups before restructuring. Add behavioral regression coverage and a standalone TypeScript gate; retain the native SQLite package failure as separate baseline debt.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import React from "react";
|
||||
import "@testing-library/jest-dom";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { api } from "./api";
|
||||
import { I18nProvider } from "./i18n/I18nProvider";
|
||||
import QuickCommandDialog from "./components/QuickCommandDialog";
|
||||
|
||||
const mockedApi = api as jest.Mocked<typeof api>;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
localStorage.removeItem("uiLanguage");
|
||||
mockedApi.get.mockImplementation((url: string) => Promise.resolve({ data: url === "/companies"
|
||||
? [{ id: 7, name: "Nordlys AS" }]
|
||||
: { items: [{ id: 42, jobTitle: "Platform engineer", company: { name: "Nordlys AS" } }] } } as never));
|
||||
});
|
||||
|
||||
test.each([
|
||||
["Nordlys AS - Platform engineer", "/jobs/42"],
|
||||
["Nordlys AS", "/companies?edit=7"],
|
||||
])("[PRES-E07] command search opens %s at its existing destination", async (label, destination) => {
|
||||
const onNavigate = jest.fn();
|
||||
const onClose = jest.fn();
|
||||
render(<I18nProvider><QuickCommandDialog open onClose={onClose} onNavigate={onNavigate} onOpenAddJob={jest.fn()} /></I18nProvider>);
|
||||
fireEvent.change(screen.getByRole("textbox"), { target: { value: "Nordlys" } });
|
||||
fireEvent.click(await screen.findByText(label, { exact: true }));
|
||||
expect(onNavigate).toHaveBeenCalledWith(destination);
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
expect(mockedApi.post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("[PRES-E07 PRES-J04] the capture command opens review without creating a job, and closing clears search", async () => {
|
||||
const onOpenAddJob = jest.fn();
|
||||
const props = { onClose: jest.fn(), onNavigate: jest.fn(), onOpenAddJob };
|
||||
const view = (open: boolean) => <I18nProvider><QuickCommandDialog open={open} {...props} /></I18nProvider>;
|
||||
const { rerender } = render(view(true));
|
||||
fireEvent.click(screen.getByRole("button", { name: /add new job/i }));
|
||||
expect(onOpenAddJob).toHaveBeenCalledTimes(1);
|
||||
expect(mockedApi.post).not.toHaveBeenCalled();
|
||||
fireEvent.change(screen.getByRole("textbox"), { target: { value: "Nordlys" } });
|
||||
await screen.findByText("Nordlys AS - Platform engineer");
|
||||
rerender(view(false));
|
||||
rerender(view(true));
|
||||
await waitFor(() => expect(screen.getByRole("textbox")).toHaveValue(""));
|
||||
expect(screen.queryByText("Nordlys AS - Platform engineer")).not.toBeInTheDocument();
|
||||
});
|
||||
Reference in New Issue
Block a user