Skip to content

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

:test_tube: Update mind map and editor test fixture dependencies

Danield3f25f47666d
diff --git a/app/src/protyle/render/listMindmap/fold.test.ts b/app/src/protyle/render/listMindmap/fold.test.ts
index d072b6ae8a..ac509c32c4 100644
--- a/app/src/protyle/render/listMindmap/fold.test.ts
+++ b/app/src/protyle/render/listMindmap/fold.test.ts
@@ -128,7 +128,7 @@ test("batch folding saves a single undo snapshot and reads the source after fini
};
runInNewContext(compiled, context);
const target = new context.Controller(list);
- Object.assign(target, {owner: {}, refresh: () => {}});
+ Object.assign(target, {owner: {}, view: {getSelectedId: () => root.id}, refresh: () => {}});
const before = snapshot();
assert.equal(await target.onFoldLevel(1), true);
assert.equal(transactions.length, 1);
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.ts
index c6e82294e8..4bdcd58649 100644
--- a/app/src/protyle/render/listMindmap/model.test.ts
+++ b/app/src/protyle/render/listMindmap/model.test.ts
@@ -2828,7 +2828,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,
const services = {
Constants: {ZWSP: "\u200b"},
getAVTemplateInteractiveElement: absent, getAVSelectionRoot: absent, isAVDragSelectSupported: absent,
- isTableLikeView: absent, isMobile: absent, shouldFoldEmbeddedListByAlt: absent,
+ isTableLikeView: absent, isMobile: absent, isPhablet: absent, shouldFoldEmbeddedListByAlt: absent,
shouldOpenListItemAttr: absent, isHiddenTabContent: absent,
isOnlyMeta: (event: MouseEvent) => (event.ctrlKey || event.metaKey) && !event.shiftKey && !event.altKey,
repairHiddenTabSelection: noop, clearSelect: noop, hideAllElements: noop, globalClickHideMenu: noop,
@@ -3270,9 +3270,10 @@ test("list mindmap mutations preserve block data in the real DOM and Lute", {
const dragSource = compile(path.join(__dirname, "../../util/hasClosest.ts")) +
compile(path.join(__dirname, "../../wysiwyg/getBlock.ts")) +
compile(path.join(__dirname, "../../wysiwyg/blockDragSelect.ts")) +
- "const {getBlockSelectionModeElement, clearBlockSelectionMode} = (() => {" +
+ "const {BLOCK_SELECTION_CLASS, getBlockSelectionModeElement, clearBlockSelectionMode} = (() => {" +
compile(path.join(__dirname, "../../wysiwyg/blockSelection.ts")) +
- "return {getBlockSelectionModeElement, clearBlockSelectionMode};})();\n" +
+ "return {BLOCK_SELECTION_CLASS, getBlockSelectionModeElement, clearBlockSelectionMode};})();\n" +
+ compile(path.join(__dirname, "../../gutter/restore.ts")) +
"const {hideElements} = (() => {" + compile(path.join(__dirname, "../../ui/hideElements.ts")) +
"return {hideElements};})();\n" +
typescript.transpileModule(mouseDownBinding.getText(wysiwygSource) + ";\n" + pointerDownBinding.getText(indexSource), {
diff --git a/app/src/protyle/render/listMindmap/preview.test.ts b/app/src/protyle/render/listMindmap/preview.test.ts
index 85d84e0028..dc6d6ae482 100644
--- a/app/src/protyle/render/listMindmap/preview.test.ts
+++ b/app/src/protyle/render/listMindmap/preview.test.ts
@@ -185,6 +185,7 @@ test("special block previews cannot acquire document writes or lose unsupported
extract("../htmlRender.ts", ["htmlRender"]) + extract("../blockRender.ts", ["blockRender"]) +
extract("../chartRender.ts", ["refreshChartTheme"]) +
extract("../av/render.ts", ["avRender", "getAVElements"]) +
+ extract("../../util/tableVirtualizationDOM.ts", ["TABLE_VIRTUAL_ID"]) +
extract("../../util/tableControl.ts", ["getCell", "getTableNode"]) +
compile(`class TablePreviewControl {${methods.map(method => method.getText(tableSource)).join("\n")}}`) +
extract("../av/richText.ts", ["ALLOWED_BLOCK_TYPES", "isSupportedAVRichTextBlock", "getAVRichTextUnsupportedPasteBlocks"]) +
diff --git a/app/src/protyle/render/listMindmap/relation.test.ts b/app/src/protyle/render/listMindmap/relation.test.ts
index f7203a8e02..b585aead23 100644
--- a/app/src/protyle/render/listMindmap/relation.test.ts
+++ b/app/src/protyle/render/listMindmap/relation.test.ts
@@ -35,7 +35,8 @@ test("manual route save and reset use one transaction and reject stale relation
canEdit: () => true,
getListMindmapSiblingIDs: () => new Map(),
normalizeListMindmapSummaryMetadata: () => {},
- readListMindmap: () => ({metadata: JSON.parse(JSON.stringify(data)), nodes: new Map(["a", "b", "c"].map(id => [id, {}]))}),
+ readListMindmap: () => ({root: {id: "a"}, metadata: JSON.parse(JSON.stringify(data)),
+ nodes: new Map(["a", "b", "c"].map(id => [id, {}]))}),
writeListMindmapMetadata: (_list: unknown, next: typeof data) => data = next,
cleanListMindmapHTML: (html: string) => html,
updateTransaction: (_owner: unknown, _list: unknown, before: string) => transactions.push({before, after: list.outerHTML}),
@@ -44,7 +45,7 @@ test("manual route save and reset use one transaction and reject stale relation
};
runInNewContext(compiled, context);
const target = new context.Controller();
- Object.assign(target, {list, owner: {}, refresh: () => {}});
+ Object.assign(target, {list, owner: {}, view: {getSelectedId: () => "a"}, refresh: () => {}});
const route = {version: 1, points: [{x: -40, y: 20, t: .5}]};
const snapshot = JSON.stringify(data.relations[0]);
target.onRelationChange("r", {route}, snapshot);
diff --git a/app/tests/agentStreamingMarkdown.test.js b/app/tests/agentStreamingMarkdown.test.js
index 7f1a3f5e46..39db957e01 100644
--- a/app/tests/agentStreamingMarkdown.test.js
+++ b/app/tests/agentStreamingMarkdown.test.js
@@ -16,6 +16,7 @@ const sources = () => {
"layout/dock/agent/AgentReasoning",
"protyle/render/setLute",
"protyle/util/inlineElementBoundary",
+ "protyle/util/tableVirtualizationDOM",
"util/escape",
].map(name => [name, ts.transpileModule(readFileSync(path.join(__dirname, "../src", name + ".ts"), "utf8"), {
compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2021},
@@ -577,7 +578,7 @@ const runCases = async (sources, css, luteScript) => {
// 实际浏览器 Worker 加载实际 Lute;模块在内存转译,不构建或替换应用产物。
body.remove();
const workerModules = Object.fromEntries(["protyle/render/setLute", "protyle/util/inlineElementBoundary",
- "layout/dock/agent/AgentMarkdownWorker"]
+ "protyle/util/tableVirtualizationDOM", "layout/dock/agent/AgentMarkdownWorker"]
.map(name => [name, sources[name]]));
const bootstrap = modules => {
const cache = {};
diff --git a/app/tests/verticalNavigation.test.js b/app/tests/verticalNavigation.test.js
index 6aaa173095..bbc119fcac 100644
--- a/app/tests/verticalNavigation.test.js
+++ b/app/tests/verticalNavigation.test.js
@@ -83,6 +83,7 @@ const rendererModules = () => {
const getAVTemplateInteractiveElement = () => false;
const focusAVByArrow = () => { throw new Error("Unexpected legacy AV keyup fallback"); };
export function bind(protyle) {
+ const isComposition = false;
let arrowStartElement = protyle.wysiwyg.element;
const handler = function(event) { ${keyupStatements} };
protyle.wysiwyg.element.addEventListener("keyup", handler.bind(protyle.wysiwyg));
@@ -92,6 +93,7 @@ const rendererModules = () => {
modules["util/selectionFocus"] = readFileSync(path.join(root, "util/selectionFocus.ts"), "utf8");
modules["util/restoreNavigationFocus"] = `import {getUndoFocusElement} from "./selectionFocus";
import {isInEmbedBlock} from "./hasClosest";
+ const restoreListMindmapFocus = () => false;
const focusByOffset = element => { window.restoredFocusElement = element; return true; };\n` +
extract("util/selection", ["restoreFocusContext"]);
for (const name of ["virtualScroll", "selectionState", "rangeSelect", "groupTableVirtual", "backlinkScroll", "viewType"]) {