import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' import { expect, type Locator, type Page } from '@playwright/test' const here = dirname(fileURLToPath(import.meta.url)) /** Where `screenshot()` drops PNGs — gitignored, readable for visual review. */ const SCREENS_DIR = join(here, '..', '.artifacts', 'screens') /** * Page Object over the CommiTea app shell. As real screens land (P3), add * per-screen page objects and accessor methods here; keep locators * user-facing (getByRole/getByText), never CSS/DOM structure. */ export class AppPage { constructor(readonly page: Page) {} get heading(): Locator { return this.page.getByRole('heading', { name: 'CommiTea' }) } /** Assert the shell has rendered. */ async expectLoaded(): Promise { await expect(this.heading).toBeVisible() } /** Read the `commitea` preload API surface from the renderer. */ async preloadApi(): Promise | undefined> { return this.page.evaluate( () => (globalThis as unknown as { commitea?: Record }).commitea, ) } /** Capture a full-page screenshot for visual review; returns the path. */ async screenshot(name: string): Promise { const path = join(SCREENS_DIR, `${name}.png`) await this.page.screenshot({ path, fullPage: true }) return path } }