Skip to content

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.sh

This script:

  • Starts Symfony on http://127.0.0.1:8000 with APP_ENV=test
  • Starts the Slack bot API on http://localhost:4001
  • Enables NOTION_MOCK=true and OPENAI_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.json

Running 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 test

Targeted 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 report

Stop the test environment

bash
/home/ubuntu/yappa-knowledge-hub/scripts/stop-test-env.sh

What Is Covered

AreaExample specs
Knowledgeknowledge/create-knowledge.spec.ts, knowledge/search-knowledge.spec.ts
Categoriescategories/delete-category.spec.ts, category-subscription.spec.ts
Digestsdigests/digest-complete.spec.ts, digests/digest-distribution-flow.spec.ts
AI summariesdigests/digest-with-ai-summaries.spec.ts (via digest pipeline)
Notion syncnotion/sync-knowledge.spec.ts, notion/complete-sync-flow.spec.ts
Slack UIslack-ui/home-tab.spec.ts, slack-ui/modals/, slack-ui/overflow/
Workflowsworkflows/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:

VariableTypical value
BACKEND_URLhttp://127.0.0.1:8000
SLACK_API_URLhttp://localhost:4001
INTERNAL_API_SECRETtest-secret-token
NOTION_MOCK_MODEtrue
OPENAI_MOCK_MODEtrue