// tests/mobile-admin/orders-visual.spec.ts
import { test, expect } from "@playwright/test";

test.use({ viewport: { width: 390, height: 844 } }); // iPhone 13

test.beforeEach(async ({ page }) => {
  // Sign in as a test admin (requires the seed admin from db/seed.ts).
  await page.goto("/login");
  await page.fill('input[name="email"]', "test-admin@example.com");
  await page.fill('input[name="password"]', "test-password");
  await page.click('button[type="submit"]');
  await page.waitForURL(/\/admin/);
});

test("orders list — iPhone 13", async ({ page }) => {
  await page.goto("/admin/v2/orders");
  await page.waitForLoadState("networkidle");
  await expect(page).toHaveScreenshot("orders-list-iphone13.png", {
    fullPage: true,
    maxDiffPixels: 200,
  });
});

test("order detail — iPhone 13", async ({ page }) => {
  await page.goto("/admin/v2/orders");
  const firstOrder = page.locator('a[href*="/admin/v2/orders/"]').first();
  await firstOrder.click();
  await page.waitForLoadState("networkidle");
  await expect(page).toHaveScreenshot("order-detail-iphone13.png", {
    fullPage: true,
    maxDiffPixels: 200,
  });
});
