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

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

[
  'from "@/api/ccdiEnterpriseBaseInfo"',
  'from "@/api/ccdiEnum"',
  "enterpriseDetailOpen",
  "enterpriseDetailLoading",
  "enterpriseDetailData",
  "handleSupplierEnterpriseDetail(row)",
  "resetEnterpriseDetail()",
  "暂无企业信息"
].forEach((token) => {
  assert(source.includes(token), `招投标供应商企业详情缺少关键结构: ${token}`);
});

[
  'label="操作"',
  ">详情</el-button>",
  "企业信息详情",
  "统一社会信用代码",
  "企业名称",
  "企业类型",
  "企业性质",
  "行业分类",
  "所属行业",
  "法定代表人",
  "风险等级",
  "企业来源",
  "数据来源",
  "股东5"
].forEach((token) => {
  assert(source.includes(token), `招投标供应商企业详情模板缺少关键结构: ${token}`);
});

[
  "v-hasPermi=\\\"['ccdi:enterpriseBaseInfo:query']\\\"",
  "v-hasPermi=\"['ccdi:enterpriseBaseInfo:query']\"",
  "ccdi:enterpriseBaseInfo:query"
].forEach((token) => {
  assert(!source.includes(token), `本次不应新增实体库权限显隐控制: ${token}`);
});

console.log("purchase-transaction-enterprise-detail-ui test passed");
