test: add Playwright E2E test configuration and test files
Railtrack Pro Tests / Code Quality Check (pull_request) Has been cancelled
Railtrack Pro Tests / Code Coverage Check (pull_request) Has been cancelled
Railtrack Pro Tests / Run Test Suite (pull_request) Has been cancelled

This commit is contained in:
Railtrack Pro Dev
2026-03-20 11:12:57 +00:00
parent 7191519b95
commit 3f7237c106
2 changed files with 75 additions and 0 deletions
+34
View File
@@ -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'] }
}
]
});
+41
View File
@@ -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');