import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import test from "node:test"; const root = new URL("../app/static/", import.meta.url); test("device workspace exposes the compact immediate pure-color test flow", async () => { const [html, device, board, picker, templates, style] = await Promise.all([ readFile(new URL("index.html", root), "utf8"), readFile(new URL("views/device.js", root), "utf8"), readFile(new URL("scene-board.js", root), "utf8"), readFile(new URL("color-picker.js", root), "utf8"), readFile(new URL("views/templates.js", root), "utf8"), readFile(new URL("style.css", root), "utf8"), ]); const deviceMarkup = html.slice( html.indexOf('id="workspace-device"'), html.indexOf('id="workspace-canvas"'), ); const templateMarkup = html.slice( html.indexOf('id="workspace-templates"'), html.indexOf('id="workspace-settings"'), ); assert.doesNotMatch(deviceMarkup, /

设备<\/p>/); assert.doesNotMatch(deviceMarkup, /id="device-title"/); assert.doesNotMatch(deviceMarkup, /data-test-diagnostic|apply-test|clear-screen/); assert.doesNotMatch(deviceMarkup, /全白只用于/); assert.equal((deviceMarkup.match(/data-test-fill=/g) || []).length, 5); assert.match(deviceMarkup, /id="custom-test-fill"[^>]*>自定义纯色/); assert.match(deviceMarkup, /id="display-test-controls"[^>]*hidden/); assert.match(deviceMarkup, /id="test-brightness"[^>]*value="50"/); assert.match(deviceMarkup, /id="exit-display-test"/); assert.match(deviceMarkup, /设备总空间[\s\S]*设备可用空间[\s\S]*当前软件总占用空间[\s\S]*模板占用空间/); assert.doesNotMatch(templateMarkup, /template-storage|template-total-size|template-free-space/); assert.match(device, /\/api\/display\/test\/fill/); assert.match(device, /\/api\/display\/test\/brightness/); assert.match(device, /method: "DELETE"/); assert.match(device, /STORAGE_REFRESH_INTERVAL_MS = 300000/); assert.match(board, /activeWorkspace === "device"/); assert.match(picker, /pickerReadonly/); assert.match(picker, /color-picker-readonly/); assert.doesNotMatch(templates, /template-total-size|template-free-space|template-total-space/); assert.ok(html.indexOf('id="topbar-current-content"') < html.indexOf('id="topbar-cpu"')); assert.ok(templateMarkup.indexOf('id="select-default-content"') < templateMarkup.indexOf('id="refresh-templates"')); assert.match(templateMarkup, /id="select-default-content"[^>]*aria-pressed="false"/); assert.match(device, /copy\.dynamic\.device\.current_content/); assert.match(device, /当前画面:\{name\}/); assert.match(templates, /\/api\/display\/default-content/); assert.match(templates, /selectingDefault/); assert.match(templates, /空动图不能设为默认/); assert.match(board, /content_source: sceneSource/); assert.match(style, /\.template-card\.template-default-content/); assert.match(style, /\.current-content-indicator/); });