Files
obsidian-excalidraw-plugin/scripts/testing/host/nativeKeyboard.test.mjs
T
zsviczian f31dff9ec1 fix: prevent recursive Markdown embeds during PDF export
Claim drawing image embeds synchronously before yielding to Obsidian's native embed discovery. Preserve native images, text references and hybrid Markdown rendering, and cover main/popout PDF preparation. Correct macOS editing commands in native test input.

Validation: 871 portable cases passed, PDF/embed and installed K-Plex checks passed. Separate native Mac Cmd+S and failed-path cleanup checks remain failing; their evidence is preserved.
2026-11-05 07:05:13 +01:00

22 lines
1.3 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { nativeKeyboardInput } from "./nativeKeyboard.mjs";
test("macOS native editing shortcuts carry browser commands while preserving trusted key parameters", () => {
for (const [code, modifiers, command] of [["KeyA", 4, "selectAll"], ["KeyZ", 4, "undo"], ["KeyZ", 12, "redo"]]) {
for (const type of ["keyDown", "rawKeyDown"]) {
const key = { type, code, key: code.slice(-1).toLowerCase(), modifiers, windowsVirtualKeyCode: code.charCodeAt(3) };
assert.deepEqual(nativeKeyboardInput(key, "darwin"), { ...key, commands: [command] });
assert.equal(Object.hasOwn(key, "commands"), false);
}
}
});
test("native keyboard transport preserves releases, app shortcuts, other platforms and explicit commands", () => {
for (const key of [{ type: "keyUp", code: "KeyA", modifiers: 4 }, { type: "keyDown", code: "KeyS", modifiers: 4 },
{ type: "keyDown", code: "KeyA", modifiers: 0 }, { type: "keyDown", code: "KeyA", modifiers: 5 },
{ type: "keyDown", code: "KeyA", modifiers: 4, commands: ["custom"] }]) assert.equal(nativeKeyboardInput(key, "darwin"), key);
const key = { type: "keyDown", code: "KeyA", modifiers: 2 };
for (const platform of ["win32", "linux"]) assert.equal(nativeKeyboardInput(key, platform), key);
});