1 Commits

Author SHA1 Message Date
Anso 429f780f40 test(stacks): E2E coverage for deploy success, failure, and bulk lifecycle (#1192)
* test(stacks): E2E coverage for deploy success, failure, and bulk lifecycle

Extends e2e coverage per L-2 of the stack-management audit. The
existing stacks.spec.ts only covered create/delete and a double-click
guard - no journey ever exercised real Docker through the deploy
pipeline.

Adds e2e/stack-deploy.spec.ts with three journeys:

1. Deploy success: creates a stack with a real-but-tiny compose file
   (alpine:3 sleep infinity), drives deploy through the authenticated
   browser session, and asserts the /api/stacks/statuses route
   reports the container as 'running' inside 30 seconds. Exercises
   the full middleware chain, ComposeService spawn, Dockerode status
   lookup, and the cache-invalidate path.

2. Deploy failure: creates a stack with intentionally malformed YAML,
   asserts the deploy route rejects with a 4xx/5xx and a parseable
   JSON envelope (no crash, no opaque text), and verifies the
   sidebar still renders the stack after reload.

3. Bulk lifecycle: creates two stacks, deploys both, then restarts
   both via per-stack POSTs (the path the current frontend bulk hook
   takes; once H-3 lands the hook fans out through the new bulk
   endpoint but the user-visible outcome is identical). Asserts both
   restarts return 200.

Disconnect-mid-deploy journey is deferred (depends on M-1 WS
reconnect). Rollback-after-failed-atomic-deploy is deferred (needs a
paid-tier license that the default e2e setup does not seed).
File-explorer journeys (upload/edit/delete) are tracked separately
to keep this spec focused on lifecycle operations.

Test design notes:
- Drives deploy through page.evaluate + fetch rather than UI buttons
  to stay resilient to editor-button label churn. Auth surface is
  still real (cookies, middleware chain, audit log) - only the click
  is bypassed. The audit's "exercise real Docker via Playwright"
  intent is satisfied.
- Each test calls teardownStack in a finally block so a failed test
  cannot strand a real container on the CI runner.
- Uses alpine:3 (smallest viable long-running image) to keep CI pull
  cost minimal. The image is shared across tests so registry pull
  amortizes after the first.

* test(stacks): bump E2E timeouts and parallelize bulk deploy

CI hit the default 30s per-test timeout on the bulk lifecycle test
because two serial deploys against a cold runner spent most of the
budget on the alpine pull. The deploy-success test passed the prior
run but had only ~0-5s of headroom outside its 30s status poll, so it
was a flake away from the same fate.

- bulk lifecycle: deploy both stacks in parallel (shared pull cache)
  and bump the per-test timeout to 90s.
- deploy success: bump per-test timeout to 60s so the 30s status poll
  is not racing setup and teardown.

The deploy failure test does no image pull (broken YAML rejects
upstream) so it keeps the default 30s.
2026-05-24 15:57:12 -04:00