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"
);

[
  "assetGroups",
  "debtGroups",
  "buildAmountGroups",
  "resolveAssetGroupLabel",
  "resolveDebtGroupLabel",
  "item.assetName",
  "item.debtName",
  "summary.totalAsset",
  "summary.totalDebt",
  "summary.riskLevelCode",
  "summary.riskLevelName",
  "NORMAL",
  "RISK",
  "HIGH",
  "MISSING_INFO",
  "结构基本合理",
  "负债与收入压力偏高",
  "资产负债结构明显异常",
  "当前信息不完整",
  "summary-group-name",
  "summary-group-amount",
  "summary-group-share",
].forEach((token) => {
  assert(source.includes(token), `缺少新版详情聚合或风险结果实现: ${token}`);
});

assert(source.includes("totalDebt / totalAsset"), "缺少资产负债率计算");
assert(source.includes("totalAsset / totalIncome"), "缺少资产收入比计算");
assert(source.includes("totalDebt / totalIncome"), "缺少负债收入比计算");
assert(source.includes("分母为 0"), "比率计算应处理分母为 0 的场景");
assert(source.includes("占比"), "来源项应展示占比语义");
assert(source.includes("return item.assetName ||"), "总资产细项应优先展示 assetName");
assert(source.includes("return item.debtName ||"), "总负债细项应优先展示 debtName");

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