Playwright testing

Offline tests are the default. Live smoke templates stay skipped unless the operator opts in with environment variables.

Updated

Default suite

From the repository root:

python -m pytest
  • Uses injectable fakes (FakePlaywrightSession, DOM fixtures under tests/playwright/fixtures/).
  • No credentials, network, Microsoft Graph, Workday REST, or attached browser session.
  • pyproject.toml excludes the granite marker only; playwright unit tests always run.

Optional file parsers (install when exercising DOCX/PPTX/XLSX/PDF tests):

pip install -e ".[dev,files]"

Optional Playwright package (for PlaywrightPageSession adapter tests only):

pip install -e ".[dev,playwright]"

Outlook inbox chunk scenarios (offline; 1 message vs 200):

python -m pytest tests/playwright/test_outlook_inbox_chunk_scenarios.py -q --tb=short

Live CDP (Edge signed into OWA):

./scripts/run-outlook-inbox-chunk-scenarios.sh

Background-tab harvest (no OS focus steal): leave FORGE_LCDL_CDP_BRING_TO_FRONT=0 (default) so LCDL enables Emulation.setFocusEmulationEnabled on attach. See EDGE-CDP-ATTACH.md.

SharePoint modern bridge offline tests (no browser):

python -m pytest tests/playwright/test_sharepoint_urls.py \
  tests/playwright/test_sharepoint_modern.py \
  tests/playwright/test_evaluating_fake_session.py \
  tests/playwright/test_sharepoint_scroll.py \
  tests/playwright/test_sharepoint_reader_modern.py \
  tests/playwright/test_playwright_sharepoint_tasks.py -q --tb=short

Pytest markers

Marker Meaning
playwright Read-only playwright unit tests (fake session / fixtures). Applied via tests/playwright/conftest.py.
playwright_live Attached-session smoke in tests/integration/test_playwright_live_smoke.py. Skipped unless FORGE_LCDL_PLAYWRIGHT_LIVE=1.

Select live smokes explicitly:

FORGE_LCDL_PLAYWRIGHT_LIVE=1 \
FORGE_LCDL_PLAYWRIGHT_SESSION_ID=your-ref \
FORGE_LCDL_PLAYWRIGHT_OUTLOOK_INBOX_URL='https://outlook.office.com/mail/' \
python -m pytest -m playwright_live -q

Live smoke environment

Variable Required for Purpose
FORGE_LCDL_PLAYWRIGHT_LIVE All live smokes Must be 1 to leave skip state
FORGE_LCDL_PLAYWRIGHT_SESSION_ID Connector + task smokes Opaque session_ref registered on PlaywrightSessionProvider by the host runtime
FORGE_LCDL_PLAYWRIGHT_OUTLOOK_INBOX_URL Outlook inbox Approved navigation URL for inbox read
FORGE_LCDL_PLAYWRIGHT_TEAMS_CHATS_URL Teams chats Approved navigation URL
FORGE_LCDL_PLAYWRIGHT_WORKDAY_INBOX_URL Workday inbox Approved navigation URL
FORGE_LCDL_PLAYWRIGHT_SHAREPOINT_NEWS_URL SharePoint news Approved navigation URL
FORGE_LCDL_PLAYWRIGHT_ONEDRIVE_RECENT_URL OneDrive recent Approved navigation URL
FORGE_LCDL_PLAYWRIGHT_LIVE_DOCX_PATH DOCX extract Absolute or relative path to a readable .docx on disk
FORGE_LCDL_PLAYWRIGHT_LIVE_PPTX_PATH PPTX extract Path to .pptx
FORGE_LCDL_PLAYWRIGHT_LIVE_XLSX_PATH XLSX extract Path to .xlsx
FORGE_LCDL_PLAYWRIGHT_LIVE_PDF_PATH PDF extract Path to .pdf

Live connector tests still skip when the session ref is not registered or per-URL env vars are unset. File extract smokes only read bytes from the given path (no playwright navigation).

Coverage map

tests/playwright/test_readonly_coverage.py asserts each v1 integration has an offline anchor test (connectors, file readers, processor, viewer, contracts, tasks).

Release verification (step 20)

Before tagging or handbook publish:

cd /home/lzvyahin/Code/forge-lcdl
python -m compileall -q src tests
python -m pytest tests/playwright/ -q --tb=short
python -m pytest -q --tb=line

tests/playwright/test_public_api.py (6 cases) asserts every name in forge_lcdl.playwright.__all__ imports, session provider get/set, credential-export tool denial via filter_tool_name, readonly ops via assert_readonly_operation, and connectors / files subpackage imports.

Deferred

  • Host runtime bridge that auto-registers FORGE_LCDL_PLAYWRIGHT_SESSION_ID (sibling forge-lcdl-runtime / Playwright MCP).
  • End-to-end live download via playwright_extract_file session policy.
  • CI job that runs playwright_live on a gated runner (never on default PR checks).