import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";

const viewPath = path.resolve("src/views/PurchaseOrderView.vue");
const source = fs.readFileSync(viewPath, "utf8");

assert.match(
  source,
  /function\s+formatMaterialOptionLabel\s*\(\s*material\s*,\s*item\s*\)/,
  "purchase order view should format material dropdown option labels through a helper"
);

assert.match(
  source,
  /formatMaterialOptionLabel\(material,\s*item\)/,
  "purchase order material dropdown should use the formatted label"
);

assert.match(
  source,
  /form\.target_warehouse_type\s*!==\s*"AUX"[\s\S]*性能要求：\$\{performance\}/,
  "raw-material purchase option labels should append the performance requirement at the end"
);

assert.match(
  source,
  /materialPerformanceRequirement\(material\)/,
  "material option label should read performance requirement from the material master data"
);

console.log("purchase order material option performance checks passed");
