E2E Testing Overview¶
CWIQ uses Playwright v1.58.2 for end-to-end testing of the Orchestrator UI. Tests live in
platform/ui/e2e/and run automatically after every successful deployment to DEV.
End-to-end tests verify the UI works correctly from a user's perspective — logging in, navigating pages, submitting forms, and confirming that the frontend and backend integrate correctly. They complement unit and integration tests by exercising the full stack through a real browser.
Test Targets¶
| Environment | URL | When Used |
|---|---|---|
| CI (main branch) | https://orchestrator.dev.cwiq.io |
After every successful deploy-dev |
| Local development | http://localhost:3000 |
When running tests against a local stack |
The target URL is controlled by the PLAYWRIGHT_BASE_URL environment variable. In CI, this is set to the VPC private IP of the DEV server (see CI Integration).
Test Projects¶
Playwright is configured with two test projects to separate authenticated and unauthenticated test scenarios.
| Project | Browser State | Matches |
|---|---|---|
| authenticated | Saved auth state from .auth/admin.json |
All tests by default |
| unauthenticated | Clean session — no cookies, no storage | Files matching */(login\|register\|public).* |
Most tests run under the authenticated project. The global setup script logs in once before the test suite starts and saves the session to .auth/admin.json. Individual tests then reuse that saved state instead of repeating the login flow.
The unauthenticated project deliberately uses a clean browser session. It is the correct context for testing the login page, registration flow, and any public-facing pages that must be accessible without credentials.
Directory Structure¶
platform/ui/e2e/
├── fixtures/ # Test fixtures (auth context, org context, test data factories)
├── helpers/ # API helper functions for setting up test data via HTTP
├── pages/ # Page Object Model classes, one per page or major component
├── specs/ # Test specification files
│ ├── auth/ # Login, logout, session expiry
│ ├── admin/ # Admin panel — user management, org settings
│ ├── workflows/ # Workflow creation, execution, run history
│ └── ...
└── global-setup.ts # Runs once before the entire suite — authenticates and saves state
The specs/ directory mirrors the application's navigation structure. When adding tests for a new feature, create the spec file in the subdirectory that matches the UI section it tests.
How Authentication Works¶
Because most tests require a logged-in user, the test suite avoids repeating the login UI flow for every test. Instead:
global-setup.tsruns once before any test.- It calls the backend login API directly (
POST /api/v1/auth/login). - It constructs a Zustand
persiststorage entry matching the shape the UI stores inlocalStorage. - It saves the result to
.auth/admin.json. - All tests in the
authenticatedproject load that saved state, starting each test already logged in.
sequenceDiagram
participant GS as global-setup.ts
participant API as Backend API
participant FS as .auth/admin.json
participant TEST as Test (authenticated project)
GS->>API: POST /api/v1/auth/login
API-->>GS: access_token + user data
GS->>FS: Write Zustand localStorage state
TEST->>FS: Load saved storage state
TEST-->>TEST: Start test already logged in
ReportPortal Integration¶
Test results from CI runs are sent to ReportPortal in real time during the pipeline.
- Dashboard: https://reportportal.shared.cwiq.io
- Project:
orchestrator_ui
ReportPortal reporting is enabled only when the RP_ENDPOINT environment variable is set. It activates automatically in CI and is silently disabled when running tests locally. See ReportPortal for configuration details.
Pipeline Behaviour¶
The E2E test job runs in the verify stage, after verify-dev confirms the deployment is healthy.
Key pipeline constraints:
- Runs only on the
mainbranch — not on feature branches. allow_failure: true— E2E failures are reported but do not block the pipeline or prevent a green status onmain.- Artifacts (HTML report, screenshots, videos, JUnit XML) are retained for two weeks.
Why allow_failure: true?
E2E tests can be flaky due to timing, network conditions, or test environment state. Setting allow_failure: true prevents intermittent test failures from blocking main. Investigate failures in ReportPortal after each run, but do not treat every E2E failure as a deployment blocker.
Related Documentation¶
- Playwright Setup — Configuration file, global setup, and how to run tests locally
- Page Object Model — How test pages and fixtures are structured
- CI Integration — CI job definition, Vault secrets, and artifacts
- ReportPortal — How to view test results and launch history