This commit is contained in:
parent
05c8a39bd8
commit
c40c5d97db
74 changed files with 863 additions and 669 deletions
|
|
@ -1,7 +1,12 @@
|
|||
import { expect, test, type Page } from '@playwright/test';
|
||||
import { test as base, expect, type Page } from '@playwright/test';
|
||||
|
||||
const canvasName = 'Interactive generative garden canvas';
|
||||
|
||||
interface BrowserDiagnostics {
|
||||
browserFailures: Array<string>;
|
||||
consoleErrors: Array<string>;
|
||||
}
|
||||
|
||||
const isLocalUrl = (url: string) => {
|
||||
const { hostname } = new URL(url);
|
||||
return hostname === '127.0.0.1' || hostname === 'localhost';
|
||||
|
|
@ -29,6 +34,27 @@ const collectLocalBrowserFailures = (page: Page) => {
|
|||
return failures;
|
||||
};
|
||||
|
||||
const test = base.extend<{ browserDiagnostics: BrowserDiagnostics }>({
|
||||
browserDiagnostics: [
|
||||
async ({ page }, use) => {
|
||||
const browserFailures = collectLocalBrowserFailures(page);
|
||||
const consoleErrors: Array<string> = [];
|
||||
|
||||
page.on('console', (message) => {
|
||||
if (message.type() === 'error') {
|
||||
consoleErrors.push(message.text());
|
||||
}
|
||||
});
|
||||
|
||||
await use({ browserFailures, consoleErrors });
|
||||
|
||||
expect(consoleErrors).toEqual([]);
|
||||
expect(browserFailures).toEqual([]);
|
||||
},
|
||||
{ auto: true },
|
||||
],
|
||||
});
|
||||
|
||||
const disableWebGpu = async (page: Page) => {
|
||||
await page.addInitScript(() => {
|
||||
Object.defineProperty(navigator, 'gpu', {
|
||||
|
|
@ -39,14 +65,6 @@ const disableWebGpu = async (page: Page) => {
|
|||
};
|
||||
|
||||
test('starts the WebGPU garden and accepts drawing input', async ({ page }) => {
|
||||
const browserFailures = collectLocalBrowserFailures(page);
|
||||
const consoleErrors: Array<string> = [];
|
||||
page.on('console', (message) => {
|
||||
if (message.type() === 'error') {
|
||||
consoleErrors.push(message.text());
|
||||
}
|
||||
});
|
||||
|
||||
await page.addInitScript((expectedCanvasName) => {
|
||||
const captureState = { count: 0 };
|
||||
Object.defineProperty(window, '__fleetingGardenPointerCaptures', {
|
||||
|
|
@ -68,7 +86,7 @@ test('starts the WebGPU garden and accepts drawing input', async ({ page }) => {
|
|||
}, canvasName);
|
||||
|
||||
await page.goto('/');
|
||||
const startButton = page.getByRole('button', { name: 'Start' });
|
||||
const startButton = page.getByRole('button', { exact: true, name: 'Start' });
|
||||
await expect(startButton).toBeVisible();
|
||||
await expect(startButton).toBeEnabled({ timeout: 30_000 });
|
||||
await page.keyboard.press('Enter');
|
||||
|
|
@ -117,13 +135,21 @@ test('starts the WebGPU garden and accepts drawing input', async ({ page }) => {
|
|||
)
|
||||
.toBeGreaterThan(0);
|
||||
|
||||
expect(consoleErrors).toEqual([]);
|
||||
expect(browserFailures).toEqual([]);
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(
|
||||
() =>
|
||||
(
|
||||
window as unknown as {
|
||||
__fleetingGardenBrushPasses?: number;
|
||||
}
|
||||
).__fleetingGardenBrushPasses ?? 0
|
||||
)
|
||||
)
|
||||
.toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('shows a clear fallback when WebGPU is unavailable', async ({ page }) => {
|
||||
const browserFailures = collectLocalBrowserFailures(page);
|
||||
|
||||
await disableWebGpu(page);
|
||||
await page.goto('/');
|
||||
|
||||
|
|
@ -135,23 +161,19 @@ test('shows a clear fallback when WebGPU is unavailable', async ({ page }) => {
|
|||
const fallback = page.getByRole('alert');
|
||||
await expect(fallback).toContainText('Fleeting Garden needs WebGPU');
|
||||
await expect(fallback).toContainText('webgpu-unsupported');
|
||||
expect(browserFailures).toEqual([]);
|
||||
});
|
||||
|
||||
test('syncs the selected vibe with the URI', async ({ page }) => {
|
||||
const browserFailures = collectLocalBrowserFailures(page);
|
||||
|
||||
await disableWebGpu(page);
|
||||
await page.goto('/?vibe=Bone%20Archive');
|
||||
await page.goto('/?vibe=Aurora%20Mycelium');
|
||||
|
||||
await expect(page).toHaveURL(/vibe=bone-archive/);
|
||||
await expect(page).toHaveURL(/vibe=aurora-mycelium/);
|
||||
|
||||
await page.getByRole('button', { name: 'Next vibe' }).click();
|
||||
await expect(page).toHaveURL(/vibe=pelagic-caustics/);
|
||||
await expect(page).toHaveURL(/vibe=velvet-observatory/);
|
||||
|
||||
await page.goBack();
|
||||
await expect(page).toHaveURL(/vibe=bone-archive/);
|
||||
expect(browserFailures).toEqual([]);
|
||||
await expect(page).toHaveURL(/vibe=aurora-mycelium/);
|
||||
});
|
||||
|
||||
test('keeps audio focus outlines scoped to the active control', async ({ page }) => {
|
||||
|
|
@ -194,7 +216,7 @@ test('keeps the config overlay scrollable and dismissible on mobile', async ({
|
|||
await page.setViewportSize({ width: 390, height: 640 });
|
||||
await page.goto('/');
|
||||
|
||||
const startButton = page.getByRole('button', { name: 'Start' });
|
||||
const startButton = page.getByRole('button', { exact: true, name: 'Start' });
|
||||
await expect(startButton).toBeEnabled({ timeout: 30_000 });
|
||||
await startButton.click();
|
||||
await expect(page.locator('body')).not.toHaveClass(/is-loading/, {
|
||||
|
|
|
|||
Loading…
Reference in a new issue