Модуль wiki: дерево страниц, страница с Markdown (react-markdown, remark-gfm, без сырого HTML), поиск, форма привязки корня, ход синхронизации в боковой панели, скачивание вложений, поле «Корень вики» в окне нового проекта. Сид копии вики и e2e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.8 KiB
TypeScript
35 lines
1.8 KiB
TypeScript
import { render, screen, waitFor } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
import { setToken } from "../../auth/token.ts";
|
|
import { NewProjectDialog } from "../../projects/NewProjectDialog.tsx";
|
|
import { json, mockFetch } from "../../test/fetchMock.ts";
|
|
import { wikiModule } from "./index.tsx";
|
|
|
|
describe("модуль wiki", () => {
|
|
beforeEach(() => setToken("tok"));
|
|
|
|
it("описывает пункт панели и поле корня", () => {
|
|
expect(wikiModule.nav.map((n) => [n.to, n.label])).toEqual([["/wiki", "Вики"]]);
|
|
expect(wikiModule.projectFields).toEqual([
|
|
{ name: "wiki_root", label: "Корень вики", hint: "DOC-… или ссылка на страницу Eva", kind: "text" },
|
|
]);
|
|
});
|
|
|
|
it("поле корня в окне нового проекта", async () => {
|
|
const posts: unknown[] = [];
|
|
mockFetch((method, _u, body) => {
|
|
if (method === "POST") { posts.push(body); return json(201, { project: { label: "P", name: "Пэ", created_at: "" }, batch_id: 3 }); }
|
|
return json(404, {});
|
|
});
|
|
render(<QueryClientProvider client={new QueryClient()}><NewProjectDialog onClose={() => {}} onCreated={() => {}} /></QueryClientProvider>);
|
|
await userEvent.type(screen.getByLabelText("Метка"), "P");
|
|
await userEvent.type(screen.getByLabelText("Название"), "Пэ");
|
|
await userEvent.type(screen.getByLabelText("Корень вики"), "DOC-001234");
|
|
await userEvent.click(screen.getByRole("button", { name: "Создать" }));
|
|
await waitFor(() => expect(posts).toHaveLength(1));
|
|
expect(posts[0]).toMatchObject({ label: "P", wiki_root: "DOC-001234" });
|
|
});
|
|
});
|