Implement integration tests with Playwright

This commit is contained in:
Hördle Bot
2025-12-06 18:31:40 +01:00
parent 2e1f1e599b
commit 4b4468deeb
9 changed files with 267 additions and 7 deletions

31
tests/gameplay.spec.ts Normal file
View File

@@ -0,0 +1,31 @@
import { test, expect } from '@playwright/test';
test.describe('Gameplay', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('Game loads correctly', async ({ page }) => {
await expect(page.locator('h1')).toBeVisible(); // Logo or main header
await expect(page.getByRole('button', { name: 'Start' })).toBeVisible();
});
test('Can play audio', async ({ page }) => {
const startButton = page.getByRole('button', { name: 'Start' });
await startButton.click({ force: true });
// In CI/Headless, audio might not play, so button might not change to "Skip".
// We check that the button is still there and interactive, or changed.
await expect(page.getByRole('button', { name: /Start|Skip/ })).toBeVisible();
});
test('Can submit a guess', async ({ page }) => {
const input = page.getByPlaceholder(/guess/i);
await expect(input).toBeVisible();
await input.fill('Test Song');
await page.keyboard.press('Enter');
// Expect input to be cleared after submission
await expect(input).toHaveValue('');
});
});