import { test, expect } from "@playwright/test";
import { USERS, login } from "./helpers";

/**
 * Foundation check: the staging instance is reachable and every seeded test user
 * can authenticate with the credentials provider. If this fails, none of the
 * per-issue specs can run — fix the seed (prisma/seed-test-users.ts) or the tunnel.
 */
test.describe("staging smoke", () => {
  test("login page renders the staging build", async ({ page }) => {
    await page.goto("/login");
    await expect(page.getByLabel(/email address/i)).toBeVisible();
    await expect(page.getByRole("button", { name: "Sign in", exact: true })).toBeVisible();
  });

  for (const [name, creds] of Object.entries(USERS)) {
    test(`seeded user ${name} can log in`, async ({ page }) => {
      await login(page, creds);
      await expect(page).not.toHaveURL(/\/login/);
    });
  }
});
