Playwright E2E Testing
End-to-end tests live in e2e-tests/ and exercise the Symfony API, Slack bot HTTP surface, and full workflows with mocked Notion and OpenAI.
Prerequisites
Always start the test environment first:
bash
/home/ubuntu/yappa-knowledge-hub/scripts/ensure-test-env.shThis script:
- Starts Symfony on
http://127.0.0.1:8000withAPP_ENV=test - Starts the Slack bot API on
http://localhost:4001 - Enables
NOTION_MOCK=trueandOPENAI_MOCK=true - Creates
/.test-env-lock(required by Playwright global setup) - Uses
backend/var/data_test.db(never the main database)
WARNING
Do not run Playwright without the test lock file. Without mocks, tests can call real Notion/OpenAI APIs and pollute production data.
Directory Structure
plaintext
e2e-tests/
├── tests/
│ ├── api/ # Subscription API flows
│ ├── categories/ # Category CRUD
│ ├── digests/ # Digest generation and distribution
│ ├── knowledge/ # Knowledge CRUD and search
│ ├── notion/ # Notion sync (mock mode)
│ ├── slack-bot/ # Production-style Slack bot flow
│ ├── slack-integration/ # Cross-layer Slack + backend flows
│ ├── slack-ui/ # App Home, modals, actions, overflow menus
│ └── workflows/ # Multi-step MVP flows
├── helpers/
│ ├── api-client.ts # Authenticated API wrapper
│ ├── assertions.ts # Shared response assertions
│ ├── cleanup.ts # Test data cleanup
│ ├── global-setup.ts # Lock-file check + backend readiness + seed data
│ └── test-data-factory.ts # Deterministic test payloads
├── playwright.config.ts
└── package.jsonRunning Tests
bash
# 1. Start test environment (required)
/home/ubuntu/yappa-knowledge-hub/scripts/ensure-test-env.sh
# 2. Run tests
cd e2e-tests
npm install
npx playwright install # first run only
npm testTargeted runs
bash
npm run test:knowledge # tests/knowledge/
npm run test:workflows # tests/workflows/
npm run test:slack-ui # tests/slack-ui/
npm run test:slack-actions # tests/slack-ui/actions/
npm run test:slack-modals # tests/slack-ui/modals/
npm run test:slack-overflow
npm run test:debug # Playwright debug mode
npm run test:ui # Interactive UI runner
npm run report # Open HTML reportStop the test environment
bash
/home/ubuntu/yappa-knowledge-hub/scripts/stop-test-env.shWhat Is Covered
| Area | Example specs |
|---|---|
| Knowledge | knowledge/create-knowledge.spec.ts, knowledge/search-knowledge.spec.ts |
| Categories | categories/delete-category.spec.ts, category-subscription.spec.ts |
| Digests | digests/digest-complete.spec.ts, digests/digest-distribution-flow.spec.ts |
| AI summaries | digests/digest-with-ai-summaries.spec.ts (via digest pipeline) |
| Notion sync | notion/sync-knowledge.spec.ts, notion/complete-sync-flow.spec.ts |
| Slack UI | slack-ui/home-tab.spec.ts, slack-ui/modals/, slack-ui/overflow/ |
| Workflows | workflows/subscription-digest-complete-flow.spec.ts |
Tests run sequentially (workers: 1) for deterministic cleanup.
Configuration
Environment variables are loaded from the test stack started by ensure-test-env.sh:
| Variable | Typical value |
|---|---|
BACKEND_URL | http://127.0.0.1:8000 |
SLACK_API_URL | http://localhost:4001 |
INTERNAL_API_SECRET | test-secret-token |
NOTION_MOCK_MODE | true |
OPENAI_MOCK_MODE | true |