This directory contains end-to-end tests for the ZenUML Confluence Cloud Add-on using Playwright.
The test suite uses Playwright's dependency project pattern for efficient authentication:
- Setup Project (
tests/auth.setup.ts): Authenticates once and saves state toauth-state.json - Test Projects: Load the saved authentication state to skip login for each test
- One-Time Authentication: Login with OTP happens once before all tests
- Page Object Model: Organized page interactions in
pages/MacroPage.ts - Test Helpers: Reusable test utilities in
utils/test-helpers.ts - Automatic Cleanup: Test pages are created and deleted automatically
- Screenshot & Video: Captured on test failures
- Trace Viewer: Step-by-step debugging for failed tests
npm installnpm run install:browsersSet the following environment variables:
export ZENUML_STAGE_USERNAME="your-username"
export ZENUML_STAGE_PASSWORD="your-password"
export ZENUML_DOMAIN="your-domain.atlassian.net" # Optional, defaults to zenuml-stg.atlassian.net
export ZENUML_SPACE="YOUR_SPACE" # Optional, defaults to ZS
export PAGE_ID="123456" # Optional, for testing with existing page
export IS_LITE="true" # Optional, for testing lite version# Run all tests
npm test
# Run tests with browser UI visible
npm run test:headed
# Run tests in debug mode (step through each action)
npm run test:debug
# Run tests with Playwright UI mode
npm run test:ui
# Run tests with trace collection
npm run test:tracetests/e2e-tests/
├── config/
│ └── test-config.ts # Centralized test configuration
├── pages/
│ └── MacroPage.ts # Page Object Model for macro interactions
├── tests/
│ ├── auth.setup.ts # Authentication setup project
│ └── e2e.view-macros.spec.ts # Main macro functionality tests
├── utils/
│ ├── ConfluenceLogin.ts # Login and OTP handling
│ ├── page-creator.ts # Test page creation/deletion
│ └── test-helpers.ts # Reusable test utilities
└── playwright.config.js # Playwright configuration
tests/e2e.view-macros.spec.ts:
- Display All Macro Types: Verifies rendering of sequence, graph, OpenAPI, and embed macros
- Display Mermaid Diagrams: Tests Mermaid diagram rendering
- Handle Body-Only Sequence Macros: Tests sequence macros without custom content
- Edit Sequence Macro: Tests editing and saving sequence diagrams
- Edit Embed Macro: Tests editing and saving embedded diagrams
-
Authentication Fails:
- Verify
ZENUML_STAGE_USERNAMEandZENUML_STAGE_PASSWORDare set - Check that MFA secret is correctly configured for OTP generation
- Delete
auth-state.jsonto force re-authentication
- Verify
-
Space Not Found:
- Ensure
ZENUML_SPACEenvironment variable matches an existing space - Default is "ZS" - update if your space has a different key
- Ensure
-
Timeout Issues:
- Increase timeouts in
playwright.config.jsif needed - Check network connectivity to Confluence instance
- Increase timeouts in
-
Frame Loading Failures:
- Verify macro is properly installed in Confluence
- Check for JavaScript errors in browser console
- Use
--headedmode to visually debug
When tests fail:
- Screenshots: Check
test-results/directory - Videos: Retained on failure in
test-results/ - Traces: Run with
npm run test:trace, then view withnpx playwright show-trace trace.zip - Console Logs: Enable with
DEBUG=pw:api npm test
Key playwright.config.js settings:
- Setup Project: Runs once before all tests to authenticate
- Dependency Pattern: Main tests depend on setup completion
- Storage State: Saved to
auth-state.jsonand reused - Timeouts: 60s action/navigation, 120s for OTP entry
- Retries: 2 retries on CI, 0 locally