Skip to content

fix: billing E2E tests timeout when run alongside portal tests #45

@macwilling

Description

@macwilling

Problem

All 9 billing E2E tests (tests/e2e/billing.spec.ts) pass reliably in isolation but time out when run as part of the full test suite alongside portal tests.

Isolation run: 10/10 pass in ~22s
Full suite run: 0/9 pass — all timeout

Root Cause

The billing tests are sensitive to dev-server load. The buildMinimalInvoice helper navigated to /invoices/new then called page.waitForLoadState("networkidle"), which waits for all network requests to be idle for 500ms. When portal tests run concurrently on the same dev server, network activity never settles within the timeout.

An attempt was made to replace waitForLoadState("networkidle") with page.locator('[id="client_id"]').waitFor({ state: "visible", timeout: 30_000 }), but the tests continued to fail, suggesting the bottleneck is deeper — likely the dev server struggling to handle concurrent requests from 2 Playwright workers.

Failing tests (all in billing — invoice management)

  • line item totals are computed correctly in the builder UI
  • adding and removing a line item updates the subtotal
  • creating an invoice redirects to the detail page with draft status
  • sending an invoice changes its status to sent
  • invoice PDF endpoint returns 200 with correct content-type
  • recording full payment marks invoice as paid
  • invoice with past due date shows overdue badge after sending
  • invoice number increments across two consecutive invoices
  • reports page loads revenue and time summary without errors

Possible paths forward

  1. Run billing tests serially, isolated from portal tests — add test.describe.configure({ mode: 'serial' }) to the billing describe block AND split billing into its own Playwright project that runs after portal tests complete (via dependencies).

  2. Increase dev-server capacity — run the dev server with --turbo or use a production build (npm run build && npm run start) for E2E tests, which handles concurrent requests better than next dev.

  3. Reduce concurrency — drop workers to 1 for the full local suite. Slower but guaranteed to work. Portal + billing + auth combined should still complete in under 5 minutes.

  4. Add per-test timeouts — set timeout: 60_000 on each billing test to give more headroom under load.

Current workaround

Run billing tests in isolation: npx playwright test tests/e2e/billing.spec.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions