const assert = require("assert");
const fs = require("fs");
const path = require("path");

const entry = fs.readFileSync(
  path.resolve(
    __dirname,
    "../../src/views/ccdiProject/components/detail/PreliminaryCheck.vue"
  ),
  "utf8"
);
const stats = fs.readFileSync(
  path.resolve(
    __dirname,
    "../../src/views/ccdiProject/components/detail/OverviewStats.vue"
  ),
  "utf8"
);
const people = fs.readFileSync(
  path.resolve(
    __dirname,
    "../../src/views/ccdiProject/components/detail/RiskPeopleSection.vue"
  ),
  "utf8"
);
const mockSource = fs.readFileSync(
  path.resolve(
    __dirname,
    "../../src/views/ccdiProject/components/detail/preliminaryCheck.mock.js"
  ),
  "utf8"
);

["overview-stats", "stats-label", "stats-icon"].forEach((token) => assert(stats.includes(token), token));
["总人数", "高风险", "中风险", "低风险", "无预警人数"].forEach((token) =>
  assert(mockSource.includes(`label: "${token}"`), token)
);
["currentData.summary", "currentData.riskPeople"].forEach((token) =>
  assert(entry.includes(token), token)
);
[
  ':selected-model-codes="selectedModelCodes"',
  '@selection-change="handleRiskModelSelectionChange"',
  "selectedModelCodes: []",
].forEach((token) => assert(entry.includes(token), token));
["风险等级", "命中模型数", "查看详情"].forEach((token) =>
  assert(people.includes(token), token)
);
["姓名", "身份证号", "所属部门", "核心异常点", "riskPointTagList"].forEach((token) =>
  assert(people.includes(token), token)
);
assert(!people.includes("中高风险人员TOP10"), "不应保留TOP10区块");
assert(entry.includes("risk-people-section"), "入口应挂载风险人员区");
assert(entry.includes("risk-overview-card"), "统计区与风险人员区应位于统一总览卡片中");
assert(entry.includes("风险总览"), "结果总览页应提供风险总览主标题");
assert(!stats.includes("风险仪表盘"), "统计区不应继续保留风险仪表盘标题");
assert(!stats.includes("风险总体数据概览"), "统计区不应继续保留旧副标题");
assert(!people.includes("风险人员总览"), "风险人员区不应继续作为独立大卡片标题存在");
