Files
gitmost/apps/server/test/jest.setup.ts
agent_coder 044daab357 feat(git-sync): двусторонний Docmost↔git синк на унифицированном конвертере (#359)
Схлопнутая дельта feat/git-sync-2 поверх актуального develop (3085ec1b).

Почему squash, а не буквальный rebase: в ветке 113 коммитов, из которых
develop уже впитал ~80 в курированном виде при унификации конвертера
(#326/#293) — но не patch-identical, поэтому они не отваливаются сами; а
коммит, УДАЛЯЮЩИЙ вендоренную копию конвертера, апстримный и в replay-набор
не входит, так что наивный replay заново добавил бы вендоренные копии.
Поэтому корректный итог — «develop + чистая net-дельта ветки», сведённая
3-way мержом (merge-base 5336f06d).

Net-дельта: серверный git-sync модуль (GitSyncModule/orchestrator/HTTP),
движок git-sync (layout/reconcile/pull/push/stabilize + QA), два фикса
round-trip/data-loss конвертера поверх УНИФИЦИРОВАННОГО
@docmost/prosemirror-markdown (вендоренной копии больше нет — git-sync
целиком на унифицированном конвертере, поведение унифицированного принято
за эталон), e2e-скрипты, доки.

Конфликты (4) слиты объединением: main.ts (метрики + GitHttpService),
apps/server/package.json (pretest-суперсет; moduleNameMapper: git-sync→src
и .js-strip оставлены, а bare-specifier @docmost/prosemirror-markdown→src
УБРАН — серверный jest выровнен на develop-подход #345 со сборённым
пакетом), .env.example (метрики + GIT_SYNC блоки), AGENTS.md (строки про
пакеты; устаревшая заметка про «три hand-synced копии схемы» в git-sync
поправлена — схема теперь только в @docmost/prosemirror-markdown).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 16:18:54 +03:00

30 lines
1.3 KiB
TypeScript

// Jest global setup (runs before each test module loads).
//
// react-dom@18 (pulled in transitively via @docmost/editor-ext -> @tiptap/react
// -> react-dom, e.g. through the math node) reads `navigator` at MODULE-INIT
// time. The server jest config uses `testEnvironment: "node"`, which has no
// `navigator`, so ANY spec that transitively imports the editor schema/engine
// (e.g. the git-sync HTTP service specs, which reach the conversion engine)
// fails to LOAD with "ReferenceError: navigator is not defined". These specs
// never exercise the DOM — they just can't survive the import. Provide the
// minimal browser globals those modules touch at import so the specs run.
/* eslint-disable @typescript-eslint/no-explicit-any */
const g = globalThis as any;
if (typeof g.navigator === "undefined") {
// react-dom only reads navigator.userAgent at init; keep it minimal.
Object.defineProperty(g, "navigator", {
value: { userAgent: "node", platform: "node" },
configurable: true,
writable: true,
});
}
if (typeof g.MessageChannel === "undefined") {
// react-dom's scheduler references MessageChannel at init in some builds.
g.MessageChannel = class {
port1 = { postMessage() {}, close() {}, onmessage: null };
port2 = { postMessage() {}, close() {}, onmessage: null };
};
}