Skip to content

test(e2e): add a Playwright suite for the v5 admin workstreams - #179

Open
ericwang401 wants to merge 3 commits into
integration/v5-workstreamsfrom
test/e2e-playwright
Open

ericwang401 wants to merge 3 commits into
integration/v5-workstreamsfrom
test/e2e-playwright

Conversation

@ericwang401

Copy link
Copy Markdown
Collaborator

Adds a Playwright end-to-end suite in tests/e2e/ for the PR #168 workstreams that don't need a Proxmox node, plus an e2e CI job.

Stacked on #178. This branch is based on fix/image-definition-bindings, and its catalogue specs read definitions and versions through the routes that PR fixes. Merge #178 first; this diff will then be just the suite.

Running it

Node and the browser both run in the ddev web container, so nothing is installed on the host.

ddev restart                     # picks up Chromium's libraries (webimage_extra_packages)
ddev npm run test:e2e:install    # headless Chromium, kept under node_modules/.cache
ddev npm run test:e2e

The catalogue specs need IMAGE_REGISTRY_URL=http://127.0.0.1:4174/registry.json in .env. The suite serves tests/e2e/fixtures/registry.json there while it runs, so nothing depends on the live CDN. Full details are in the new End-to-end tests (Playwright) section of AGENTS.md.

Fixtures

Global setup runs php artisan db:seed --class=E2eSeeder before every run. It resets:

  • admin@e2e.test (Superadmin), user@e2e.test (no role) and guest@e2e.test (guest), all with password password
  • guest accounts switched off
  • E2E … roles deleted
  • images an earlier run imported or uploaded deleted, and the E2E Uploads image recreated

A run therefore behaves the same on a fresh migrate:fresh as on a reused database. The seeder refuses to run in production.

Specs

Spec Covers
catalogue import once → one version; re-import → created: false, still one version, Import disabled; Windows Server 2025 gets tpm: v2.0
upload a 48 MiB image goes up as 3 PUTs at offsets 0 / 16 / 32 MiB, then finalize; a dropped second chunk shows Resume, which asks the server for its offset (16 MiB) and continues from there
roles the superadmin creates a limited role in the UI and assigns it; the user sees only Dashboard / Images / Users / Roles, gets 403 from nodes, locations, servers, settings and image-group writes, and can't author roles (no button; API 403 "Only a full administrator can author roles."); taking the role away keeps them out of /admin
guests a guest can't sign in while the switch is off; turning it off makes a signed-in guest's requests 403 and the app drops them to /auth/login; standard accounts are unaffected
live/live-node tagged @live: a node smoke check, plus fixme stubs for adoption, migration and sharing; skips unless PROXMOX_FQDN, PROXMOX_TOKEN_ID and PROXMOX_TOKEN_SECRET are in the runner's environment

Other changes

  • npm run tc also typechecks tests/e2e (its own tsconfig.json; adds @types/node).
  • The specs share one database and one global guest switch, so they run with one worker.

Verified

Against a fresh migrate:fresh in ddev, run repeatedly: 16 passed, 4 @live skipped. Also run over plain HTTP against php artisan serve inside the container, which is how the CI job runs. This PR's CI run is that job's first run on GitHub Actions.

…lations

The admin API is registered with scopeBindings(), which resolves a child
route parameter through a parent relation named after it: `{image_definition}`
under `{image_group}` through ImageGroup::imageDefinitions(), and
`{image_version}` under `{image_definition}` through
ImageDefinition::imageVersions(). Neither exists -- the relations are
definitions() and versions() -- so every route below
/image-groups/{group}/images/{definition} answered 500, taking the Versions
dialog, image edit and version publishing with it.

Map those two parameters onto the existing relations, and cover the routes
over HTTP, including a child requested under the wrong parent still 404ing.
Runs inside the ddev web container (`ddev npm run test:e2e`), with headless
Chromium's libraries added to the web image and the browser kept under
node_modules/.cache. Global setup seeds E2eSeeder, which resets a superadmin,
a plain user and a guest, and clears what earlier runs imported or uploaded,
so a run works the same on a fresh migrate as on a reused database.

Covers, without a Proxmox node:
- catalogue import from a local registry.json fixture served on :4174
  (one version per import, re-import adds nothing, Windows Server 2025 gets
  a v2.0 TPM)
- chunked upload of a 48 MiB image in three chunks, and resuming an
  interrupted one from the server's offset
- a limited admin role: only its nav items, 403s elsewhere, and no role
  authoring for a non-superadmin
- the guest-accounts switch locking out a signed-in guest

Live-node specs (adoption, migration, sharing) are tagged @LiVe and skip
without PROXMOX_* in the runner's environment. A new `e2e` CI job runs the
rest against `php artisan serve`.
.env.ci ends without a newline, so echoing IMAGE_REGISTRY_URL onto the copied
file joined it to PHP_XDEBUG_MODE and Dotenv refused to parse it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant