Skip to content

feat(expect): add toBeInViewport for web and mobile - #2011

Merged
okwasniewski merged 11 commits into
mainfrom
krzysztof/feat/expect-to-be-in-viewport
Nov 24, 2026
Merged

okwasniewski merged 11 commits into
mainfrom
krzysztof/feat/expect-to-be-in-viewport

Conversation

@KrzysztofMoch

@KrzysztofMoch KrzysztofMoch commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Playwright suites lean on toBeInViewport() to check that something is on screen without scrolling to it: a sticky bar, a toast, the first field of a form. e2e had no equivalent (#1295). #1303 added one, but it compared the node's box with a viewport taken from a second observation, and that answer is wrong on both engines:

  • On web it ignores overflow and scroll-container clipping, which Playwright's IntersectionObserver check takes into account.
  • On mobile, agent-device reports rects that are already clipped. A half-visible node read as 100% inside. Offscreen nodes leave the tree, so .not.toBeInViewport() could never pass.

This replaces #1303 and keeps @Anmol202005's commits, tests, and docs as the base.

await expect(screen.getByRole('toolbar', 'Selection')).toBeInViewport();
await expect(screen.getByRole('toolbar', 'Selection')).toBeInViewport({ ratio: 0.5 });
await expect(screen.getByRole('alert')).not.toBeInViewport();

How

Each engine now measures what it can actually report, through a new optional engine member:

viewportIntersection?(ref: NodeRef, context: OperationContext): Promise<{ intersects: boolean; ratio?: number }>;

It adds the viewport-intersection capability and the engine/viewportIntersection protocol method, and requires locate. A poll sample is the usual locate and read, then one measure of that ref, all inside the ReadWindow. There is no second observation.

flowchart LR
  A[locate + read the one match] -->|no match| O[outside: .not passes]
  A --> M[engine.viewportIntersection ref]
  M -->|NODE_STALE| A
  M --> W[web: page IntersectionObserver, clipped by overflow, scrollers, frames]
  M --> D[mobile: clipped device rect ∩ confirmed screen, no ratio]
Loading
  • Web measures with the page's IntersectionObserver, the same check Playwright makes, inside readingTab. An element with no box or a zero-size box counts as outside.
  • Mobile answers only whether the node is on screen, against the screen size observe confirms (a resized screen is checked with the device), so toBeInViewport({ ratio: 0.5 }) fails with UNSUPPORTED_CAPABILITY instead of reporting a fake 100%. ratio: 0 works the same as leaving ratio out. If the capture couldn't place the app's window on the screen, or the node has no bounds, it fails closed.
  • Matcher:
    • No match counts as outside.
    • A ref that goes stale before it is read or measured is sampled again, so .not can't pass on a navigation race. On web, an element the page replaces before the observer fires counts as stale too.
    • An engine without the member is refused before the resolve, including under .not.
    • An engine answer outside the contract, or one whose ratio contradicts intersects, is ENGINE_FAILURE.
    • ratio outside 0..1 is INVALID_ARGUMENT.
  • Surfaces updated:
    • The engine manifest schema and both its fixtures.
    • The docs for reference/expect, engine, engine-protocol, and test, plus the Playwright migration guide and skills/e2e/.
  • MCP: run_code runs the real expect since feat(mcp): run JavaScript in run_code #1998, so toBeInViewport works there with no change of its own.
  • Peers: an older core rejects the new engine member at config load, so @e2e-dev/web and @e2e-dev/mobile need the next core release. main already raised their floors to >=0.25.0, which covers it.
  • Not done: the schema doesn't require engine/locate alongside engine/viewportIntersection, because connectEngine({ resolveLocators: true }) builds locate on the client. defineEngine enforces the pairing, and tests cover both paths.

Issue

Closes #1295. Supersedes #1303.

Verified

Ran it locally: yes

Surface What ran Result
iOS 26.5 simulator (iPhone 17 Pro) mobile benchmark, "sticky chrome", built CLI, Release build passed: .not before scroll 1.1 s, in view after scroll, { ratio: 0.5 } refused with UNSUPPORTED_CAPABILITY
Android API 36 emulator same test passed: same three results
Chromium, testbed tests/controls.e2e.ts 18 passed, incl. the failure message observed: outside the viewport
Chromium, web engine integration viewport-intersection.test.ts ratios: full 1, half off-edge 0.5, half clipped by overflow: hidden 0.5, scrolled away in a scroller 0, half clipped by an iframe 0.5, display: none and zero width 0, password field measured, removed node NODE_STALE
Web benchmark pnpm test:web-benchmark 95 passed
Gates pnpm check, full pnpm test (every package) green on the rebased head

The web demo below runs through the built CLI. It walks a fully visible card, a card half clipped by overflow: hidden ({ ratio: 0.5 } passes, { ratio: 0.6 } fails with observed: 0.5 of its box), a row scrolled away inside a scroll container, a footnote 2300px down the page, and a missing match.

Overflow clipping, { ratio: 0.6 } refused Scroll container after scrollIntoView
clipped scroller

Fresh-context review: one Claude pass, then three rounds each with Claude Fable 5.2 and Gemini 4 Neon. Rounds 2 and 3 found nothing critical or important. Two findings were declined, with reasons:

  • Mobile refusing ratio before the node appears would need a new up-front engine field.
  • Running the web measure in Playwright's utility world isn't possible through Playwright's public API, so the docs say it runs in the page's own world instead.

Made by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, driven from T3 Code. Reviews by Claude Fable 5.2 and Gemini 4 Neon.

Co-authored-by: Anmol202005 183815727+Anmol202005@users.noreply.github.com

Web demo (Chromium, built CLI):

web-to-be-in-viewport-demo.mp4

iOS 26.5 simulator, mobile benchmark "sticky chrome":

ios-sticky-chrome.mp4

Android API 36 emulator, same test:

android-sticky-chrome.mp4

@github-actions github-actions Bot added e2e team Opened by the e2e team size:L Up to 499 changed lines, not counting tests, fixtures, translated docs, or the lockfile labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e web: 95 passed

All 95 tests in 43 files
Test Time
🟢 tests/aria-hidden-flow.e2e.ts · 2 passed 873ms
🟢 aria hidden flow › picks the Pro plan by its visible text and confirms it 620ms
🟢 aria hidden flow › another plan shows the error and keeps the picker open 253ms
🟢 tests/async-states.e2e.ts · 2 passed 7.0s
🟢 async states › reads the code off the transient toast and verifies it once the button enables 2.3s
🟢 async states › a wrong code is rejected after the toast has gone 4.7s
🟢 tests/canvas-only.e2e.ts · 2 passed 325ms
🟢 canvas only › taps square, circle, then diamond at their pixel coordinates 172ms
🟢 canvas only › a shape out of order paints the error and resets progress 153ms
🟢 tests/canvas-whiteboard.e2e.ts · 2 passed 449ms
🟢 canvas whiteboard › drags both shapes into their slots and saves 245ms
🟢 canvas whiteboard › bounces a shape off the wrong slot and refuses to save early 204ms
🟢 tests/cart-totals.e2e.ts · 2 passed 440ms
🟢 cart totals › increasing a quantity updates the line total but the order summary stays stale (planted bug) 240ms
🟢 cart totals › a quantity never drops below one 200ms
🟢 tests/checkout-review.e2e.ts · 1 passed 195ms
🟢 shows a raw greeting token and an undefined delivery date (planted bug), yet places the order 195ms
🟢 tests/context-menu-trap.e2e.ts · 2 passed 708ms
🟢 context menu trap › right-click opens nothing; the row menu renames the file 383ms
🟢 context menu trap › the decoy menu items refuse and keep the file 325ms
🟢 tests/control-inventory.e2e.ts · 8 passed 3.7s
🟢 control inventory › check sets the checkbox and the radio without flipping a set one 280ms
🟢 control inventory › check picks a radio the pick replaces with its summary 191ms
🟢 control inventory › a long press and a double click are told apart from a tap 1.0s
🟢 control inventory › the file menu opens on right-click only and Rename renames the file 288ms
🟢 control inventory › setInputFiles attaches files named from the project root 154ms
🟢 control inventory › the details view is left through the browser history 184ms
🟢 control inventory › scrollIntoView brings the footnote into view 213ms
🟢 control inventory › every exercise done shows the success message 1.3s
🟢 tests/css-content-ui.e2e.ts · 2 passed 395ms
🟢 css content ui › the tile labelled Ship it advances and confirming ships 210ms
🟢 css content ui › a wrong tile shows the CSS-rendered error and keeps the picker 185ms
🟢 tests/date-picker.e2e.ts · 2 passed 758ms
🟢 date picker › navigates three months ahead and books the required date 450ms
🟢 date picker › confirming without the exact date shows the error 308ms
🟢 tests/debounced-search.e2e.ts · 2 passed 2.8s
🟢 debounced search › a decoy one character off is refused 1.4s
🟢 debounced search › picking the exact item adds it to the cart 1.4s
🟢 tests/deferred-dialog.e2e.ts · 1 passed 1.1s
🟢 one submit opens one confirm, even when double-clicked 1.1s
🟢 tests/div-soup.e2e.ts · 2 passed 842ms
🟢 div soup › a wrong code is rejected 355ms
🟢 div soup › the right code grants access after the delete tile fixes a typo 487ms
🟢 tests/drag-and-drop.e2e.ts · 2 passed 745ms
🟢 drag and drop › an out-of-order item resets the dropzone 377ms
🟢 drag and drop › dropping Banana then Cherry passes 368ms
🟢 tests/file-round-trip.e2e.ts · 2 passed 421ms
🟢 file round trip › downloads the issued voucher and verifies the same file uploaded back 200ms
🟢 file round trip › rejects a file that is not the voucher, then accepts the issued one 221ms
🟢 tests/filter-deep-link.e2e.ts · 2 passed 285ms
🟢 filter deep link › filtering writes the query to the URL 170ms
🟢 filter deep link › opening a shared link restores the filter 115ms
🟢 tests/gift-card-purchase.e2e.ts · 3 passed 702ms
🟢 gift card purchase › refuses to buy without an amount 188ms
🟢 gift card purchase › refuses a recipient without an at sign 264ms
🟢 gift card purchase › sends the gift card 250ms
🟢 tests/hover-menu.e2e.ts · 2 passed 492ms
🟢 hover menu › a decoy leaf is refused 209ms
🟢 hover menu › hovering Account, then Billing, reaches Redeem voucher 283ms
🟢 tests/iframe-form.e2e.ts · 2 passed 600ms
🟢 iframe form › a wrong code is refused by the host page 268ms
🟢 iframe form › the code read from one frame applies through the other 332ms
🟢 tests/image-only-ui.e2e.ts · 3 passed 545ms
🟢 image only ui › the icons have no names, so the bare svg locator is ambiguous 133ms
🟢 image only ui › a wrong icon shows the error image and keeps the icons 199ms
🟢 image only ui › tapping the star, then the heart, verifies the icons 213ms
🟢 tests/infinite-scroll.e2e.ts · 1 passed 2.9s
🟢 scrolls the feed until the Golden Ticket loads, then claims it 2.9s
🟢 tests/kanban-board.e2e.ts · 3 passed 889ms
🟢 kanban board › pointer drags move both cards into the goal layout 420ms
🟢 kanban board › a swipe along a path drags a card as well 198ms
🟢 kanban board › a plain tap moves nothing and the untouched board is rejected 271ms
🟢 tests/login-form.e2e.ts · 4 passed 992ms
🟢 login form › rejects a malformed email 245ms
🟢 login form › rejects a short password 269ms
🟢 login form › rejects an unknown account 221ms
🟢 login form › signs in and logs out 257ms
🟢 tests/lying-labels.e2e.ts · 4 passed 791ms
🟢 lying labels › the button whose accessible name says Pay now is the wrong one 195ms
🟢 lying labels › a text match for Pay now catches the decoy phrase too 119ms
🟢 lying labels › the field whose accessible name says Amount is the wrong one 229ms
🟢 lying labels › visible text drives the payment through 248ms
🟢 tests/native-dialogs.e2e.ts · 3 passed 586ms
🟢 native dialogs › answers the confirm, prompt, and alert chain 204ms
🟢 native dialogs › dismissing the confirm cancels the order 182ms
🟢 native dialogs › a wrong gift code is rejected 200ms
🟢 tests/new-tab-flow.e2e.ts · 2 passed 544ms
🟢 new tab flow › reads the code in the tab the app opens and enters it back in the original tab 292ms
🟢 new tab flow › a tap that opens a tab leaves the screen on the original tab, and activate shows the new one 252ms
🟢 tests/newsletter-signup.e2e.ts · 1 passed 2.2s
🟢 subscribe renders no feedback and logs a TypeError (planted bug) 2.2s
🟢 tests/onboarding-wizard.e2e.ts · 5 passed 6.1s
🟢 onboarding wizard › back keeps what was typed and the brief comes back with it 365ms
🟢 onboarding wizard › the address step takes the brief through its bare-div dropdown 478ms
🟢 onboarding wizard › the profile step steers the calendar three decades back 1.5s
🟢 onboarding wizard › the preferences step flips the toggles the brief names and leaves the trap off 1.7s
🟢 onboarding wizard › the review step repeats the brief and finishes with the PIN 2.0s
🟢 tests/order-history.e2e.ts · 2 passed 1.6s
🟢 order history › overview and settings render their panels 292ms
🟢 order history › the orders tab never leaves its loading state (planted bug) 1.3s
🟢 tests/otp-auto-advance.e2e.ts · 3 passed 1.6s
🟢 otp auto-advance › focus advances with each digit and the full code verifies 536ms
🟢 otp auto-advance › backspace on an empty box clears and refocuses the previous one 218ms
🟢 otp auto-advance › a wrong code clears every box and starts over 851ms
🟢 tests/overlay-trap.e2e.ts · 1 passed 689ms
🟢 continues only after the banner and the overlay are gone 689ms
🟢 tests/playbook-cleanup.e2e.ts · 2 passed 677ms
🟢 playbook cleanup › deleting the draft removes it from an exact-name search 326ms
🟢 playbook cleanup › cancelling the dialog keeps the draft searchable 351ms
🟢 tests/price-sorting.e2e.ts · 3 passed 618ms
🟢 price sorting › opens in the featured order with sale prices struck through 182ms
🟢 price sorting › low to high sorts by the original price, not the paid one (planted bug) 215ms
🟢 price sorting › high to low is the same wrong order reversed (planted bug) 221ms
🟢 tests/product-reviews.e2e.ts · 1 passed 1.2s
🟢 the running-shoe page lists coffee-grinder reviews (planted bug) 1.2s
🟢 tests/promo-storefront.e2e.ts · 1 passed 1.4s
🟢 buys a deal once the promo chrome is out of the way 1.4s
🟢 tests/rich-text-editor.e2e.ts · 2 passed 529ms
🟢 rich text editor › bolding exactly the required word passes the check 259ms
🟢 rich text editor › bold that spills into the previous word fails the check 270ms
🟢 tests/saved-addresses.e2e.ts · 3 passed 732ms
🟢 saved addresses › adds an address and clears the form 242ms
🟢 saved addresses › ignores an add with an empty field 245ms
🟢 saved addresses › delete shows its toast but keeps the address, on retry too (planted bug) 245ms
🟢 tests/shadow-dom-form.e2e.ts · 2 passed 487ms
🟢 shadow DOM form › rejects a wrong access code 239ms
🟢 shadow DOM form › grants access with the code from the hint inside the root 248ms
🟢 tests/smoke.e2e.ts · 1 passed 306ms
🟢 home lists the scenarios and opens one 306ms
🟢 tests/stale-dom.e2e.ts · 1 passed 4.1s
🟢 taps the moving target three times across rebuilds of the list 4.1s
🟢 tests/sticky-chrome.e2e.ts · 1 passed 271ms
🟢 accepts the terms once the button clears the sticky footer 271ms
🟢 tests/virtualized-table.e2e.ts · 1 passed 19.0s
🟢 scrolls the windowed table to the Golden Row and claims it 19.0s
🟢 tests/wishlist.e2e.ts · 2 passed 1.7s
🟢 wishlist › saving toggles the button and the tab badge 313ms
🟢 wishlist › the wishlist tab renders the empty state despite the badge count (planted bug) 1.4s

Tested by e2e 0.24.0 · 1m 14s · web · run artifacts

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e web agent: 34 passed

35 agent steps · 26 replayed from cache · 25 model calls · 133.7k tokens (94% cached) · $0.0053

All 34 tests in 5 files
Test Agent Time
🟢 tests-agent/control-inventory.e2e.ts · 7 passed 7 steps 8.4s
🟢 control inventory › check sets the checkbox and the radio 1 step 977ms
🟢 control inventory › check picks a radio the pick replaces with its summary 1 step 344ms
🟢 control inventory › a long press and a double click are chosen over a plain tap 1 step 1.0s
🟢 control inventory › a right-click opens the file menu and Rename renames the file 1 step 2.7s
🟢 control inventory › upload attaches the named project files 1 step 2.6s
🟢 control inventory › back returns from the details view to the inventory 1 step 420ms
🟢 control inventory › scroll_to brings the footnote into view 1 step 432ms
🟢 tests-agent/login-form.e2e.ts · 1 passed 1 step 421ms
🟢 act signs in with the benchmark account 1 step 421ms
🟢 tests-agent/planted-bugs.e2e.ts · 3 passed 4 steps · 8 calls 10.6s
🟢 cart totals: a judgment catches the stale order summary 2 steps · 4 calls 5.4s
🟢 checkout review: a judgment catches the broken copy 1 step · 1 call 1.2s
🟢 wishlist: a judgment catches the lost saved items 1 step · 3 calls 4.0s
🟢 tests-agent/scenarios.e2e.ts · 22 passed 22 steps · 17 calls 1m 19s
🟢 act completes shadow-dom-form 1 step · 3 calls 3.2s
🟢 act completes lying-labels 1 step · 3 calls 4.3s
🟢 act completes iframe-form 1 step · 3 calls 4.5s
🟢 act completes infinite-scroll 1 step 3.6s
🟢 act completes virtualized-table 1 step 22.5s
🟢 act completes overlay-trap 1 step 951ms
🟢 act completes sticky-chrome 1 step 902ms
🟢 act completes async-states 1 step · 3 calls 6.2s
🟢 act completes debounced-search 1 step 2.4s
🟢 act completes hover-menu 1 step 545ms
🟢 act completes drag-and-drop 1 step 504ms
🟢 act completes kanban-board 1 step 715ms
🟢 act completes context-menu-trap 1 step 2.6s
🟢 act completes stale-dom 1 step 531ms
🟢 act completes otp-auto-advance 1 step 751ms
🟢 act completes date-picker 1 step 898ms
🟢 act completes rich-text-editor 1 step 10.3s
🟢 act completes playbook-cleanup 1 step 688ms
🟢 act completes promo-storefront 1 step 1.4s
🟢 act completes new-tab-flow 1 step · 5 calls 9.0s
🟢 act completes gift-card-purchase 1 step 2.5s
🟢 act filters the list and the URL carries the filter 1 step 253ms
🟢 tests-agent/unique-cache.e2e.ts · 1 passed 1 step 312ms
🟢 act adds an address with a run-unique label 1 step 312ms

Tested by e2e 0.24.0 · 1m 40s · web · run artifacts

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e android agent: 20 passed

24 agent steps · 15 replayed from cache · 32 model calls · 186.0k tokens (89% cached) · $0.0094

All 20 tests in 1 file
Test Agent Time
🟢 tests-agent/scenarios.e2e.ts · 20 passed 24 steps · 32 calls 5m 49s
🟢 act completes Login Form 1 step 25.0s
🟢 act completes Infinite Scroll List 1 step 19.4s
🟢 act completes Modal Flow 1 step 12.3s
🟢 act completes Bottom Tabs 1 step 9.3s
🟢 act completes Text Input Variations 1 step 10.6s
🟢 act completes Broken Accessibility 2 steps · 5 calls 16.4s
🟢 act completes Vision Only 2 steps · 1 call 7.5s
🟢 act completes Gestures 1 step · 7 calls 18.7s
🟢 act completes Async States 1 step · 8 calls 16.8s
🟢 act completes Debounced Search 1 step 7.0s
🟢 act completes Huge Virtualized List 1 step 1m 54s
🟢 act completes Flattened Registration Form 2 steps · 1 call 9.8s
🟢 act completes Flattened Login 2 steps · 6 calls 15.2s
🟢 act completes Sticky Chrome Target 1 step 9.5s
🟢 act completes WebView Accessibility 1 step · 4 calls 13.6s
🟢 act completes Permission Prompt 1 step 6.9s
🟢 act completes Product Catalog 1 step 8.5s
🟢 act completes Error Recovery 1 step 9.5s
🟢 act completes Choice Controls 1 step 8.8s
🟢 act completes Sequential Onboarding 1 step 10.5s

Tested by e2e 0.24.0 · 5m 51s · android-emulator · run artifacts

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e ios: 60 passed, 1 skipped

All 61 tests in 7 files
Test Time
⏭️ tests/controls.e2e.ts · 23 passed, 1 skipped 2m 45s
🟢 control inventory › a label query resolves a labeled text field 9.1s
🟢 control inventory › a labeled field answers name, display value, value reads, fill, and clear 13.3s
🟢 control inventory › a placeholder query and attribute reads find the field 4.4s
🟢 control inventory › a secure field takes a fill and denies value reads 7.2s
🟢 control inventory › press sends a character and Enter through the soft keyboard 9.0s
🟢 control inventory › a field autofocuses on mount and focus() moves the focus 9.6s
🟢 control inventory › toBeFocused follows the focus 8.7s
🟢 control inventory › a switch checks, unchecks, and reports its state 9.1s
🟢 control inventory › checkbox and radio roles answer getByRole, and a checkbox toggles by tap 8.1s
🟢 control inventory › checkbox and radio roles check, uncheck, and report their state 12.2s
🟢 control inventory › a radio group reports the checked option 8.7s
🟢 control inventory › buttons report disabled, enabled, and a state that arrives later 7.3s
🟢 control inventory › a display: none element is absent rather than hidden, its visible twin attached 6.9s
🟢 control inventory › a header answers its accessible name 4.5s
🟢 control inventory › a tab row answers count, all, texts, filters, positions, and switching 5.9s
🟢 control inventory › a list answers counts, list-form text, reads, and boxes in order 6.3s
⏭️ control inventory › a row contains its texts (skipped: React Native flattens a plain View out of the accessibility tree on both platforms: XCTest and the Android helper report a View with a testID as a leaf beside its children, so filter({ has }) and a query scoped to it match nothing; only Sc…)
🟢 control inventory › a long press lands as one 8.2s
🟢 control inventory › pointer verbs land at the point asked for 9.0s
🟢 control inventory › an ambiguous locator fails at once 5.5s
🟢 control inventory › screenshot, restart, and clearState reopen the app on its home list 10.8s
🟢 refusals › verbs a device never declares are refused before the engine 2ms
🟢 refusals › keys the soft keyboard cannot send are refused by the engine 247ms
🟢 refusals › a missing locator fails as not found once its timeout passes 1.1s
🟢 tests/device-fixture.e2e.ts · 14 passed 1m 53s
🟢 device fixture › setAppearance flips the color scheme the app reads 12.7s
🟢 device fixture › setOrientation rotates the window and viewport dimensions 6.8s
🟢 device fixture › the clipboard reads back what was written 5.1s
🟢 device fixture › home leaves the app, openApp brings it back where it was 6.5s
🟢 device fixture › closeApp then openApp relaunches on the home list 8.2s
🟢 device fixture › closeApp leaves the next commands on the same device 11.6s
🟢 device fixture › foregroundApp after closeApp reports the closed session as APP_NOT_OPEN 5.5s
🟢 device fixture › openLink opens the scenario a deep link names 12.6s
🟢 device fixture › isAppInstalled finds the app under test and no app that is absent 6.2s
🟢 device fixture › uninstallApp removes the app until installApp puts it back 9.6s
🟢 device fixture › device.back pops the scenario 4.9s
🟢 device fixture › unstable_raw reaches the test session through the raw driver 4.1s
🟢 device fixture › setLocation and clearLocation change what the app reads 9.7s
🟢 device fixture › enrollBiometrics and setBiometrics answer a biometric prompt 9.4s
🟢 tests/device.e2e.ts · 5 passed 56.3s
🟢 sequential onboarding echoes the exact values 24.3s
🟢 isKeyboardShown follows the keyboard up and through a dismissal 7.5s
🟢 a shake is sent without an error and leaves the screen readable 4.6s
🟢 onboarding rejects a malformed email before advancing 9.4s
🟢 dismissing the keyboard over choice controls leaves them as they were 10.5s
🟢 tests/flows-lists.e2e.ts · 7 passed 3m 53s
🟢 infinite scroll reaches the target item 34.1s
🟢 product catalog adds exactly two of the right variant 9.9s
🟢 gestures: long-press, then swipe left 8.8s
🟢 sticky chrome: accept below the fold, then continue 12.7s
🟢 async states: load, pull to refresh, claim through the toast 11.4s
🟢 huge virtualized list reaches row 512 2m 25s
🟢 web view coupon form applies the code shown on the page 11.4s
🟢 tests/flows.e2e.ts · 7 passed 1m 6s
🟢 text inputs unlock the submit button 11.7s
🟢 filled text inputs report their values 10.0s
🟢 modal flow confirms through the native alert 9.5s
🟢 bottom tabs act inside the last tab 7.4s
🟢 error recovery retries, then confirms the delete 9.2s
🟢 choice controls place the exact order 7.4s
🟢 debounced search selects the target once results arrive 11.1s
🟢 tests/login-form.e2e.ts · 3 passed 44.3s
🟢 login form › rejects a malformed email 12.4s
🟢 login form › rejects an unknown account 12.4s
🟢 login form › signs in and logs out 19.5s
🟢 tests/smoke.e2e.ts · 1 passed 7.3s
🟢 home lists the scenarios and opens one 7.3s

Tested by e2e 0.24.0 · 6m 40s · ios-simulator · run artifacts

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e android: 61 passed, 1 skipped

All 62 tests in 7 files
Test Time
⏭️ tests/controls.e2e.ts · 24 passed, 1 skipped 2m 52s
🟢 control inventory › a label query resolves a labeled text field 28.8s
🟢 control inventory › a labeled field answers name, display value, value reads, fill, and clear 11.9s
🟢 control inventory › a placeholder query and attribute reads find the field 6.4s
🟢 control inventory › a secure field takes a fill and denies value reads 7.6s
🟢 control inventory › press sends a character and Enter through the soft keyboard 7.8s
🟢 control inventory › a field autofocuses on mount and focus() moves the focus 8.0s
🟢 control inventory › toBeFocused follows the focus 7.5s
🟢 control inventory › a switch checks, unchecks, and reports its state 7.7s
🟢 control inventory › checkbox and radio roles answer getByRole, and a checkbox toggles by tap 6.7s
🟢 control inventory › checkbox and radio roles check, uncheck, and report their state 10.2s
🟢 control inventory › a tab role answers getByRole 3.6s
🟢 control inventory › a radio group reports the checked option 7.2s
🟢 control inventory › buttons report disabled, enabled, and a state that arrives later 6.6s
🟢 control inventory › a display: none element is absent rather than hidden, its visible twin attached 6.3s
🟢 control inventory › a header answers its accessible name 3.7s
🟢 control inventory › a tab row answers count, all, texts, filters, positions, and switching 5.5s
🟢 control inventory › a list answers counts, list-form text, reads, and boxes in order 5.2s
⏭️ control inventory › a row contains its texts (skipped: React Native flattens a plain View out of the accessibility tree on both platforms: XCTest and the Android helper report a View with a testID as a leaf beside its children, so filter({ has }) and a query scoped to it match nothing; only Sc…)
🟢 control inventory › a long press lands as one 7.3s
🟢 control inventory › a double tap lands inside the 300 ms window 7.1s
🟢 control inventory › an ambiguous locator fails at once 5.3s
🟢 control inventory › screenshot, restart, and clearState reopen the app on its home list 9.3s
🟢 refusals › verbs a device never declares are refused before the engine 3ms
🟢 refusals › keys the soft keyboard cannot send are refused by the engine 1.6s
🟢 refusals › a missing locator fails as not found once its timeout passes 1.1s
🟢 tests/device-fixture.e2e.ts · 13 passed 1m 56s
🟢 device fixture › setOrientation rotates the window and viewport dimensions 6.2s
🟢 device fixture › home leaves the app, openApp brings it back where it was 6.5s
🟢 device fixture › foregroundApp sees the home screen after home() 5.6s
🟢 device fixture › closeApp then openApp relaunches on the home list 10.1s
🟢 device fixture › closeApp leaves the next commands on the same device 9.9s
🟢 device fixture › foregroundApp after closeApp reports the closed session as APP_NOT_OPEN 5.8s
🟢 device fixture › openLink opens the scenario a deep link names 5.7s
🟢 device fixture › isAppInstalled finds the app under test and no app that is absent 4.5s
🟢 device fixture › uninstallApp removes the app until installApp puts it back 13.1s
🟢 device fixture › device.back pops the scenario 6.0s
🟢 device fixture › unstable_raw reaches the test session through the raw driver 4.8s
🟢 device fixture › setNetwork and setAirplaneMode change what the app sees 17.3s
🟢 device fixture › setLocation and clearLocation change what the app reads 20.2s
🟢 tests/device.e2e.ts · 6 passed 51.1s
🟢 permission prompt › allowing the system dialog enables the microphone 6.7s
🟢 permission prompt › a denied prompt recovers once the permission is granted outside 15.0s
🟢 sequential onboarding echoes the exact values 11.1s
🟢 a shake is sent without an error and leaves the screen readable 5.7s
🟢 onboarding rejects a malformed email before advancing 5.6s
🟢 dismissing the keyboard over choice controls leaves them as they were 7.1s
🟢 tests/flows-lists.e2e.ts · 7 passed 3m 7s
🟢 infinite scroll reaches the target item 28.8s
🟢 product catalog adds exactly two of the right variant 8.5s
🟢 gestures: long-press, then swipe left 7.9s
🟢 gestures: double-tap completes the flow 9.5s
🟢 sticky chrome: accept below the fold, then continue 10.7s
🟢 async states: load, pull to refresh, claim through the toast 11.8s
🟢 huge virtualized list reaches row 512 1m 50s
🟢 tests/flows.e2e.ts · 7 passed 49.2s
🟢 text inputs unlock the submit button 6.0s
🟢 filled text inputs report their values 5.3s
🟢 modal flow confirms through the native alert 8.8s
🟢 bottom tabs act inside the last tab 6.4s
🟢 error recovery retries, then confirms the delete 8.2s
🟢 choice controls place the exact order 6.1s
🟢 debounced search selects the target once results arrive 8.5s
🟢 tests/login-form.e2e.ts · 3 passed 26.9s
🟢 login form › rejects a malformed email 7.3s
🟢 login form › rejects an unknown account 7.2s
🟢 login form › signs in and logs out 12.4s
🟢 tests/smoke.e2e.ts · 1 passed 5.7s
🟢 home lists the scenarios and opens one 5.7s

Tested by e2e 0.24.0 · 10m 9s · android-emulator · run artifacts

@KrzysztofMoch
KrzysztofMoch force-pushed the krzysztof/feat/expect-to-be-in-viewport branch from c7123ea to cc66ae3 Compare November 20, 2026 16:08
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e ios agent: 1 flaky, 20 passed, 1 skipped

25 agent steps · 12 replayed from cache · 61 model calls · 556.3k tokens (83% cached) · $0.0369

⚠️ 1 flaky test passed on a retry

⚠️ act completes Gestures
tests-agent/scenarios.e2e.ts:266

ASSERTION_FAILED at step 4 of 4: agent.act "Complete this scenario as the screen instructs: long-press the first target, swipe the card left, then double-tap the last target", after 42.4s and 11 model calls

agent.act failed: Long-pressing the first target and swiping the card left advanced the scenario to Step 3. The final target remained on Step 3 after double_tap attempts, so the scenario did not complete.

  • Failed on 2 attempts: ASSERTION_FAILED at step 5, then at step 4.
  • Turn 8: double_tap({"target":"n4695"}) → [double_tap] Double-tapped #n4695.
  • Turn 9: tap({"target":"n4731"}) → [tap] Tapped #n4731.
  • Turn 10: tap({"target":"n4767"}) → [tap] Tapped #n4767.
  • Screen: dev.e2e.benchmark / Gestures

Evidence: screenshot, log

All 22 tests in 1 file
Test Agent Time
⚠️ tests-agent/scenarios.e2e.ts · 1 flaky, 20 passed, 1 skipped 25 steps · 61 calls 8m 32s
🟢 act completes Login Form 1 step 39.6s
🟢 act completes Infinite Scroll List 1 step 34.8s
🟢 act completes Modal Flow 1 step 10.8s
🟢 act completes Bottom Tabs 1 step 7.7s
🟢 act completes Text Input Variations 1 step 12.1s
🟢 act completes Broken Accessibility 2 steps · 8 calls 37.8s
🟢 act completes Vision Only 2 steps · 6 calls 24.4s
⚠️ act completes Gestures (2 failed attempts first) 1 step · 8 calls 34.3s
🟢 act completes Async States 1 step · 9 calls 31.7s
🟢 act completes Debounced Search 1 step · 1 call 29.3s
🟢 act completes Flattened Registration Form 2 steps · 1 call 26.9s
🟢 act completes Flattened Login 2 steps · 13 calls 1m 7s
🟢 act completes Sticky Chrome Target 1 step 13.3s
🟢 act completes WebView Accessibility 1 step 12.2s
🟢 act completes Permission Prompt 1 step 11.8s
🟢 act completes Photo Picker 1 step · 2 calls 28.2s
🟢 act completes Product Catalog 1 step 10.6s
🟢 act completes Error Recovery 1 step 9.4s
🟢 act completes Choice Controls 1 step · 5 calls 32.2s
🟢 act completes Stripe PaymentSheet 1 step · 8 calls 27.7s
🟢 act completes Apple Pay 1 step 11.2s
⏭️ act completes Apple Pay Billing Address (skipped: the CI simulator's Apple Pay sheet skips the billing-address step, so the scenario cannot be completed there)

Tested by e2e 0.24.0 · 9m 54s · ios-simulator · run artifacts

@KrzysztofMoch KrzysztofMoch added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 20, 2026
kdy1
kdy1 previously requested changes Nov 21, 2026

@kdy1 kdy1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This text was drafted with AI and posted after human approval.

  • Harness: T3 Code (Claude Code harness)
  • AI agents: Claude Opus 5.5 (claude-opus-5-5), coordinator in T3 Code, GPT-6.2 Astra (gpt-6.2-astra), Review Once subagent via Codex, GPT-6.2 Sol (gpt-6.2-sol), Review Once subagent via Codex, Claude Opus 5.5 (claude-opus-5-5), Review Once subagent via Claude, Claude Sonnet 5.5 (claude-sonnet-5-5), Review Once subagent via Claude

Thanks, the matcher works as described on the cases I ran (testbed controls.e2e.ts 21/21, web viewport-intersection + lifecycle 35/35, e2e unit 210/210, mobile engine unit 256/256 at cc66ae3b).

I'm requesting changes for one P2 in the web measure, explained inline on packages/web/src/surface.ts. A fully visible element that the page replaces on every frame reads as outside the viewport, so .not.toBeInViewport() passes on it. I reproduced it in Chromium (20/20 samples { intersects: false, ratio: 0 }) and checked a 5-line fix (20/20 NODE_STALE, existing tests still pass).

The other 5 inline comments are P3. None of them would block on its own. Because the P2 needs another iteration anyway, I'm asking for them in the same round. If you prefer to leave one for a follow-up, say so in the thread.

6 inline comments in total.

Comment thread packages/web/src/surface.ts Resolved
Comment thread packages/web/src/surface.ts Resolved
Comment thread packages/core/src/locator/engine.ts Resolved
Comment thread packages/mobile/src/surface.ts Resolved
Comment thread packages/core/src/engine/session.ts Resolved
Comment thread packages/e2e/src/expect/async.ts Resolved

@michal-e2e michal-e2e left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Drafted with AI (Claude Code and Codex in T3 Code; Claude Opus 5.5, with GPT-6.2 Astra, GPT-6.2 Sol and Claude Fable 5.2 as second readers), checked and posted by me.

@KrzysztofMoch, this adds to @kdy1's review at the same commit (cc66ae3b4). On the stale read at the read step, of kdy1's two options I would narrow the description. I did not rerun kdy1's P2. Two more things need changing, and I add one case to kdy1's mobile screen-size comment.

Must fix

  • packages/e2e/schema/fixtures/engine-manifest-v1.invalid.json:1: the invalid fixture is unchanged, though AGENTS.md asks a wire change to edit both fixtures. It already fails on older rules, so deleting the new one (engine/viewportIntersection requires engine/observe) leaves every schema test green; I ran that. Replace it with {"name":"android","version":"0.1.0","spiVersion":1,"methods":["engine/viewportIntersection"]}, as #1633 did for readStyle. Tried: the fixture test passes, and removing the rule now fails it. The refused list at engine-protocol.test.ts:539 already covers the old fixture's actions case, but nothing else checks its isolation: "attempt", so add expect(validate({ ...base, methods: ['engine/observe'], isolation: 'attempt' })).toBe(false); after that loop.

  • packages/e2e/tests/unit/expect-viewport.test.ts:61: two claims in your description are only partly tested: the existing tests miss three cases, and the mutants under them pass this PR's tests. "ratio: 0 works the same as leaving ratio out" is tested only on an engine that reports a ratio (line 34); on one that reports only intersects, as mobile does, const minimum = ratio passes, though { ratio: 0 } on a device then fails with UNSUPPORTED_CAPABILITY. "An engine answer outside the contract is ENGINE_FAILURE" is tested only with ratio: 2; dropping the negative-ratio or the non-boolean-intersects check passes. Add await expectFixture(visiblePart).toBeInViewport({ ratio: 0 }); after line 63, and loop the test at line 120 over { intersects: true, ratio: 2 }, { intersects: false, ratio: -0.1 } and { intersects: 'yes' } (intersects: false keeps the negative row failing on the range check alone if you add kdy1's consistency check). Tried: all 9 tests pass and each of the three mutants fails one.

Adding to kdy1's mobile screen-size comment

surface.ts:1310: kdy1 names foldables; after the public device.fold(), the check can still measure against the old screen size. On the fake device (not a foldable emulator): Android at 412x915, one observe, fold('open'), then a capture at 841x701 with a button at x: 600 measured { intersects: false }. Whatever fix you pick there, please add a fold case beside the fold test at engine.test.ts:2639.

Optional

  • .changeset/viewport-matcher.md:14: on a device, ratio > 0 fails with UNSUPPORTED_CAPABILITY only once the node is on screen; off screen, .not passes, as your test at line 72 expects. docs/reference/expect.mdx already says "once the node is on screen"; the changeset and skills/e2e/references/writing-tests.md:413 could say the same (then pnpm plugins:sync).
  • docs/reference/errors.mdx:151: the UNSUPPORTED_CAPABILITY row has none of the new causes (no viewportIntersection, ratio > 0 with no reported ratio, a node with no reportable bounds).
  • Tests for two more surviving mutants: a mobile node on screen lower than the screen is wide, such as below y: 390 on the 390x844 test screen (computing its height against the width passes today), and a zero-height web element (dropping box.height <= 0 passes today).

Verified

  • On the merge base (e88153b2f), the new testbed test fails through the built CLI with expect(...).not.toBeInViewport is not a function, and the PR's expect-viewport.test.ts copied onto that build fails 9 of 9.
  • Mutation testing at cc66ae3b4, each mutant run against this PR's own tests: 42 mutants, 22 killed by an assertion, 14 survived, 6 unconfirmed: 5 made a test fail without a failed assertion, and 1 passed the unit tests and failed the new testbed test's message assertion. The survivors I ask tests for are under the two must-fix items and the last optional bullet.
  • Mobile from CI at this head, not run here: "sticky chrome" passed on iOS and Android.

Not run: a foldable emulator; iOS and Android locally; Lightpanda, where the new controls.e2e.ts test calls scrollIntoView, which docs/integrations/lightpanda.mdx lists as a no-op.

The engine contract, the schema and the mobile peer range are code-owner paths, so the approval is @okwasniewski's.

@michal-e2e michal-e2e removed the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 21, 2026
@KrzysztofMoch
KrzysztofMoch force-pushed the krzysztof/feat/expect-to-be-in-viewport branch from cc66ae3 to 611bc6a Compare November 23, 2026 07:17
@KrzysztofMoch

Copy link
Copy Markdown
Member Author

@michal-e2e thanks, all of it is in 10a438f.

Must fix

  • The invalid fixture is now your engine/viewportIntersection manifest without engine/observe. The old fixture's actions case stays in the refused list in engine-protocol.test.ts, and the isolation: 'attempt' check follows the loop.
  • expect-viewport.test.ts now runs toBeInViewport({ ratio: 0 }) on the engine that reports only intersects. The contract test loops over { true, 2 }, { false, -0.1 }, { intersects: 'yes' }, and the two answers kdy1's consistency check refuses ({ false, 1 }, { true, 0 }).

Fold

  • The mobile measure now gets its screen size from viewportFor (fixed for kdy1's comment in 611bc6a), so it confirms the size when a capture's differs. Your repro is beside the fold test in engine.test.ts: Android 412x915, observe, fold('open'), a capture at 841x701 with a node at x: 600, which measures { intersects: true }.

Optional

  • The changeset and the skill say "once the node is on screen" (plugins synced).
  • errors.mdx lists the three new UNSUPPORTED_CAPABILITY causes.
  • A mobile node at y: 600 on the 390x844 screen, and a zero-height web element that reads as outside.

Stale read: I fixed it in code rather than narrowing the description. readViewport marks a read or measure that went stale, and the matcher samples again instead of reading it as no node, so the description's claim holds. The test is in locator-engine.test.ts (readViewport) and expect-viewport.test.ts.

pnpm check, pnpm test, and the testbed's controls.e2e.ts pass at 10a438f. Still not run: a foldable emulator and Lightpanda.

[claude-opus-5-5] responding on behalf of KrzysztofMoch

@KrzysztofMoch
KrzysztofMoch requested a review from kdy1 November 23, 2026 07:30
@kdy1
kdy1 dismissed their stale review November 23, 2026 07:41

All requested changes are in as of 10a438f. Checked and dismissed by a T3 Code automation (Claude) for @kdy1.

@KrzysztofMoch
KrzysztofMoch force-pushed the krzysztof/feat/expect-to-be-in-viewport branch from 10a438f to 8377566 Compare November 23, 2026 11:18

@michal-e2e michal-e2e left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.

Reviewed at 83775666e (merge base d53602a84, main). It merges cleanly with main at 634d06047.

Thanks @KrzysztofMoch, every must-fix from my last review and kdy1's comments is fixed, and the rebase onto #1883 kept both fixture rules. I found nothing blocking, so I'm approving this commit. The engine contract, the manifest schema and its fixtures are code-owner paths, so @okwasniewski's sign-off is still his to give.

Must fix: none.

Optional

  • Your changeset bumps e2e, @e2e-dev/core, @e2e-dev/web and @e2e-dev/mobile, but not @e2e-dev/desktop. CONTRIBUTING.md ("Engine contract") says a change to the engine contract bumps "every engine together in one release, with a changeset for each". I missed this last round. The pending changesets for #1883 (a new engine action) and #1962 (the readonly node state) do not list desktop either, and desktop has pending changesets of its own, so it ships in the same release anyway. Adding "@e2e-dev/desktop": patch follows the rule as written. .changeset/viewport-matcher.md:5
  • A tiny positive share prints as 0. With no ratio, describeRatio returns the three-decimal rounding, so a failing .not.toBeInViewport() on a share of 0.00025 says observed: 0 of its box inside the viewport. Print the share in full when it rounds to 0 but is above 0. packages/e2e/src/expect/async.ts:588
  • Can we add a mobile test with a zero-size rect inside the screen ({ x: 10, y: 300, width: 0, height: 0 }, expects { intersects: false }) and one that straddles the bottom edge (expects { intersects: true })? Changing width > 0 && height > 0 to >= 0 passes every test today. packages/mobile/src/surface.ts:1344
  • docs/reference/engine.mdx says toBeInViewport with ratio > 0 "then fails with UNSUPPORTED_CAPABILITY". The changeset and expect.mdx already add "once the node is on screen"; the same qualifier fits here. docs/reference/engine.mdx:456

Verified

  • Each earlier must-fix at 83775666e: the mobile measure confirms the capture's own size through viewportFor (fold and resize tests), the invalid fixture fails only on engine/viewportIntersection without engine/observe, ratio: 0 and five out-of-contract answers are tested, the changeset wording is fixed, a node replaced after it is observed is stale on web, size and ratio come from one observer entry, a stale read is sampled again, contradictory answers are ENGINE_FAILURE, and 0.99975 prints in full.
  • The rebase: git range-diff shows nine of eleven commits unchanged; the rest is a comment line from #1883 and the fixture conflict. #1883's duplicate payload case moved into an inline test that still asserts uniqueItems at /actions, and the new test asserts contains at /methods.
  • Suites at 83775666e, run here: pnpm check and pnpm test pass, the testbed passes (608 passed, 1 skipped), including "toBeInViewport follows the scroll position, and no match is outside the viewport", and the web benchmark passes (95). The web agent suite from its recordings fails the same 8 tests on this PR and on its merge base d53602a84, each a step with no recording that calls the model without a key here (MODEL_PROVIDER_FAILED); CI's web agent job, which has the key, passes at this head.
  • CI's spec jobs at this head were cancelled at the 15-minute limit. Main's own spec runs hit the same limit at the same time (45164506047, 45157201606). It needs a rerun before merge.
  • Merged with main at 64d5be8bb locally: the PR's e2e unit files (320 passed), the mobile engine unit tests (285 passed), the web viewport integration test (5 passed) and pnpm typecheck all pass. Main has moved one commit since (#2096), touching none of this PR's files.
  • Mutation testing: 26 mutants over the branches this PR adds or changes, 17 killed by a failing assertion, run with each mutant applied to 83775666e. Every mutant that undoes one of the fixes above is killed. One more fails another way: ratio: 0 read as a share makes the new ratio: 0 line throw UNSUPPORTED_CAPABILITY. Eight survive: the zero-size mobile rect above; two that give the same answer as the head (the first isConnected and the getClientRects checks, now covered by the checks in the observer callback); and five from last round on code that did not change (the superseded-locate check, the float tolerance, the 0 to 1 clamp, and the mobile left and top clips). Two more mutants remove main's schema rules that the rebased tests now carry (isolation: 'attempt' refused, actions unique); both are killed.
  • New tests and the mutant that kills each: the contract test (negative ratio, ratio above 1, contradictory answers, non-boolean intersects), the rounding test, readViewport stale (two mutants), the resized-screen and fold tests (measure against the known screen, binding without its capture size), the Lower node (height against width), the ticker test (no detach check in the callback), #flat (no height check), the new schema test (rule removed), the isolation: 'attempt' line, and the rewritten duplicate payload test (uniqueItems removed). The ratio: 0 line fails another way, as above.

Not run

  • Mobile locally. CI's iOS and Android deterministic and agentic jobs pass at this head (run 45164027996), including the sticky chrome test that uses toBeInViewport.
  • A foldable emulator: device.fold('open') on a Pixel Fold, then toBeInViewport() on a node past the closed screen's edge.
  • Lightpanda: pnpm --filter @e2e-dev/testbed run test:lightpanda. The new testbed test scrolls, which the Lightpanda page lists as a no-op.

For the maintainer

  • Release order: core is 0.24.0 with only patch changesets pending for it, and the engines' peers read >=0.25.0 (set on main by #1962). Which core version this ships in is yours to settle.
  • Still open from last round: a node with no box (web reads display: none as outside, mobile throws), ratio on a device refused only once the node is on screen, and no Lightpanda row.

The findings are mine; the approval of the code-owner paths is @okwasniewski's.

@KrzysztofMoch
KrzysztofMoch force-pushed the krzysztof/feat/expect-to-be-in-viewport branch from 8377566 to e678ba4 Compare November 23, 2026 12:39
@KrzysztofMoch
KrzysztofMoch force-pushed the krzysztof/feat/expect-to-be-in-viewport branch from e678ba4 to b7e6884 Compare November 24, 2026 06:14
Anmol202005 and others added 6 commits November 24, 2026 12:00
…ection

Reworks the imported matcher so each engine measures what it can honestly
report, instead of the harness comparing a node box with a second
observation's viewport.

- Engines get an optional `viewportIntersection(ref)` member
  (`viewport-intersection` capability, `engine/viewportIntersection` on the
  protocol). The harness reads the match and measures that ref once per
  poll sample, inside the read window.
- The web engine measures with an IntersectionObserver, as Playwright does,
  so scroll containers, overflow ancestors, and frames clip the box.
- The mobile engine answers only whether the node is on screen: agent-device
  reports bounds already clipped, so `ratio` there is UNSUPPORTED_CAPABILITY.
- No match reads as outside the viewport, so `.not` passes for a node a
  device left out of its tree. A node that goes stale before it is measured
  is sampled again rather than read as gone.

Co-authored-by: Anmol202005 <183815727+Anmol202005@users.noreply.github.com>
…at cannot measure

Also drops the schema rule that required engine/locate beside
engine/viewportIntersection (the client may build locate itself), adds the
capability to the web lifecycle test and to the docs' capability lists.
- mobile: refuse a node whose window has no known place on the screen, and
  measure against the confirmed screen, not a capture's own size
- web: measure inside readingTab, and dispose a handle when the operation
  aborts
- test defineEngine's locate requirement and the resolveLocators path
- docs: strictness list, zero-size difference from Playwright, page-world note
- web: clamp the measured ratio to 0..1 in the page
- skill: list toBeInViewport among the matchers that accept zero matches
Reviewed with Gemini 4 Neon against the code: ratio 0 works on mobile and
only ratio > 0 is refused, a missing box on the web reads as outside while
missing bounds or screen position is UNSUPPORTED_CAPABILITY, and an
out-of-range ratio is INVALID_ARGUMENT.
- web: an element replaced before the observer fires is NODE_STALE, not
  outside, and the zero-size check reads the observer's own entry, so the
  box and the ratio come from one frame
- core: a ref superseded between the resolve and the read is a stale sample
  the poll never evaluates, like one stale at the measure, so `.not` cannot
  pass on either race; tryRead's other callers are unchanged
- mobile: the measure confirms a capture whose size is not the known
  screen's through viewportFor, as observe does, so a resized screen is
  picked up without an observe
- core: reject an engine answer whose ratio contradicts intersects
- expect: print a share in full when rounding would show the threshold as met
- changeset: drop the 0.24.1 floor sentence; main's floors are 0.25.0
…nd flat boxes

From michal-e2e's review: the invalid manifest fixture now fails on the viewportIntersection rule alone, ratio 0 runs on an engine that reports no share, the contract test covers every refused answer, a mobile fold measures against the new screen, and a zero-height web element reads as outside. The changeset, skill, and errors reference name when ratio is refused on a device.
run_code calls the real expect since #1998, which removed the matcher allowlist this branch extended. Check that the matcher works there.
@KrzysztofMoch
KrzysztofMoch force-pushed the krzysztof/feat/expect-to-be-in-viewport branch from b7e6884 to 382c210 Compare November 24, 2026 11:12

@michal-e2e michal-e2e left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.

Reviewed at 382c21060 (merge base 757d1dbd4). The rebase carried over the manifest and stale-reference fixes. The new MCP test exercises the matcher through run_code.

Must fix: none.

Optional

  • Add a viewport assertion that should fail in the MCP test, such as .not.toBeInViewport() on the visible button. The current success cases catch a missing matcher and pass when the MCP wrapper returns success without invoking it. Checking for ASSERTION_FAILED would cover what the caller sees when the assertion fails. MCP test
  • The MCP session's matcher list omits toBeInViewport. Consider naming it in the API text agents see when they open a session. MCP API description
  • The engine reference says that toBeInViewport with ratio > 0 “then fails with UNSUPPORTED_CAPABILITY.” The matcher can decide the assertion when the engine reports that the node is outside. Add “when the node intersects the viewport” to match the behavior the test covers. Engine reference · Assertion test

Verified

  • The built MCP server ran the matcher through run_code against a real button and a missing match. The new test failed on the merge base because the matcher was missing. It also failed when I removed MCP's access to the matcher on this head.

  • The manifest schema accepted the new method with observation and rejected it without observation. The valid and invalid fixtures cover those cases. The separate duplicate-action check still passed. The package declarations add an optional engine method and an assertion method. The wire protocol stays at version 1.

  • Local pnpm check, pnpm test and pnpm test:web-benchmark passed. The new viewport test passed on the testbed. A separate iframe test timed out on the first testbed run, then passed in the full rerun and on the merge base.

  • The strict-cache web agent benchmark failed in the same eight cases on the head and base. Five reported missing AI Gateway authentication and three failed judgment assertions.

  • The packed candidate runner passed its Chromium smoke test with the published web engine. The reverse compatibility check could not run because npm had no stable runner in the candidate web engine's declared peer range.

  • The compiler caught changes that accepted a string ratio, required a string timeout or accepted the unsupported threshold option. All new viewport type assertions rejected the corresponding changed declaration.

  • The full e2e package suite passed with the MCP matcher replaced by a no-op, including the new integration test. The compiled matcher works on this head. The gap is in what the MCP test would catch.

  • Runtime mutation checks ran 42 distinct patches. Thirty failed by assertion, nine passed the tested files and three failed through an expected runtime error. The two new tests without an assertion failure still caught changed behavior. The type mutations ran separately.

New runtime tests and the mutations that reached them
  • e2e mcp run_code measures a node against the viewport with toBeInViewport — MCP01-matcher-unavailable
  • defineEngine rejects viewportIntersection without locate: it measures located nodes — target-define
  • toBeInViewport passes on any area inside by default and compares the share with ratio — target-ratio
  • toBeInViewport reads no match and a box outside as outside the viewport — target-absence
  • Polls until the node enters the viewport — target-poll-budget ended the assertion after one read.
  • toBeInViewport refuses ratio on an engine that measures only the visible part of a box, even under .not — target-no-ratio
  • toBeInViewport fails at once when the engine cannot measure the node, even under .not — target-no-capability
  • toBeInViewport samples a node that went stale before it was measured again instead of reading it as gone — N04-measure-stale-false, N05-async-stale-evaluable, N07-observed-no-stale-text
  • Measures a secure field — target-secure-refusal rejected the field.
  • toBeInViewport fails on an engine answer outside the contract or one that contradicts itself — M04d-check-no-boolean, M05-check-ratio-low, M06-check-ratio-high, N01-check-no-consistency
  • toBeInViewport prints a share that falls short of ratio in full when rounding would show it as met — N06-describe-ratio-rounded
  • toBeInViewport rejects an invalid ratio and unknown options before reading — target-invalid-ratio
  • readViewport reads a ref superseded between the resolve and the read as stale, not as gone — N02-readone-stale-false, N03-readviewport-no-early-stale
  • engine-manifest-v1 schema rejects the invalid fixture for viewportIntersection without engine/observe — M27-schema-no-observe-requirement
  • location answers whether a located node is on the screen, never the share agent-device clipped away — X05-height-uses-width
  • location measures against a resized screen once the device confirms it, without waiting for an observe — N12-screen-from-known, N13-binding-no-capture-size, X05-height-uses-width
  • location refuses to say whether a node is in the viewport when its window has no known place on the screen — target-mobile-origin
  • device fixture measures toBeInViewport against the unfolded screen after fold — N12-screen-from-known, N13-binding-no-capture-size
  • viewport intersection on the web engine measures the share of the box the viewport and clipping ancestors leave — target-web-unclipped
  • viewport intersection on the web engine reads an element with no box or an empty one as outside — N09-no-width-check, N10-no-height-check
  • viewport intersection on the web engine measures a password field like any other element — target-web-password
  • viewport intersection on the web engine follows scrolling, and a removed element is stale — target-web-removed
  • viewport intersection on the web engine reads an element the page replaces every frame as stale, never as outside — N08-no-callback-detached-check

Not run locally

  • pnpm test:mobile-benchmark stayed queued because the host's simulator and emulator were reserved by other reviews. The GitHub Actions logs show the new sticky-chrome viewport case passing on iOS and Android.

For the maintainer

  • The engine contract release rule calls for a changeset for each engine. Desktop already has a pending patch in the same release and the viewport changeset omits it. Please decide whether to add Desktop to this changeset. Release rule · Viewport changeset

The engine contract and manifest paths are for @okwasniewski to approve.

@okwasniewski
okwasniewski merged commit 94fd9a6 into main Nov 24, 2026
37 checks passed
@okwasniewski
okwasniewski deleted the krzysztof/feat/expect-to-be-in-viewport branch November 24, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e team Opened by the e2e team size:L Up to 499 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Portable toBeInViewport: assert that a match intersects the viewport without scrolling

5 participants