feat(documents): add owner-scoped document workspace
This commit is contained in:
@@ -3,6 +3,7 @@ import "@testing-library/jest-dom";
|
||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { api } from "./api";
|
||||
import { I18nProvider } from "./i18n/I18nProvider";
|
||||
import { translations } from "./i18n/translations";
|
||||
import QuickCommandDialog from "./components/QuickCommandDialog";
|
||||
|
||||
const mockedApi = api as jest.Mocked<typeof api>;
|
||||
@@ -48,7 +49,7 @@ test("[PRES-E07 PRES-J04] the capture command opens review without creating a jo
|
||||
|
||||
test("[P5-00 PRES-E07] command and empty results use valid list semantics", async () => {
|
||||
render(<I18nProvider><QuickCommandDialog open onClose={jest.fn()} onNavigate={jest.fn()} onOpenAddJob={jest.fn()} /></I18nProvider>);
|
||||
expect(screen.getAllByRole("listitem")).toHaveLength(6);
|
||||
expect(screen.getAllByRole("listitem")).toHaveLength(7);
|
||||
expect(screen.getAllByRole("list").every(list => Array.from(list.children).every(item => item.tagName === "LI"))).toBe(true);
|
||||
fireEvent.change(screen.getByRole("textbox"), { target: { value: "no-such-result" } });
|
||||
mockedApi.get.mockResolvedValue({ data: [] } as never);
|
||||
@@ -125,3 +126,19 @@ test("[P5-02 PRES-E07] arrowing from a focused result keeps focus and activation
|
||||
fireEvent.click(jobs);
|
||||
expect(onNavigate).toHaveBeenCalledWith("/jobs");
|
||||
});
|
||||
|
||||
test("[P7-07 PRES-E07] the Documents command is localized and opens its owner index without fetching bodies", async () => {
|
||||
const onNavigate = jest.fn();
|
||||
const onClose = jest.fn();
|
||||
render(<I18nProvider><QuickCommandDialog open onClose={onClose} onNavigate={onNavigate} onOpenAddJob={jest.fn()} /></I18nProvider>);
|
||||
const english = (translations.en as Record<string, string>).goToDocuments;
|
||||
expect(screen.getByRole("button", { name: name => name.includes(english) })).toBeVisible();
|
||||
await act(async () => { window.dispatchEvent(new StorageEvent("storage", { key: "uiLanguage", newValue: "nb" })); });
|
||||
const bokmal = (translations.nb as Record<string, string>).goToDocuments;
|
||||
fireEvent.click(screen.getByRole("button", { name: name => name.includes(bokmal) }));
|
||||
expect(onNavigate).toHaveBeenCalledTimes(1);
|
||||
expect(onNavigate).toHaveBeenCalledWith("/documents");
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
expect(mockedApi.get).not.toHaveBeenCalled();
|
||||
expect(mockedApi.post).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user