import { test, expect } from '@playwright/test'; test.describe('2048 Game - Visual Tests & Screenshots', () => { test.beforeEach(async ({ page }) => { await page.goto('/'); await page.waitForLoadState('networkidle'); }); test('should match initial game state screenshot', async ({ page }) => { // Wait for game to fully load await page.waitForSelector('.tile', { timeout: 5000 }); // Take screenshot of initial game state await expect(page).toHaveScreenshot('initial-game-state.png', { fullPage: true, animations: 'disabled' }); }); test('should match game container layout', async ({ page }) => { const gameContainer = page.locator('.game-container'); await expect(gameContainer).toHaveScreenshot('game-container.png', { animations: 'disabled' }); }); test('should match header with scores', async ({ page }) => { const header = page.locator('.header'); await expect(header).toHaveScreenshot('header-scores.png', { animations: 'disabled' }); }); test('should match environment badge', async ({ page }) => { const envBadge = page.locator('#env-badge'); await expect(envBadge).toHaveScreenshot('environment-badge.png', { animations: 'disabled' }); }); test('should display correctly on mobile', async ({ page, isMobile }) => { test.skip(!isMobile, 'Mobile test only'); await expect(page).toHaveScreenshot('mobile-game.png', { fullPage: true, animations: 'disabled' }); }); test('should show game over state', async ({ page }) => { // Try to fill the board quickly (this is a simplified approach) // In a real scenario, we might need to manipulate the game state directly // Take screenshot of current state for comparison await expect(page).toHaveScreenshot('game-in-progress.png', { fullPage: true, animations: 'disabled' }); }); });