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

const sectionSource = fs.readFileSync(
  path.resolve(__dirname, "../../src/views/ccdiProject/components/detail/ExtendedQuerySection.vue"),
  "utf8"
);
const purchaseDialogSource = fs.readFileSync(
  path.resolve(__dirname, "../../src/views/ccdiProject/components/detail/ExtendedPurchaseDetailDialog.vue"),
  "utf8"
);
const recruitmentDialogSource = fs.readFileSync(
  path.resolve(__dirname, "../../src/views/ccdiProject/components/detail/ExtendedRecruitmentDetailDialog.vue"),
  "utf8"
);
const transferDialogSource = fs.readFileSync(
  path.resolve(__dirname, "../../src/views/ccdiProject/components/detail/ExtendedTransferDetailDialog.vue"),
  "utf8"
);

assert(sectionSource.includes("getExtendedPurchaseDetail"), "缺少采购详情接口调用");
assert(sectionSource.includes("getExtendedRecruitmentDetail"), "缺少招聘详情接口调用");
assert(sectionSource.includes("getExtendedTransferDetail"), "缺少调动详情接口调用");
assert(sectionSource.includes("extended-purchase-detail-dialog"), "缺少采购详情弹窗挂载");
assert(sectionSource.includes("extended-recruitment-detail-dialog"), "缺少招聘详情弹窗挂载");
assert(sectionSource.includes("extended-transfer-detail-dialog"), "缺少调动详情弹窗挂载");
assert(sectionSource.includes("详情加载失败"), "详情查询失败时应提示错误");

[
  "基本信息",
  "数量与金额",
  "供应商信息",
  "日期信息",
  "申请人信息",
  "采购负责人信息",
  "审计信息",
].forEach((token) => assert(purchaseDialogSource.includes(token), token));

[
  "招聘项目信息",
  "职位信息",
  "候选人信息",
  "录用信息",
  "面试官信息",
  "审计信息",
].forEach((token) => assert(recruitmentDialogSource.includes(token), token));

[
  "基本信息",
  "调动前信息",
  "调动后信息",
  "审计信息",
].forEach((token) => assert(transferDialogSource.includes(token), token));
