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

const source = fs.readFileSync(
  path.resolve(__dirname, "../../src/views/ccdiProject/components/detail/FamilyAssetLiabilityDetail.vue"),
  "utf8"
);

[
  "总收入",
  "总负债",
  "总资产",
  "关键指标",
  "详查结果",
  "本人收入",
  "配偶收入",
  "净资产",
  "资产负债率",
  "资产/收入比",
  "负债/收入比",
  "section-summary-value",
  "summary-group-list",
  "summary-group-item",
  "summary-group-share",
].forEach((token) => assert(source.includes(token), token));

assert(!source.includes("el-table"), "资产与负债来源项不应继续使用表格");
assert(!source.includes("detail-grid"), "详情区不应继续保留三列网格结构");
assert(!source.includes("detail-table"), "详情区不应继续保留旧表格样式");

const incomeIndex = source.indexOf("总收入");
const debtIndex = source.indexOf("总负债");
const assetIndex = source.indexOf("总资产");
const metricIndex = source.indexOf("关键指标");
const resultIndex = source.indexOf("详查结果");

assert(incomeIndex > -1, "缺少总收入卡片");
assert(debtIndex > -1, "缺少总负债卡片");
assert(assetIndex > -1, "缺少总资产卡片");
assert(metricIndex > -1, "缺少关键指标卡片");
assert(resultIndex > -1, "缺少详查结果卡片");
assert(
  incomeIndex < debtIndex && debtIndex < assetIndex && assetIndex < metricIndex && metricIndex < resultIndex,
  "详情卡片顺序应为总收入、总负债、总资产、关键指标、详查结果"
);

assert(
  source.includes("detail-stack"),
  "详情区应改为纵向卡片容器"
);
assert(source.includes("@media (max-width: 1200px)"), "中小屏应保留响应式回落");

console.log("special-check-detail-layout test passed");
