import assert from "node:assert/strict";
import { readFileSync } from "node:fs";

const productSpecSource = readFileSync(new URL("../src/views/ProductSpecLiteView.vue", import.meta.url), "utf8");
const masterDataImportSource = readFileSync(new URL("../src/views/MasterDataImportView.vue", import.meta.url), "utf8");
const masterDataRouteSource = readFileSync(new URL("../../backend/app/api/routes/master_data.py", import.meta.url), "utf8");

assert.doesNotMatch(productSpecSource, />\s*标准工作量\s*</, "产品需规表单不应再展示标准工作量列");
assert.doesNotMatch(
  productSpecSource,
  /v-model\.number="processRow\.standard_workload"/,
  "产品需规表单不应再让用户手填标准工作量"
);
assert.doesNotMatch(
  productSpecSource,
  /processRow\.standard_workload\s*\|\|\s*\(standardBeat > 0 \? 28800 \/ standardBeat : 0\)/,
  "产品需规保存时不应再用手填标准工作量兜底"
);
assert.match(
  productSpecSource,
  /standard_workload:\s*0/,
  "产品需规同步小程序时应保留兼容字段并统一写入 0"
);

assert.doesNotMatch(masterDataImportSource, /标准工作量/, "基础资料导入导出说明不应再提示用户维护标准工作量");
assert.doesNotMatch(
  masterDataRouteSource,
  /"标准工作量":\s*"standard_workload"/,
  "后端导入字段映射不应再接收标准工作量列"
);
assert.doesNotMatch(
  masterDataRouteSource,
  /_import_number\(data\.get\("standard_workload"\)\)/,
  "后端导入不应再读取 Excel 中的标准工作量"
);

console.log("product spec standard workload hidden checks passed");
