Files
koc-loop/tests/task-center-stage.test.mjs

58 lines
3.0 KiB
JavaScript
Raw Permalink Normal View History

import { strict as assert } from "node:assert";
import { readFileSync } from "node:fs";
import test from "node:test";
const adminApp = readFileSync(new URL("../app/admin-app.tsx", import.meta.url), "utf8");
const adminCss = readFileSync(new URL("../app/globals.css", import.meta.url), "utf8");
test("任务卡单一入口:发布/回收面板整块可点,全卡只有一个「查看明细」", () => {
const start = adminApp.indexOf("function TaskRowCard");
const end = adminApp.indexOf("function TasksPage");
const body = adminApp.slice(start, end);
// 两块阶段面板都可整块点击进入任务明细
assert.match(body, /className="master-panel publish clickable"/);
assert.match(body, /className="master-panel recovery clickable"/);
// 回收面板不再有独立的「查看明细」按钮:全卡仅一处
assert.equal(body.match(/查看明细/g)?.length, 1);
// 未开通回收的面板保持不可点、保留开通入口
assert.match(body, /className="master-panel ghost"/);
assert.match(body, /开通回收 ›/);
});
test("详情页自述身份:动态 label 说明任务阶段构成", () => {
assert.match(adminApp, /任务详情 · 分发与回收一体/);
assert.match(adminApp, /任务详情 · 仅分发/);
// 头部阶段徽章:含回收(带截止日或同日说明)/ 未开通回收
assert.match(adminApp, /未开通回收"\s*: task\.recovery_due_at/);
assert.match(adminApp, /含回收 · 回收截止 \$\{formatDate\(task\.recovery_due_at\)\}/);
assert.match(adminApp, /含回收 · 与发布同日截止/);
});
test("单一列表按阶段筛选:不拆两套列表,用筛选 chips 过滤生命周期阶段", () => {
const start = adminApp.indexOf("function TaskDistributionDetail");
const end = adminApp.indexOf("\nfunction ", start + 20);
const body = adminApp.slice(start, end);
assert.match(body, /const \[stageFilter, setStageFilter\] = useState<StageFilterKey>\("all"\);/);
assert.match(body, /key: "pending_publish",\s*\n\s*label: "待发布"/);
assert.match(body, /label: "已发布待数据"/);
assert.match(body, /label: "待收截图"/);
// 待收截图仅在开通回收的任务出现
assert.match(body, /\.\.\.\(recoveryEnabled\s*\?\s*\[\{/);
// 表格使用过滤后的列表;筛选落空时给出专用空态文案
assert.match(body, /distributions=\{visibleDistributions\}/);
assert.match(body, /当前筛选下没有分发记录/);
assert.match(body, /stage-filter-tabs/);
});
test("阶段面板与筛选 chips 的样式", () => {
assert.match(adminCss, /^\.master-panel\.clickable \{/m);
assert.match(adminCss, /^\.master-panel\.clickable:hover \{/m);
assert.match(adminCss, /^\.stage-filter-tabs \{/m);
assert.match(adminCss, /^\.stage-filter-tabs button\.active \{/m);
});
test("数据回收页入口不再使用「数据回收任务」的说法", () => {
assert.match(adminApp, /选择一个任务进入回收队列/);
assert.doesNotMatch(adminApp, /选择一个数据回收任务/);
});