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

const root = process.cwd();
const source = readFileSync(path.join(root, "src/views/OperationReportView.vue"), "utf8");

assert.match(source, /RECENT_REPORT_DAYS\s*=\s*15/, "operation reports should default to recent 15 days");
assert.match(source, /buildDefaultReportDateRange/, "operation reports should centralize default date range");
assert.match(source, /reportDateFilters/, "operation reports should keep user date filter state");
assert.match(source, /v-model="reportDateFilters\.start_date"/, "operation report page should expose start date picker");
assert.match(source, /v-model="reportDateFilters\.end_date"/, "operation report page should expose end date picker");
assert.match(source, /params\.set\("start_date", reportDateFilters\.start_date\)/, "operation report request should send start_date");
assert.match(source, /params\.set\("end_date", reportDateFilters\.end_date\)/, "operation report request should send end_date");
assert.match(source, /\/production\/miniapp-operation-reports\?\$\{params\.toString\(\)\}/, "operation report request should use query params");
assert.match(source, /最近15天/, "operation report UI should explain the default date range");
assert.match(source, /开始日期不能晚于结束日期/, "operation report page should reject invalid date ranges before requesting");
assert.match(source, /sync_to_erp:\s*"false"/, "operation report refresh should be read-only by default");
assert.doesNotMatch(source, /sync_to_erp:\s*"true"/, "operation report refresh must not sync ERP implicitly");

console.log("operation report date filter checks passed");
