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

const source = fs.readFileSync(
  path.resolve(__dirname, "../../src/views/ccdiAccountInfo/index.vue"),
  "utf8"
);

assert(
  source.includes(':xs="24" :sm="12" :md="8" :lg="6" :xl="6"'),
  "账户库查询项应使用响应式列宽"
);

const ownerTypeColumnIndex = source.indexOf('label="所属人类型"');
const staffNameColumnIndex = source.indexOf('label="员工姓名" prop="staffName"');
assert.notStrictEqual(ownerTypeColumnIndex, -1, "账户库列表应保留所属人类型列");
assert.notStrictEqual(staffNameColumnIndex, -1, "账户库列表应保留员工姓名列");
assert(
  ownerTypeColumnIndex < staffNameColumnIndex,
  "账户库列表中所属人类型应展示在员工姓名前面"
);

["员工姓名", "账户姓名", "账户号码"].forEach((label) => {
  const pattern = new RegExp(
    `<el-table-column[^>]*label="${label}"[^>]*show-overflow-tooltip`,
    "m"
  );
  assert(pattern.test(source), `${label}列应使用溢出提示避免撑开表格`);
});

assert(source.includes('width="92%"'), "账户库编辑弹窗应使用自适应宽度");
assert(
  source.includes('custom-class="account-info-dialog"'),
  "账户库编辑弹窗应有独立样式类"
);
assert(
  /::v-deep \.account-info-dialog\s*\{[\s\S]*max-width:\s*1160px;/m.test(source),
  "账户库编辑弹窗大屏应限制最大宽度"
);

console.log("account-info-layout-polish test passed");
