// TEMPORARY AUDIT — dump the exact config the UI sends. Delete after use.
import { describe, it } from "vitest";
import { writeFileSync } from "node:fs";
import { useDiagramStore } from "../store/diagramStore";
import { buildScenarioConfig } from "./configBuilder";
import example from "../../public/examples/chiller_r134a_exv_orifice.json";

describe("dump UI config", () => {
  it("writes the full emitted config to target/tmp/ui_emitted_config.json", () => {
    useDiagramStore.getState().loadFromConfig(example);
    const s = useDiagramStore.getState();
    const config = buildScenarioConfig(s.nodes, s.edges, {
      fluid: s.fluid,
      fluidBackend: s.fluidBackend,
      solverStrategy: s.solverStrategy,
      maxIterations: s.maxIterations,
      tolerance: s.tolerance,
      controls: s.controls,
    });
    writeFileSync(
      "../../target/tmp/ui_emitted_config.json",
      JSON.stringify(config, null, 2),
    );
    console.log("strategy:", config.solver.strategy, "| components:", config.circuits[0].components.length);
  });
});
