import { expect, test } from "@playwright/test";
import {
  createCase,
  openCaseOnStep,
  sendChat,
  sendMany,
  STEP_SCRIPT,
} from "./helpers";

test("step 0 Lead intake: new case is missing name and state", async ({ request, page }) => {
  const c = await createCase(request);
  expect(c.process.step).toBe(0);
  expect(c.process.missingRequired).toEqual(expect.arrayContaining(["name_or_phone", "state"]));

  const named = await sendChat(request, c.caseId, STEP_SCRIPT.name);
  expect(named.profile.name).toBe("Pat Lee");
  expect(named.process.step).toBe(0);
  expect(named.process.missingRequired).toEqual(expect.arrayContaining(["state"]));

  await openCaseOnStep(page, named.caseId);
  await expect(page.getByTestId("process-current")).toHaveText("Lead intake");
  await expect(page.getByTestId("process-exit-gate")).toContainText("Contactable person + state");
  await expect(page.getByText("0. Lead intake")).toBeVisible();
});
