Skip to content

playwright: fix wait_for_hover false-pass on missing widget + cover both #186 sync primitives#187

Merged
borisbat merged 2 commits into
masterfrom
bbatkin/recording-sync-tests
Jun 6, 2026
Merged

playwright: fix wait_for_hover false-pass on missing widget + cover both #186 sync primitives#187
borisbat merged 2 commits into
masterfrom
bbatkin/recording-sync-tests

Conversation

@borisbat

@borisbat borisbat commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Follow-up to the #186 Copilot review — a real correctness fix plus the regression coverage it asked for.

Fix — wait_for_hover(expected=false) false-pass (#186 review)

wait_for_hover(ident, expected=false) returned the first snapshot when the widget was missing or had no hover field: the predicate find_widget(...)?["hover"] ?? false == expected coalesces a null hover to false, so a typo'd / unregistered ident reads as a successful "not hovered" and masks a real sync failure.

Guard with widget_exists — the same load-bearing check widget_rendered already uses for the identical daslib/json ?[] quirk (find_widget(...) != null is unreliable there; only a non-empty kind proves a real entry). The widget must actually be present before its hover state is compared:

return wait_until_sec(app, timeout_sec) $(var snap) {
    return widget_exists(snap, widget_ident) && (find_widget(snap, widget_ident)?["hover"] ?? false) == expected
}

Same false-positive discipline as widget_rendered / wait_for_series_shown. Only expected=false on a missing ident changes behavior (now times out → null → loud failure, instead of an immediate false pass); no existing caller relied on the old path.

Coverage — tests/integration/test_recording_sync.das (#186 review)

No dasImgui-side test exercised either primitive #186 added. New test (one app spawn, color_button_hover feature — CBH_RED carries the per-widget IsItemHovered telemetry):

  • wait_for_hover: registers hover after move_to onto the swatch; clears after moving away (expected=false on a present widget); does NOT false-pass a missing ident (the regression above).
  • record_check: returns its ok argument, and accumulates without panicking on false — the accumulate-don't-panic discipline. (The teardown-panic surfacing is exercised transitively by every record_* driver in the suite, which all share the g_record_failureswith_recording_app teardown path.)

Verification (local)

  • test_recording_sync green headless.
  • Lint + format clean (pre-push verified).

🤖 Generated with Claude Code

…oth #186 primitives

Copilot review on PR #186:

- wait_for_hover(ident, expected=false) false-passed when the widget was missing or
  had no `hover` field: the predicate `find_widget(...)?["hover"] ?? false == expected`
  coalesced a null hover to false, so a typo'd / unregistered ident read as a
  successful "not hovered" and masked a real sync failure. Guard with widget_exists
  (the same load-bearing check widget_rendered uses for the identical daslib/json ?[]
  quirk): the widget must actually be present before its hover state is compared.

- Add tests/integration/test_recording_sync.das covering both primitives #186 added
  (no dasImgui-side test exercised either): wait_for_hover registers on move-onto /
  clears on move-away / does NOT false-pass a missing ident (the regression above),
  and record_check returns its `ok` and accumulates-without-panicking on false (the
  teardown-panic surfacing is exercised transitively by the record_* driver suite).

Verified: test_recording_sync green headless; lint + format clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a correctness edge case in imgui_playwright.wait_for_hover(expected=false) where a missing/misspelled widget ident could incorrectly “pass” as “not hovered”, and adds an integration test covering both wait_for_hover and record_check (introduced in #186).

Changes:

  • Fix wait_for_hover(..., expected=false) to require widget_exists(...) before comparing hover state, preventing false positives on missing widgets.
  • Add tests/integration/test_recording_sync.das to exercise wait_for_hover (hover set/clear + missing-ident regression) and record_check’s return behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
widgets/imgui_playwright.das Adds a widget_exists guard inside wait_for_hover to avoid false-passing on missing widget idents.
tests/integration/test_recording_sync.das New integration test covering wait_for_hover hover transitions and the missing-ident regression, plus basic record_check behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/integration/test_recording_sync.das Outdated
Copilot review on PR #187: the negative-case regression check waited out a full 2s
every run (the widget is guaranteed missing, so it always times out). A tiny timeout
still separates the two implementations — the old false-pass returned non-null on the
first poll, the fixed version times out — without spending the wall-clock.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@borisbat borisbat merged commit 4c14ab0 into master Jun 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants