Skip to content

[ENHANCEMENT][TESTING][UI]: Improve Playwright test resilience and developer experience #2632

@crivetimihai

Description

@crivetimihai

Summary

Enhance the Playwright UI testing infrastructure to improve test resilience, developer experience, and alignment with the recommended docker-compose testing stack.

Problem

  1. Endpoint mismatch: Default test target (localhost:8000) didn't match the recommended docker-compose nginx endpoint (localhost:8080)
  2. Auth brittleness: Tests failed when admin credentials didn't match the running gateway, with no fallback mechanism
  3. Poor preflight guidance: No validation or guidance before running tests, leading to confusing failures
  4. Test data collisions: Hardcoded server names caused conflicts when tests ran multiple times
  5. Missing artifact capture: No always-on screenshot/video targets for debugging intermittent failures

Changes

Configuration & Defaults

  • Default TEST_BASE_URL changed from localhost:8000 to localhost:8080 (docker-compose nginx)
  • Added playwright-preflight target that validates gateway availability and shows helpful guidance
  • Made TEST_BASE_URL configurable via environment variable for all make targets

Authentication Resilience

  • Added JWT cookie fallback (_set_admin_jwt_cookie()) when UI login fails with unknown credentials
  • Fallback uses _create_jwt_token() to seed a valid admin JWT, bypassing form login
  • Fallback can be disabled via PLAYWRIGHT_DISABLE_JWT_FALLBACK=true
  • Auth tests now skip gracefully instead of failing when credentials are invalid

Test Stability

  • Fixed admin page URL from /admin to /admin/ for consistent navigation
  • Added UUID suffix to test server names to prevent naming collisions
  • Improved login flow handling with better status detection

Artifact Capture

  • Added make test-ui-screenshots for always-on screenshot capture
  • Enhanced make test-ui-record to capture both videos and screenshots
  • Updated .gitignore for test-results/, reports/, videos/, screenshots/

Documentation

  • Updated TESTING.md with preflight guidance and new targets
  • Updated tests/playwright/README.md with docker-compose workflow
  • Clarified artifact storage locations

Technical Details

File Change
playwright.config.py Default base URL → localhost:8080
tests/playwright/conftest.py JWT fallback, URL updates
tests/playwright/pages/admin_page.py Trailing slash fix
tests/playwright/test_admin_ui.py UUID server names
tests/playwright/test_auth.py Graceful skip on invalid credentials
Makefile playwright-preflight, test-ui-screenshots, preflight in all targets
.gitignore Playwright artifact directories
TESTING.md, README.md Documentation updates

Testing

# Start the recommended stack
make testing-up

# Run tests with new defaults
make test-ui-headless

# Override endpoint if needed
TEST_BASE_URL=http://localhost:8000 make test-ui

Related Issues

Metadata

Metadata

Assignees

Labels

COULDP3: Nice-to-have features with minimal impact if left out; included if time permitsplaywrightAutomated UI testing with playwrightpythonPython / backend development (FastAPI)test-automationAutomated testingtestingTesting (unit, e2e, manual, automated, etc)uiUser Interface

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions