import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { samplePresenceAt, samplePresenceForOfficeAt } from "../adapters/sample.ts";
import FRONTIER_VALLEY from "../offices/frontier-valley.ts";
import LUMBRIDGE_HQ from "../offices/lumbridge-hq.ts";
import MATEO_COURT from "../offices/mateo-court.ts";
import { activityRobotsForOffice } from "../offices/runtime.ts";

describe("office-keyed runtime activity", () => {
  it("authors one deterministic SF robot, two LA robots, and none in a building preview", () => {
    assert.deepEqual(activityRobotsForOffice(LUMBRIDGE_HQ), [
      { id: "sf-studio-activity-01", levelId: "level-1", seed: 0x53464851, jobSet: "studio-support" },
    ]);
    assert.deepEqual(activityRobotsForOffice(MATEO_COURT), [
      { id: "la-office-activity-01", levelId: "level-1", seed: 0x4c414851, jobSet: "office-operations" },
      { id: "la-office-activity-02", levelId: "level-2", seed: 0x4c414852, jobSet: "model-review" },
    ]);
    assert.deepEqual(activityRobotsForOffice(FRONTIER_VALLEY), []);
  });

  it("returns defensive specs and drops a robot when a local pack removes its level", () => {
    const first = activityRobotsForOffice(MATEO_COURT);
    first[0]!.id = "mutated";
    assert.equal(activityRobotsForOffice(MATEO_COURT)[0]?.id, "la-office-activity-01");
    assert.deepEqual(activityRobotsForOffice({ id: MATEO_COURT.id, levels: [MATEO_COURT.levels[0]!] }), [
      { id: "la-office-activity-01", levelId: "level-1", seed: 0x4c414851, jobSet: "office-operations" },
    ]);
  });
});

describe("office-keyed presence fallback", () => {
  const workingHour = new Date(2026, 7, 19, 11, 0, 0);

  it("never fabricates people at either active HQ", () => {
    assert.deepEqual(samplePresenceForOfficeAt("lumbridge-hq", workingHour), []);
    assert.deepEqual(samplePresenceForOfficeAt("mateo-court", workingHour), []);
  });

  it("retains the legacy roster only as an explicit renderer fixture", () => {
    assert.ok(samplePresenceAt(workingHour).length > 0);
  });
});
