mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
091346dfe8
* wip * Remove obsolete snapshots * simplify * chore(test): Convert mocks to TypeScript and tighten fetch mock types Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Remove unneccessary patches * Migrate to msw instead of custom fetch mock * Address PR review comments - Split chained vi.useFakeTimers().setSystemTime() into separate calls. - Switch test setup to dynamic imports so EventEmitter.defaultMaxListeners assignment runs before module init (static imports were hoisted above it). - Drop redundant NODE_ENV guard in monkeyPatchSequelizeErrorsForJest; its sole caller already gates on env.isTest. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { Node } from "prosemirror-model";
|
|
import { ProsemirrorHelper } from "@server/models/helpers/ProsemirrorHelper";
|
|
import nodesWithEmptyTextNode from "@server/test/fixtures/notion-page-with-empty-text-nodes.json";
|
|
import allNodes from "@server/test/fixtures/notion-page.json";
|
|
import type { ProsemirrorData, ProsemirrorDoc } from "@shared/types";
|
|
import type { NotionPage } from "./NotionConverter";
|
|
import { NotionConverter } from "./NotionConverter";
|
|
|
|
const generatedId = "550e8400-e29b-41d4-a716-446655440000";
|
|
|
|
function normalizeGeneratedIds(node: ProsemirrorDoc | ProsemirrorData) {
|
|
if (node.type === "container_toggle" && node.attrs) {
|
|
node.attrs.id = generatedId;
|
|
}
|
|
|
|
node.content?.forEach(normalizeGeneratedIds);
|
|
}
|
|
|
|
describe("NotionConverter", () => {
|
|
it("converts a page", () => {
|
|
const response = NotionConverter.page({
|
|
children: allNodes,
|
|
} as NotionPage);
|
|
|
|
normalizeGeneratedIds(response);
|
|
expect(response).toMatchSnapshot();
|
|
expect(ProsemirrorHelper.toProsemirror(response)).toBeInstanceOf(Node);
|
|
});
|
|
|
|
it("converts a page with empty text nodes", () => {
|
|
const response = NotionConverter.page({
|
|
children: nodesWithEmptyTextNode,
|
|
} as NotionPage);
|
|
|
|
normalizeGeneratedIds(response);
|
|
expect(response).toMatchSnapshot();
|
|
expect(ProsemirrorHelper.toProsemirror(response)).toBeInstanceOf(Node);
|
|
});
|
|
});
|