mirror of
https://github.com/ghndrx/k8s-game-2048.git
synced 2026-02-10 06:45:07 +00:00
- Add Playwright configuration with multi-browser testing - Create basic functionality tests for game mechanics - Add gameplay tests with keyboard and touch interactions - Implement visual regression testing with screenshots - Add environment-specific tests for dev/staging/prod - Include health endpoint and security header validation - Set up test infrastructure for CI/CD pipeline
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
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'
|
|
});
|
|
});
|
|
});
|