import { test, expect } from "@playwright/test";
import { products } from "@/lib/site-config";

for (const p of products) {
  test(`/products/${p.slug} renders successfully`, async ({ page }) => {
    const response = await page.goto(p.href);
    expect(response?.status()).toBe(200);

    // At least one h1 should be present on the page.
    await expect(page.getByRole("heading", { level: 1 }).first()).toBeVisible();

    // The product name should appear somewhere on the page (nav, hero, or body).
    await expect(page.getByText(p.name, { exact: false }).first()).toBeVisible();
  });
}
