Files
workinf_Blender_Wasm/web/tests/unit/ui-schema.test.mjs
mes123456 0fe8d2bb56
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
Advance M8-M11 parity workflows
2026-08-17 04:37:07 -04:00

36 lines
1.7 KiB
JavaScript

import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import test from "node:test";
import ts from "typescript";
const repoRoot = path.resolve(import.meta.dirname, "../../..");
const sourcePath = path.join(repoRoot, "web/protocol/ui-schema.ts");
const transpiled = ts.transpileModule(fs.readFileSync(sourcePath, "utf8"), {
compilerOptions: { module: ts.ModuleKind.ES2022, target: ts.ScriptTarget.ES2022 },
fileName: sourcePath,
reportDiagnostics: true,
});
assert.deepEqual(transpiled.diagnostics, []);
const moduleUrl = "data:text/javascript;base64," + Buffer.from(transpiled.outputText).toString("base64");
const { createDefaultWebWorkspaceState, reduceUICommand } = await import(moduleUrl);
test("M7-13 menu and modal overlays are mutually exclusive and Escape-closeable", () => {
let state = createDefaultWebWorkspaceState();
state = reduceUICommand(state, { type: "toggleMenu", menu: "文件" });
assert.equal(state.openMenu, "文件");
assert.equal(state.operatorSearchOpen, false);
state = reduceUICommand(state, { type: "toggleMenu", menu: "编辑" });
assert.equal(state.openMenu, "编辑");
assert.equal(state.operatorSearchOpen, false);
state = reduceUICommand(state, { type: "toggleOperatorSearch", open: true });
assert.equal(state.operatorSearchOpen, true);
assert.equal(state.openMenu, null);
state = reduceUICommand(state, { type: "toggleOperatorSearch", open: false });
assert.equal(state.operatorSearchOpen, false);
state = reduceUICommand(state, { type: "toggleMenu", menu: "窗口" });
assert.equal(state.openMenu, "窗口");
state = reduceUICommand(state, { type: "toggleMenu", menu: "窗口" });
assert.equal(state.openMenu, null);
});