diff --git a/playwright.config.js b/playwright.config.js new file mode 100644 index 0000000..b910f08 --- /dev/null +++ b/playwright.config.js @@ -0,0 +1,34 @@ +/** + * Playwright Configuration for Railtrack Pro + * E2E testing with video recording + */ +const { defineConfig, devices } = require('@playwright/test'); + +module.exports = defineConfig({ + testDir: './test/e2e', + fullyParallel: true, + forbidOnly: !!process.env.CI, + retries: process.env.CI ? 2 : 0, + workers: process.env.CI ? 1 : undefined, + reporter: 'html', + use: { + baseURL: 'http://localhost:8080', + trace: 'on-first-retry', + screenshot: 'only-on-failure', + video: 'on-first-retry' + }, + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] } + }, + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] } + }, + { + name: 'webkit', + use: { ...devices['Desktop Safari'] } + } + ] +}); diff --git a/test/e2e/railtrack.spec.js b/test/e2e/railtrack.spec.js new file mode 100644 index 0000000..f6061d4 --- /dev/null +++ b/test/e2e/railtrack.spec.js @@ -0,0 +1,41 @@ +/** + * Playwright E2E Tests for Railtrack Pro + * Tests core game functionality with video recording on failure + */ +const { test, expect } = require('@playwright/test'); + +test.describe('Railtrack Pro E2E Tests', () => { + + test.beforeEach(async ({ page }) => { + await page.goto('http://localhost:8080'); + }); + + test.afterEach(async ({ page }) => { + await page.close(); + }); + + test('should load game page successfully', async ({ page }) => { + await expect(page).toHaveTitle(/Railtrack Pro/i); + }); + + test('should render Three.js canvas', async ({ page }) => { + const canvas = page.locator('canvas'); + await expect(canvas).toBeVisible(); + }); + + test('should initialize game world', async ({ page }) => { + await page.waitForTimeout(2000); + const canvas = page.locator('canvas'); + const rect = await canvas.boundingBox(); + expect(rect).toBeTruthy(); + }); + + test('should respond to mouse interactions', async ({ page }) => { + await page.waitForTimeout(2000); + const canvas = page.locator('canvas'); + await canvas.hover(); + console.log('Mouse interaction successful'); + }); + +}); +console.log('Playwright E2E test file created successfully');