初始化奇妙小屏幕控制器项目
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const editorRoot = new URL("../app/ui_copy_editor/static/", import.meta.url);
|
||||
|
||||
test("special editor exposes the agreed modes and guarded editing flow", async () => {
|
||||
const [source, style, runtime, board, device, html] = await Promise.all([
|
||||
readFile(new URL("editor.js", editorRoot), "utf8"),
|
||||
readFile(new URL("editor.css", editorRoot), "utf8"),
|
||||
readFile(new URL("../../static/ui-copy-runtime.js", editorRoot), "utf8"),
|
||||
readFile(new URL("../../static/scene-board.js", editorRoot), "utf8"),
|
||||
readFile(new URL("../../static/views/device.js", editorRoot), "utf8"),
|
||||
readFile(new URL("../../static/index.html", editorRoot), "utf8"),
|
||||
]);
|
||||
|
||||
assert.match(source, /data-mode="browse"/);
|
||||
assert.match(source, /data-mode="select"/);
|
||||
assert.match(source, /data-mode="insert"/);
|
||||
assert.match(source, /确定修改/);
|
||||
assert.match(source, /删除这行文字/);
|
||||
assert.match(source, /确认删除文字/);
|
||||
assert.match(source, /"If-Match": etag/);
|
||||
assert.match(source, /event\.stopImmediatePropagation\(\)/);
|
||||
assert.match(source, /crypto\.randomUUID\(\)/);
|
||||
assert.match(source, /history\.push/);
|
||||
assert.match(source, /页面和输入内容均未改变/);
|
||||
assert.doesNotMatch(source, /MutationObserver/);
|
||||
assert.doesNotMatch(source, /setTimeout/);
|
||||
assert.doesNotMatch(source, /applyAllBindings/);
|
||||
assert.doesNotMatch(source, /innerHTML\s*=\s*copyTextInput/);
|
||||
|
||||
const inputHandler = source.match(/elements\.copyForm\.addEventListener\("input", \(\) => \{([\s\S]*?)\n\}\);/)?.[1] || "";
|
||||
assert.doesNotMatch(inputHandler, /fetch|setUiCopyDraft|applyUiCopyId|textContent\s*=/);
|
||||
assert.match(runtime, /preserveAccessibleName/);
|
||||
assert.match(runtime, /record\.defaultHidden/);
|
||||
assert.match(source, /恢复显示这行文字/);
|
||||
assert.doesNotMatch(runtime, /\.hidden\s*=/);
|
||||
assert.doesNotMatch(runtime, /MutationObserver/);
|
||||
assert.match(board, /renderUiCopy\("copy\.dynamic\.board\.monitor_eyebrow"/);
|
||||
assert.match(device, /copy\.dynamic\.device\.voltage_ok/);
|
||||
assert.match(html, /id="topbar-cpu"[^>]*data-ui-copy-value/);
|
||||
assert.match(html, /id="brightness-value"[^>]*data-ui-copy-value/);
|
||||
|
||||
assert.match(style, /#ui-copy-editor-toggle[\s\S]*position:\s*fixed/);
|
||||
assert.match(style, /right:\s*max\(16px, env\(safe-area-inset-right\)\)/);
|
||||
assert.match(style, /@media \(max-width: 40rem\)/);
|
||||
assert.doesNotMatch(style, /\.ui-copy-custom-insertion[\s\S]{0,250}position:\s*absolute/);
|
||||
});
|
||||
Reference in New Issue
Block a user