Up[date snapshots and generation
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful

This commit is contained in:
2026-02-01 15:15:18 -03:00
parent 0266d472d9
commit 3a940e9da1
6 changed files with 68 additions and 46 deletions

View File

@@ -33,7 +33,7 @@ This project uses **pnpm** as the package manager. After cloning, run `pnpm inst
| `pnpm run preview` | Serve `dist/` (Critters-processed) at http://localhost:4173 — same as deployed |
| `pnpm test` | Run unit tests (Vitest) |
| `pnpm run test:e2e` | Run Playwright visual regression (e2e) |
| `pnpm run test:e2e:update-snapshots` | Regenerate e2e snapshots in CI Docker image (see below) |
| `pnpm run test:e2e:update-snapshots` | Regenerate e2e snapshots (in devcontainer = CI; see Visual regression) |
| `pnpm run lint` | ESLint (JS/TS/Svelte) |
| `pnpm run lint:css` | Stylelint (global CSS + Svelte styles) |
| `pnpm run format` | Prettier (JS/TS/Svelte/CSS/JSON) |
@@ -61,11 +61,11 @@ Preview uses `serve dist` so you see the same HTML/CSS as in production (includi
### Option 3: Dev Container
Open the project in a dev container for a consistent local environment:
Open the project in a dev container for a consistent local environment. The devcontainer uses the **same image as CI** (`mcr.microsoft.com/playwright:v1.58.0-noble`), so e2e snapshots generated inside it match CI.
1. **Open in Cursor or VS Code** with the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension installed.
2. **Reopen in Container**: Command Palette (`Cmd/Ctrl+Shift+P`) → **Dev Containers: Reopen in Container**.
3. Wait for the container to build and start.
3. Wait for the container to build and start. (If you already had a devcontainer open, use **Rebuild Container** once to pick up the Playwright Noble image.)
**Inside the container**, run:
@@ -74,21 +74,21 @@ pnpm install
pnpm run dev
```
The site is served at **http://localhost:5173** (or the port shown) with live reload (port forwarded automatically).
The site is served at **http://localhost:5173** (or the port shown) with live reload (port forwarded automatically). Run `pnpm run test:e2e:update-snapshots` here to regenerate the Linux snapshot when the layout changes.
### Visual regression (e2e)
E2e tests use Playwright and compare full-page screenshots to committed snapshots. CI runs in `mcr.microsoft.com/playwright:v1.58.0-noble`; the **Linux** snapshot (`home-chromium-linux.png`) must be generated in that same environment or CI will fail (e.g. different height due to font/layout rendering).
E2e tests use Playwright and compare full-page screenshots to committed snapshots. CI and the **devcontainer** both use `mcr.microsoft.com/playwright:v1.58.0-noble`, so snapshots generated in the devcontainer match CI.
If CI fails with a snapshot mismatch (e.g. "Expected 1280×5985px, received 1280×5782px"):
**To update the Linux snapshot locally (devcontainer):**
1. Regenerate the Linux snapshot in the CI Docker image:
```bash
pnpm run test:e2e:update-snapshots
```
2. Commit the updated file(s) under `tests/visual.spec.ts-snapshots/`.
1. Rebuild the devcontainer once (so it uses the Playwright Noble image; see Option 3 below).
2. Run `pnpm run test:e2e:update-snapshots` (no Docker needed — same environment as CI).
3. Commit the updated file(s) under `tests/visual.spec.ts-snapshots/`.
Local `pnpm run test:e2e` uses the **Darwin** snapshot on macOS; the Linux snapshot is only used in CI.
**If youre not using the devcontainer:** run the **update-e2e-snapshots** workflow manually in Woodpecker (requires a `git_push_token` secret), or run `pnpm run test:e2e:update-snapshots` on a host with Docker.
Local `pnpm run test:e2e` on **macOS** uses the Darwin snapshot; the Linux snapshot is used in CI and in the devcontainer.
### Option 4: Docker (Production-like Test)
@@ -178,6 +178,7 @@ Navigate to your repository → Settings → Secrets and add:
| `deploy_username` | SSH username | `deploy` or `root` |
| `deploy_ssh_key` | Private SSH key (multi-line) | `-----BEGIN OPENSSH PRIVATE KEY-----...` |
| `deploy_port` | SSH port | `22` (default) |
| `git_push_token` | *(Optional)* Repo push token for manual **update-e2e-snapshots** workflow (fallback when not using devcontainer) | Gitea/Forgejo personal access token |
**Generate SSH key for deployment:**