E2E Testing Guide
This guide covers end-to-end testing for the Teams application using Playwright.
Table of Contents
- Overview
- Quick Start
- Environment Setup
- Running Tests
- Test Architecture
- Writing Tests
- Debugging
- CI/CD Integration
- Best Practices Quick Reference
- Troubleshooting
- Playwright Test Agents
- Additional Resources
Overview
The E2E test suite uses Playwright 1.58.2 to test complete user workflows. Locally, tests run against all three browsers (Chromium, Firefox, WebKit). In CI, only Chromium is tested for speed (ADR-0015).
What We Test
- User workflows: Login, navigation, thread management
- Real-time collaboration: Multi-user comments, shared drafts (Yjs/WebSocket)
- App Suite integration: Mail API, sessions, accounts
- UI interactions: Assignment, status changes, tags, comments
- Deep linking: URL persistence, page reloads
Test Coverage
| Feature Area | Test Files | Key Scenarios |
|---|---|---|
| Provisioning | provisioning.spec.js | User setup, login, email provisioning |
| Navigation | inbox_list.spec.js, deep_links.spec.js | Folder switching, URL persistence |
| Thread Management | assignee.spec.js, status.spec.js | Assign/unassign, status updates |
| Collaboration | comments.spec.js, categories.spec.js | Comments, categories |
reply.spec.js, mail-detail.spec.js | Shared drafts, replies, rendering | |
| Multi-user | multiuser.spec.js | Real-time synchronization |
| Onboarding | tour-view.spec.js | Guided tour workflow |
Total: 11 test specs, ~803 lines of test code
Quick Start
# 1. Install dependencies
pnpm install
# 2. Install Playwright browsers (first time only)
npx playwright install
# 3. Configure environment (see Environment Setup below)
# Create e2e/.env with your settings (see e2e/.env.defaults for reference)
# Example:
echo "LAUNCH_URL=https://localhost:5173/
E2E_ADMIN_PW=your-password" > e2e/.env
# 4. Run tests
pnpm e2e
# 5. View HTML report
npx playwright show-reportEnvironment Setup
Environment Variables
The E2E tests use environment variables loaded from e2e/.env (overrides e2e/.env.defaults).
Default values are provided in e2e/.env.defaults. To customize, create e2e/.env with only the values you need to override:
# e2e/.env - Only override what you need
LAUNCH_URL=https://localhost:5173/
E2E_ADMIN_PW=your-admin-passwordAvailable variables (see e2e/.env.defaults for full reference):
# Target Application URL
LAUNCH_URL=https://localhost:5173/
# OR for remote testing:
# LAUNCH_URL=https://teams-reply.dev.oxui.de/
# Admin Credentials for Provisioning
E2E_ADMIN_USER=oxadmin # Default: oxadmin
E2E_ADMIN_PW=your-password # Required: no default
# Mail Domain (for provisioned users)
MX_DOMAIN=box.ox.io # Default: box.ox.io
# Browser Mode
HEADLESS=false # Default: false (set to true for headless)Local Development Setup
For local testing against https://localhost:5173:
Start the backend:
pnpm dev # Runs on http://127.0.0.1:8080Start the UI dev server (separate terminal):
pnpm vite dev # Runs on https://localhost:5173Create
e2e/.envwith your settings:# e2e/.env LAUNCH_URL=https://localhost:5173/ E2E_ADMIN_PW=your-admin-passwordRun tests:
pnpm e2e
Remote Environment Testing
To test against a deployed environment:
LAUNCH_URL=https://teams-reply.dev.oxui.de/ pnpm e2eNote: The provisioning fixture will create test users via SOAP API using the admin credentials.
Running Tests
Basic Commands
# Run all tests across all browsers
pnpm e2e
# Run tests in headed mode (see browser)
pnpm e2e --headed
# Run tests in a specific browser
pnpm e2e --project=chromium
pnpm e2e --project=firefox
pnpm e2e --project=webkit
# Run a specific test file
pnpm e2e e2e/tests/comments.spec.js
# Run tests matching a pattern
pnpm e2e --grep "assign to me"
# Run in debug mode
pnpm e2e --debug
# Run with UI mode (interactive)
npx playwright test --uiAdvanced Options
# Run tests sequentially (no parallelization)
pnpm e2e --workers=1
# Run with retries
pnpm e2e --retries=2
# Generate trace files for debugging
pnpm e2e --trace=on
# Run tests with specific timeout
pnpm e2e --timeout=60000 # 60 seconds
# Update snapshots (if using visual regression)
pnpm e2e --update-snapshotsViewing Reports
# Open the last HTML report
npx playwright show-report
# Open a specific report
npx playwright show-report playwright-report/
# View trace files
npx playwright show-trace test-results/path-to-trace.zipTest Architecture
Directory Structure
e2e/
├── fixtures/
│ ├── base.ts # Main fixture exports
│ ├── provisioning.ts # User provisioning via SOAP
│ └── mail.ts # Email sending fixture
├── tests/
│ ├── provisioning.spec.js
│ ├── inbox_list.spec.js
│ ├── assignee.spec.js
│ ├── status.spec.js
│ ├── comments.spec.js
│ ├── categories.spec.js
│ ├── reply.spec.js
│ ├── multiuser.spec.js
│ ├── mail-detail.spec.js
│ ├── deep_links.spec.js
│ └── tour-view.spec.js
├── .env # Environment variables
└── output/ # Test artifacts (screenshots, traces)Fixture System
The test suite uses custom Playwright fixtures for setup and teardown. See fixture files in e2e/fixtures/:
provisioning.ts- Creates test users/contexts via SOAP API (worker-scoped)mail.ts- Send test emails via App Suite Mail APIbase.ts- Combines fixtures and extends Playwright test
Available Fixtures:
test('my test', async ({
page, // Playwright page
currentUser, // First provisioned user
users, // All 5 provisioned users
sendMail, // Email sending function
browser, // Browser instance (for multi-user tests)
context // Browser context
}) => {
// Your test code
})Test Lifecycle
1. Worker starts
↓
2. Provisioning fixture runs (worker-scoped)
- Creates context via SOAP
- Provisions 5 users with random names
- Creates secondary accounts
- Saves authentication state
↓
3. Tests run (reuse provisioned users)
- Load storage state (already logged in)
- Send test emails
- Interact with UI
- Verify behavior
↓
4. Worker finishes
- Cleanup: Delete context and usersWriting Tests
Core Patterns
Basic test structure:
- Import fixtures:
import { expect, test } from '../fixtures/base.js' - Use
test.describe()to group related tests - Set up with
test.beforeEach()for common navigation - Arrange-Act-Assert pattern in test body
Key fixtures:
page- Playwright page objectcurrentUser- Authenticated user with secondary accountsendMail- Function to send test emailsusers- Array of 5 provisioned users for multi-user testsbrowser- Browser instance for creating additional contexts
Examples: See existing test files in e2e/tests/:
comments.spec.js- Basic test structure with sendMailassignee.spec.js- Using test steps for complex flowsmultiuser.spec.js- Multi-user collaboration patternsprovisioning.spec.js- Simplest test structure
Test Data
Use Faker for randomization:
import { faker } from '@faker-js/faker'
const subject = faker.word.words(5)Why? Prevents test pollution and ensures test independence.
Multi-User Testing
Create additional browser contexts for real-time collaboration tests:
const user2Context = await browser.newContext({
storageState: users[1].storageState
})
const user2Page = await user2Context.newPage()See e2e/tests/multiuser.spec.js for complete examples.
Browser Configuration
By default, tests run against Chromium only (ADR-0015).
Locally all three browsers are tested. CI runs Chromium only (ADR-0015).
To run a specific browser locally:
npx playwright test --project=chromiumDebugging
Quick debugging commands:
pnpm e2e --debug # Playwright Inspector (step through tests)
pnpm e2e --headed # Watch tests execute
pnpm e2e --headed --slow-mo=1000 # Slow down execution
pnpm e2e --trace=on # Capture traces for failed testsView traces:
npx playwright show-trace test-results/path-to-trace.zipAdd breakpoints in tests:
await page.pause() // Opens Playwright InspectorScreenshots: Automatically captured on failure in test-results/
For detailed troubleshooting: See E2E Troubleshooting Guide
CI/CD Integration
Tests run automatically on merge requests via GitLab CI (.gitlab-ci.yml):
- 3 parallel workers with browser sharding
- 2 retries on failure
- Tests against deployed review environment
- HTML reports published as artifacts
View reports: GitLab pipeline → "playwright" job → Artifacts → "playwright-report/index.html"
Simulate CI locally:
CI=true pnpm e2e --workers=1 --retries=2Best Practices Quick Reference
- Use role-based selectors:
getByRole()over CSS selectors - Randomize test data: Use Faker for independence
- Clean isolation: Each test independent, use
test.beforeEach() - Explicit waits:
await expect().toBeVisible()notwaitForTimeout() - Test steps: Use
test.step()for complex flows - Browser differences: Document skips with
test.fixme() - Real-time sync: Test WebSocket/Yjs with multi-user scenarios
- Descriptive names: Describe behavior, not implementation
- Leverage fixtures: Use
sendMail,currentUser,users
For troubleshooting: See E2E Troubleshooting Guide.
Playwright Test Agents
This project uses specialized Playwright agents (via Claude Code's Task tool) for test development:
- Test Planner: Creates test specifications in
docs/development/testing/specs/ - Test Generator: Generates test files in
e2e/tests/from specifications - Test Healer: Debugs and fixes failing tests
Workflow: Plan → Generate → Maintain
Test specifications: See Test Specs Overview for all test spec documents.
Contributing
Adding New Tests
Recommended: Use Playwright Test Agents (Plan → Generate → Verify)
Manual process:
- Create test spec in
docs/development/testing/specs/ - Follow existing test patterns in
e2e/tests/ - Use fixtures (
currentUser,sendMail,users) - Randomize test data with Faker
- Use role-based selectors
- Document browser-specific skips
Additional Resources
- Playwright Docs: https://playwright.dev/
- Test Specs: Test Specs Overview
- Unit Testing: Unit Testing Guide
- Troubleshooting: E2E Troubleshooting Guide

