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 app = await readFile(new URL("../public/app.js", import.meta.url), "utf8"); const css = await readFile(new URL("../public/styles.css", import.meta.url), "utf8"); test("history toolbar exposes collect selected action", () => { assert.match(html, /id="history-collect-selected"/); assert.match(html, />采集选中 { assert.match(app, /historyCollectSelected\s*=\s*document\.querySelector\("#history-collect-selected"\)/); assert.match(app, /selectedHistoryPrograms\.size \? `采集选中\(\$\{selectedHistoryPrograms\.size\}\)` : "采集选中"/); assert.match(app, /collectHistoryPrograms\(names/); }); test("history selection mode has a neutral entry point", () => { assert.match(html, /id="history-bulk-button"[^>]*>批量选择<\/button>/); assert.doesNotMatch(html, /id="history-bulk-button"[^>]*>批量删除<\/button>/); }); test("history bulk button toggles select all and cancel selection", () => { assert.match(app, /selectedHistoryPrograms = new Set\(programsCache\.map\(\(program\) => program\.name\)\)/); assert.match(app, /function clearHistorySelection\(\)/); assert.match(app, /historyBulkButton\.textContent = historyBulkMode \? "取消选择" : "批量选择"/); assert.match(app, /historyCancelBulk\.addEventListener\("click", \(\) => \{\s*clearHistorySelection\(\);/); assert.match(app, /historyBulkButton\.hidden = false;/); }); test("history delete options appear after pressing delete selected", () => { assert.match(app, /let historyDeleteMode = false;/); assert.match(app, /historyDeleteMode = true;[\s\S]*renderPrograms\(programsCache\);/); assert.match(app, /\$\{historyDeleteMode \? `