kaikai_test/test/desktop-dashboard.test.js

60 lines
2.5 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
const html = await readFile(new URL("../public/index.html", import.meta.url), "utf8");
const css = await readFile(new URL("../public/styles.css", import.meta.url), "utf8");
const app = await readFile(new URL("../public/app.js", import.meta.url), "utf8");
test("home screen exposes a desktop workbench summary", () => {
assert.match(html, /id="desktop-dashboard"/);
assert.match(html, /id="dashboard-program-count"/);
assert.match(html, /id="dashboard-last-capture"/);
assert.match(html, /id="dashboard-pending-count"/);
assert.match(html, /href="#temporary-query-panel"/);
assert.match(css, /\.desktop-dashboard/);
assert.match(app, /renderDesktopDashboard/);
});
test("desktop workbench summary sits below the trend charts", () => {
assert.ok(html.indexOf('id="trend-charts"') < html.indexOf('id="desktop-dashboard"'));
});
test("collection progress has a visible task queue panel", () => {
assert.match(html, /id="task-queue-panel"/);
assert.match(html, /brand-task-queue/);
assert.match(html, /id="task-current"/);
assert.match(html, /id="task-progress-fill"/);
assert.match(html, /id="task-ok-count"/);
assert.match(html, /id="task-missing-count"/);
assert.match(css, /\.task-queue-panel/);
assert.match(css, /\.brand-task-queue/);
assert.match(app, /updateTaskQueue/);
});
test("task queue sits directly under the top history collection controls", () => {
assert.ok(html.indexOf('id="collect-history-button"') < html.indexOf('id="task-queue-panel"'));
assert.ok(html.indexOf('id="task-queue-panel"') < html.indexOf('id="collect-form"'));
assert.ok(html.indexOf('id="task-queue-panel"') < html.indexOf('class="statusline"'));
});
test("desktop shell has app-style navigation and persistent status", () => {
assert.match(html, /class="app-nav"/);
assert.match(html, /href="#desktop-dashboard"/);
assert.match(html, /href="#collect-form"/);
assert.match(html, /href="#temporary-query-panel"/);
assert.match(html, /href="#program-list"/);
assert.match(html, /id="app-status-port"/);
assert.match(css, /\.app-nav/);
assert.match(css, /\.app-status-dock/);
assert.match(app, /renderAppStatusDock/);
});
test("desktop build is visibly identified in the app chrome", () => {
assert.match(html, /id="app-version-badge"/);
assert.match(html, /桌面开发版/);
assert.match(html, /id="app-build-label"/);
assert.match(css, /\.app-version-badge/);
assert.match(app, /APP_BUILD_LABEL/);
});