Implement integration tests with Playwright
This commit is contained in:
31
tests/gameplay.spec.ts
Normal file
31
tests/gameplay.spec.ts
Normal 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('');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user