Skip to content

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

:white_check_mark: Align editor regression tests with current behavior

Danielf11894073e7b
diff --git a/app/src/layout/tabList.test.ts b/app/src/layout/tabList.test.ts
index 22c6f65f07..310f4aa2d5 100644
--- a/app/src/layout/tabList.test.ts
+++ b/app/src/layout/tabList.test.ts
@@ -96,11 +96,21 @@ describe("tab switcher keyboard entry", () => {
assert.equal(f.document.activeElement, f.original);
});
- it("toggles an open menu without reopening it", () => {
+ it("keeps a shortcut-opened menu visible without reopening it", () => {
const f = fixture();
f.wnd.renderTabList(undefined, true);
+ const selected = f.items[1].element;
f.wnd.renderTabList(undefined, true);
assert.equal(f.popupCount(), 1);
+ assert.equal(f.menu.element.classList.contains("fn__none"), false);
+ assert.equal(f.document.activeElement, selected);
+ });
+
+ it("closes an open menu when its mouse anchor is toggled", () => {
+ const f = fixture();
+ f.wnd.renderTabList(undefined, true);
+ f.wnd.renderTabList(f.anchor);
+ assert.equal(f.popupCount(), 1);
assert.equal(f.menu.element.classList.contains("fn__none"), true);
assert.equal(f.document.activeElement, f.original);
});
diff --git a/app/src/protyle/render/listMindmap/fit.test.ts b/app/src/protyle/render/listMindmap/fit.test.ts
index 3638bfd744..2ba39ce920 100644
--- a/app/src/protyle/render/listMindmap/fit.test.ts
+++ b/app/src/protyle/render/listMindmap/fit.test.ts
@@ -40,7 +40,7 @@ test("fit restores a small map to its initial scale and centered position", () =
assert.deepEqual(transform(target), initial);
assert.equal(target.scale, 1);
assert.equal(target.offsetX, 290);
- assert.equal(target.offsetY, 142);
+ assert.equal(target.offsetY, 130);
target.fit();
assert.deepEqual(transform(target), initial, "repeated fitting is stable");
});
@@ -48,15 +48,15 @@ test("fit restores a small map to its initial scale and centered position", () =
test("fit still shrinks large maps and adapts to the current viewport", () => {
const target = setup(2020, 1010);
target.fit();
- assert.equal(target.scale, .362);
+ assert.equal(target.scale, .338);
assert.equal((20 + 2020) / 2 * target.scale + target.offsetX, 400);
- assert.equal((10 + 1010) / 2 * target.scale + target.offsetY, 197);
+ assert.equal((10 + 1010) / 2 * target.scale + target.offsetY, 185);
target.viewport.clientWidth = 360;
target.viewport.clientHeight = 300;
target.fit();
assert.equal(target.scale, .156);
assert.equal((20 + 2020) / 2 * target.scale + target.offsetX, 180);
- assert.equal((10 + 1010) / 2 * target.scale + target.offsetY, 137);
+ assert.equal((10 + 1010) / 2 * target.scale + target.offsetY, 125);
});
test("fit keeps the existing minimum zoom and ignores an unavailable canvas", () => {
diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.ts
index 8f36902288..3b07867ba6 100644
--- a/app/src/protyle/render/listMindmap/model.test.ts
+++ b/app/src/protyle/render/listMindmap/model.test.ts
@@ -3394,7 +3394,8 @@ test("list mindmap mutations preserve block data in the real DOM and Lute", {
const findShortcut = (node: import("typescript").Node) => {
if ((typescript.isVariableStatement(node) && node.declarationList.declarations.some(item =>
["isMatchList", "isMatchOList", "isMatchCheck", "isMatchQuote"].includes(item.name.getText(keydownSource)))) ||
- (typescript.isIfStatement(node) && node.expression.getText(keydownSource).includes("isProtyleListItemFragment("))) {
+ (typescript.isIfStatement(node) && ["isProtyleListItemFragment(", "isMatchList", "isMatchOList", "isMatchCheck"]
+ .every(name => node.expression.getText(keydownSource).includes(name)))) {
shortcutStatements.push(node);
}
typescript.forEachChild(node, findShortcut);
diff --git a/app/src/protyle/util/contextMenuHotkey.test.ts b/app/src/protyle/util/contextMenuHotkey.test.ts
index ac0ba43ab5..ec2e7ca681 100644
--- a/app/src/protyle/util/contextMenuHotkey.test.ts
+++ b/app/src/protyle/util/contextMenuHotkey.test.ts
@@ -113,6 +113,7 @@ test("mobile leaves unhandled context menu shortcuts available to plugin dispatc
window: {siyuan: {config: {keymap: {general: {openContextMenu: {custom: "⌘/"}}}}}},
filterHotkey: () => false,
matchHotKey: () => { throw new Error("Context menu must be handled locally"); },
+ logKeyboardDiagnostic: () => {},
captureShortcutContext: () => ({}),
dispatchPluginShortcut: () => { dispatched++; },
});
diff --git a/app/tests/avAttributeCarrier.test.js b/app/tests/avAttributeCarrier.test.js
index d100ac95d1..feea07de4f 100644
--- a/app/tests/avAttributeCarrier.test.js
+++ b/app/tests/avAttributeCarrier.test.js
@@ -226,6 +226,7 @@ const runElectron = async () => {
extract("blockAttr", ["renderAVAttribute", "renderAttributeViewBacklinks"]),
extract("openMenuPanel", ["openMenuPanel"]), extract("cell", ["updateCellsValue"]),
extract("primaryFocus", ["focusDatabasePrimary"]),
+ extract("rowReadonly", ["inheritDatabaseRowReadonly"]),
extract("../../../editor/databaseRow", ["newDatabaseRowModel"]),
extract("openDatabaseRow", ["closeMobileDatabaseRow", "openMobileDatabaseRow"])].map(source =>
ts.transpileModule(source, {compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020}}).outputText);
diff --git a/app/tests/compositionCaret.test.js b/app/tests/compositionCaret.test.js
index add5d026e3..0519e4a452 100644
--- a/app/tests/compositionCaret.test.js
+++ b/app/tests/compositionCaret.test.js
@@ -64,6 +64,7 @@ const rendererSource = () => {
const getAVTemplateInteractiveElement = () => false;
const getBlockSelectionModeElement = () => undefined;
const revealTabsForTarget = () => {};
+ const logKeyboardDiagnostic = () => {};
const getAtomicVerticalNavigationOwner = () => undefined;
const getSemanticMarkerPrefixLengthForNode = () => 0;
const normalizeInlineElementBoundaries = () => {};