diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index b50603f..93748c6 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -27,17 +27,33 @@ jobs: - name: Install dependencies run: npm ci + - name: Install Playwright browsers + run: npx playwright install --with-deps chromium + - name: Lint run: npm run lint - name: Typecheck run: npm run typecheck + - name: Typecheck browser tests + run: npm run typecheck:e2e + - name: Test run: npm test - - name: Build - run: npm run build + - name: Browser tests + run: npm run test:e2e + + - name: Upload Playwright report + if: failure() + uses: actions/upload-artifact@v4 + with: + name: playwright-report + path: | + playwright-report/ + test-results/ + retention-days: 7 - name: Copy build to host pages mount if: github.event_name == 'push' && github.ref == 'refs/heads/main' diff --git a/.gitignore b/.gitignore index 14d1e17..916a63e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ ts-node--*/ rss.xml dist +playwright-report +test-results # Logs logs diff --git a/README.md b/README.md index 56bf279..1a7466c 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,10 @@ draw persistent coloured paths, spawn agents from those strokes, erase locally, and export the scene as a 4K wallpaper. Check out the [agent logic](./src/pipelines/agents/agent.wgsl). + +## Testing + +- `npm test` runs the Vitest unit suite. +- `npm run test:e2e` builds the production bundle and runs the Playwright Chromium + smoke test. +- `npx playwright install chromium` installs the local browser binary when needed. diff --git a/e2e/app.spec.ts b/e2e/app.spec.ts new file mode 100644 index 0000000..e42de2f --- /dev/null +++ b/e2e/app.spec.ts @@ -0,0 +1,23 @@ +import { expect, test } from '@playwright/test'; + +test('loads the app shell and WebGPU fallback in Chromium', async ({ page }) => { + await page.addInitScript(() => { + Object.defineProperty(navigator, 'gpu', { + configurable: true, + value: undefined, + }); + }); + + await page.goto('/'); + + await expect(page).toHaveTitle('Fleeting Garden'); + await expect( + page.getByRole('img', { name: 'Interactive generative garden canvas' }) + ).toBeVisible(); + await expect(page.getByRole('toolbar', { name: 'Garden toolbar' })).toBeVisible(); + await expect(page.locator('body')).not.toHaveClass(/is-loading/); + await expect(page.getByRole('alert')).toContainText('Fleeting Garden needs WebGPU'); + + await page.getByRole('button', { name: 'About' }).click(); + await expect(page.getByRole('heading', { name: 'Fleeting Garden' })).toBeVisible(); +}); diff --git a/index.html b/index.html index 8db16b3..1957196 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" /> - + Fleeting Garden - +