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

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

assert(source.includes('label="异常标签"'), "列表应新增异常标签列");
assert(source.includes("scope.row.hitTags"), "异常标签列应读取当前行的 hitTags");
assert(
  source.includes('v-for="(tag, index) in scope.row.hitTags"'),
  "异常标签列应逐个渲染命中标签"
);
assert(source.includes("tag.ruleName"), "异常标签列应展示标签名称");

const amountColumnIndex = source.indexOf('label="交易金额"');
const hitTagColumnIndex = source.indexOf('label="异常标签"');
assert.notStrictEqual(amountColumnIndex, -1, "列表应保留交易金额列");
assert.notStrictEqual(hitTagColumnIndex, -1, "列表应保留异常标签列");
assert(
  amountColumnIndex < hitTagColumnIndex,
  "流水明细查询列表中交易金额列应展示在异常标签列前面"
);
assert(
  source.includes('label="摘要 / 交易类型" min-width="200"'),
  "流水明细查询摘要列不应占用过宽"
);
assert(
  source.includes('width="120"') && source.includes('label="异常标签" min-width="220"'),
  "流水明细查询金额列和异常标签列应保持紧凑宽度"
);

console.log("detail-query-hit-tags-list test passed");
