import assert from "node:assert/strict";
import test from "node:test";
import { parseImportDispoBatchArgs } from "./import-dispo-batch.js";

test("parseImportDispoBatchArgs uses the agreed workbook defaults", () => {
  const options = parseImportDispoBatchArgs([]);

  assert.equal(options.allowTbdUnresolved, true);
  assert.equal(options.importTbdProjects, false);
  assert.equal(options.skipCommit, false);
  assert.equal(options.strictSourceData, false);
  assert.equal(options.previewUnresolvedLimit, 10);
  assert.match(options.referenceWorkbookPath, /MandatoryDispoCategories_V3\.xlsx$/u);
  assert.match(options.planningWorkbookPath, /DISPO_2026\.xlsx$/u);
  assert.match(
    options.chargeabilityWorkbookPath,
    /20260309_Bi-Weekly_Chargeability_Reporting_Content_Production_V0\.943_4Hartmut\.xlsx$/u,
  );
  assert.match(options.rosterWorkbookPath ?? "", /MV_DispoRoster\.xlsx$/u);
  assert.match(
    options.costWorkbookPath ?? "",
    /Resource Roster_MASTER_FY26_CJ_20251201\.xlsx$/u,
  );
});

test("parseImportDispoBatchArgs applies operator overrides", () => {
  const options = parseImportDispoBatchArgs([
    "--planning-workbook",
    "./custom-planning.xlsx",
    "--notes",
    "live test",
    "--preview-unresolved",
    "25",
    "--skip-commit",
    "--strict-source-data",
    "--disallow-tbd",
    "--import-tbd-projects",
    "--no-roster",
    "--no-cost",
  ]);

  assert.match(options.planningWorkbookPath, /custom-planning\.xlsx$/u);
  assert.equal(options.notes, "live test");
  assert.equal(options.previewUnresolvedLimit, 25);
  assert.equal(options.skipCommit, true);
  assert.equal(options.strictSourceData, true);
  assert.equal(options.allowTbdUnresolved, false);
  assert.equal(options.importTbdProjects, true);
  assert.equal(options.rosterWorkbookPath, undefined);
  assert.equal(options.costWorkbookPath, undefined);
});
