import { expect, test } from "@playwright/experimental-ct-react"; import { SpotlightSearchVisualFixture as VisualFixture } from "../../apps/web/app/components/ui/commandPalettes/spotlight-search.visual-fixture"; const DIALOG_ID = "ui.surface.commandPalette.portal"; const SEARCH_ID = "ui.surface.commandPalette.search"; const RESULT_ID = "ui.surface.commandPalette.result.project.project1"; test.describe("R-P11a Spotlight interim UI pixel baseline", () => { test("desktop modal stays visually stable", async ({ mount, page }) => { await mount(); await prepareReadyResults(page); const dialog = page.locator(`[data-ui-id="${DIALOG_ID}"]`); await expect(dialog).toBeVisible(); const viewport = page.viewportSize(); const box = await dialog.boundingBox(); expect(viewport).not.toBeNull(); expect(box).not.toBeNull(); expect(Math.abs(box!.x - (viewport!.width - box!.width) / 2)).toBeLessThan(1); expect(box!.x).toBeGreaterThanOrEqual(0); expect(box!.y).toBeGreaterThanOrEqual(0); await expect(dialog).toHaveScreenshot("r-p11a-spotlight-desktop.png"); }); test("mobile viewport overlay stays visually stable", async ({ mount, page }) => { await page.setViewportSize({ width: 390, height: 844 }); await mount(); await prepareReadyResults(page); const dialog = page.locator(`[data-ui-id="${DIALOG_ID}"]`); await expect(dialog).toBeVisible(); await expect(dialog).toHaveCSS("height", "844px"); await expect(dialog).toHaveCSS("width", "390px"); expect(await dialog.boundingBox()).toEqual({ x: 0, y: 0, width: 390, height: 844 }); await expect(dialog).toHaveScreenshot("r-p11a-spotlight-mobile.png"); }); }); async function prepareReadyResults(page: import("@playwright/test").Page) { await page.evaluate(async () => { await document.fonts.ready; }); await page.locator(`[data-ui-id="${SEARCH_ID}"]`).fill("solar"); await expect(page.locator(`[data-ui-id="${RESULT_ID}"]`)).toBeVisible(); }