import { expect } from "e2e";
import { test, WEB } from "./t3.ts";

test("A mapping-only price row asks for its missing model ID", WEB, async ({ t3, app, screen }) => {
  await t3.project("model-price-validation");
  await t3.open("/usage");
  await screen.getByRole("button", "All environments", { exact: true }).tap();
  await screen.getByRole("menuitem", "Model prices", { exact: true }).tap();
  await screen.getByRole("button", "Add model price", { exact: true }).tap();
  await app.screenshot("untouched-price-row");
  await screen.getByRole("combobox", "Map new model to model", { exact: true }).fill("gpt-4o");
  await screen.getByRole("heading", "Custom model prices", { exact: true }).tap();
  await app.screenshot("mapping-only-missing-model-id");
  await expect(screen.getByRole("alert")).toHaveText("Enter a model ID.");
  await expect(screen.getByRole("combobox", "New model ID", { exact: true })).toHaveAttribute("aria-invalid", "true");
  await expect(screen.getByRole("button", "Save changes", { exact: true })).toBeDisabled();
});
