fix(web): observe responses before the first navigation

Merged
BO
11d ago
+76-8

What and why

  • browser.waitForResponse can observe the response from the first browser.goto or app.open. Previously it rejected with APP_NOT_OPEN before navigation could begin.
  • The wait and navigation share one pending active page and resume in call order. Existing media emulation, recording, cleanup and active-tab scope are retained.
  • Includes Chromium, lifecycle and built-CLI regressions, documentation, the generated consumer skill and a web patch changeset.

Addresses the pre-navigation response-wait gap in #1020.

const [response] = await Promise.all([
  browser.waitForResponse('**/network'),
  browser.goto('/network'),
]);
expect(response.status).toBe(200);
flowchart LR
  W["waitForResponse"] --> P["Shared first-page opening"]
  G["goto or app.open"] --> P
  P --> L["Register response listener"]
  L --> N["Navigate"]
  N --> R["Resolve response wait"]

Verified

Ran it locally: yes

  • Tested head 4bb44bfa against base c82a03a2, including the media-emulation changes from #1030, on Linux Node 22.23.3. From apps/testbed, used the built CLI with video off so recording setup cannot open the page and hide the defect:
node node_modules/e2e/dist/cli/bin.js run tests/network.e2e.ts \
  --grep "observes the first navigation response" --video off --reporter list,markdown
Current baseThis branch
APP_NOT_OPEN: no app page is open; call app.open() or browser.goto() firstobserves the first navigation response passes
Focused regressions: 26 pass, 2 failFocused regressions: 28 pass
  • pnpm check passes. The web suite passes 559 tests with one skip; built-CLI testbed passes 79 with one skip; web benchmark passes 91/91. The initial web run lacked the required Chromium binary; these results are from the rerun after installing it.
  • Follow-up e2ba3700 addresses the three documentation nits without changing executable code. pnpm check was rerun successfully; the runtime results above remain from 4bb44bfa.
  • Fresh-context review found no actionable issues. A delayed-media probe confirms one page, one emulation and listener continuation before navigation. The full core suite was not rerun for this rebase.
  • The earlier six-pair benchmark comparison was inconclusive. This change makes no performance claim. The earlier rendered-guide review is retained; no guide text changed during the rebase. Screenshot upload requires upstream write access, so media remains local.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. Web patch entry added.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). N/A: no breaking change.
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures. N/A: public signatures and wire formats are unchanged.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile. N/A: no engine contract change.

Compound Engineering