Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:white_check_mark: Repair frontend test fixtures and cross-context assertions

Danielff7822c0dc04
diff --git a/app/src/layout/dock/Graph.test.ts b/app/src/layout/dock/Graph.test.ts
index 725ae8be98..a85a03de7b 100644
--- a/app/src/layout/dock/Graph.test.ts
+++ b/app/src/layout/dock/Graph.test.ts
@@ -28,7 +28,7 @@ for (const type of ["global", "local", "pin"]) {
runInNewContext(transpileModule(readFileSync("src/config/util/configApi.ts", "utf8"), {
compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},
}).outputText, {
- exports: configExports, window: runtimeWindow, structuredClone,
+ exports: configExports, window: runtimeWindow,
require: (name: string) => {
if (name === "../../util/fetch") return {fetchSyncPost: (url: string, data: typeof writes[number]) => {
assert.equal(url, "/api/graph/setGraphConf");
@@ -78,7 +78,7 @@ for (const type of ["global", "local", "pin"]) {
await started;
assert.equal(writes.length, 1);
assert.equal(writes[0].type, type === "global" ? "global" : "local");
- assert.deepEqual(writes[0].conf, conf);
+ assert.deepEqual(JSON.parse(JSON.stringify(writes[0].conf)), conf);
assert.notEqual(writes[0].conf, conf, "queued configuration is copied before saving");
graph.searchGraph();
assert.equal(writes.length, 1);
diff --git a/app/tests/assetPreview.test.js b/app/tests/assetPreview.test.js
index 7360df590f..74d80886fc 100644
--- a/app/tests/assetPreview.test.js
+++ b/app/tests/assetPreview.test.js
@@ -17,6 +17,7 @@ const sources = () => {
viewer: compile("asset/pdf/viewer.js"),
annotations: compile("asset/anno.ts"),
annotationRuntime: compile("asset/annoRuntime.ts"),
+ annotationSave: compile("asset/annotationSave.ts"),
textLayer: compile("asset/pdf/text_layer_builder.js"),
viewerTemplate: compile("asset/pdf/viewerTemplate.ts"),
pdfTheme: compile("asset/pdfViewer.ts"),
@@ -414,6 +415,7 @@ const runCases = async source => {
"../protyle/upload/uploadResult", "../editor/pdfAssetLink", "./pdfTextAnnotation", "./pdfCoordinates",
"./pdfSelectionText"].map(name => [name, {}])),
"./annoRuntime": runtime,
+ "./annotationSave": load(source.annotationSave),
"../layout/getAll": {getAllModels: () => ({asset: []})},
"../util/fetch": {fetchPost: (...args) => annotationRequests.push(args)},
});
diff --git a/app/tests/tabsFocus.test.js b/app/tests/tabsFocus.test.js
index 0b3c045948..3d04a040a4 100644
--- a/app/tests/tabsFocus.test.js
+++ b/app/tests/tabsFocus.test.js
@@ -39,6 +39,7 @@ const sources = () => {
compile("protyle/wysiwyg/tabsRemoval.ts", ["repairActiveTab"]),
compile("protyle/util/tabsCopy.ts", ["preserveTabTask"]),
compile("protyle/wysiwyg/transactionUpdate.ts"),
+ compile("protyle/undo/viewport.ts"),
compile("protyle/wysiwyg/transaction.ts", ["onTransaction"]),
compile("protyle/wysiwyg/tabs.ts", ["boundFocusedTitles", "canEdit", "changeTabs", "renameTab", "openTabsMenu", "initEditorTabs"]),
compile("protyle/util/selection.ts", ["selectAll"]),
diff --git a/app/tests/verticalNavigation.test.js b/app/tests/verticalNavigation.test.js
index f7a66863f7..e73dee6e18 100644
--- a/app/tests/verticalNavigation.test.js
+++ b/app/tests/verticalNavigation.test.js
@@ -45,10 +45,12 @@ const rendererModules = () => {
'import {focusBlock} from "./selection";\n' + extract("util/tableCellRichNavigation", ["leaveRichTableCell"]);
modules["../util/highlightById"] = "export const scrollCenter = () => {};";
modules["util/codeScrollCenter"] = 'import {hasClosestBlock} from "./hasClosest";\n' +
+ 'import {isUndoViewportPreserved} from "../undo/viewport";\n' +
'import {getEditorRange} from "./selection";\n' +
'import {focusByRange} from "./selectionOffsets";\n' +
"const resolveVisibleListMindmapBlock = () => undefined, revealTabsForTarget = () => {};\n" +
"const isMobile = () => false;\n" + extract("../util/highlightById", ["scrollCenter"]);
+ modules["undo/viewport"] = readFileSync(path.join(root, "undo/viewport.ts"), "utf8");
modules["render/av/focus"] = 'import {focusEditableAtGoalX} from "../../wysiwyg/verticalCaret";\n' +
'import {isTableLikeView} from "./viewType";\n' +
'import {ensureAVTableBoundaryRow, getAVData} from "./virtualScroll";\n' +