Skip to content

Fix flaky test_hybrid_properties controlled-input race#6682

Open
masenf wants to merge 1 commit into
mainfrom
claude/nice-mendel-it2al1
Open

Fix flaky test_hybrid_properties controlled-input race#6682
masenf wants to merge 1 commit into
mainfrom
claude/nice-mendel-it2al1

Conversation

@masenf

@masenf masenf commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

tests/integration/test_hybrid_properties.py::test_hybrid_properties is flaky on the integration-app-harness shards (seen on #6680/#6681 and reproducible across runs).

Root cause

The test clears the set_info_a input (Ctrl+A, Delete) and immediately types "z":

set_info_a.send_keys(Keys.CONTROL + "a")
set_info_a.send_keys(Keys.DELETE)
set_info_a.send_keys("z")
assert poll_for_content(info_a_b, exp_not_equal="info_a_b: a - b") == "info_a_b: z - b"

set_info_a is a controlled input (value=State.info.a, on_change=State.update_info_a), so each keystroke round-trips through the backend. Firing the clear and the type back-to-back races that async sync, intermittently producing:

  • info_a_b: az - b — the "z" is typed onto a stale "a" (clear hadn't re-rendered yet)
  • info_a_b: - b — the "z" is dropped by a late empty-state delta

…instead of the expected info_a_b: z - b. The non-deterministic values (two different wrong answers) confirm it's a timing race, not a logic bug. pytest-rerunfailures already retries 3× and still flakes.

Fix

Serialize the interaction — wait for the cleared value to round-trip to the backend (poll the backend-derived info_a_b text for "info_a_b: - b") before typing "z", then poll for the final "info_a_b: z - b". This mirrors the poll-between-interactions pattern already used in test_event_chain.py and removes the race without changing the app under test. The intermediate value ("info_a_b: - b") is exactly what Selenium returned in the observed failure.

Validation

ruff (format + check), pyright, and pytest collection pass locally. Behavioral validation is the integration-app-harness shards in CI — this PR exercises them directly.

🤖 Generated with Claude Code

https://claude.ai/code/session_017ELfV78gRoQiknTTEXctPs


Generated by Claude Code

test_hybrid_properties cleared the `set_info_a` input (Ctrl+A, Delete) and
immediately typed "z" before the clear had round-tripped to the backend. Since
the input is controlled by State.info.a, the rapid sequence raced the async
state sync, intermittently producing "info_a_b: az - b" (typed onto a stale
"a") or "info_a_b: - b" (the "z" dropped by a late empty-state delta) instead
of "info_a_b: z - b".

Serialize the interaction: after clearing, poll the backend-derived text until
it reflects the empty value ("info_a_b: - b") before typing "z", then poll for
the final "info_a_b: z - b". This mirrors the poll-between-interactions pattern
already used in test_event_chain.py and removes the race without changing the
app under test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ELfV78gRoQiknTTEXctPs
@masenf masenf requested a review from a team as a code owner June 25, 2026 23:23
@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a flaky integration test caused by a timing race on a controlled input. The fix adds an intermediate poll_for_content assertion that waits for the backend to confirm the cleared state ("info_a_b: - b") before sending the next keystroke, serializing the interaction and preventing the stale-state race.

  • Moves set_info_a.send_keys(\"z\") after an explicit poll for \"info_a_b: - b\", ensuring the clear round-trip has landed before the next key is sent.
  • Updates the second poll's exp_not_equal sentinel from \"info_a_b: a - b\" to \"info_a_b: - b\" to match the new intermediate state.

Confidence Score: 5/5

Safe to merge. The change is a single-file test-only fix with no impact on production code.

The change is entirely confined to a test file: it inserts a well-understood polling step between two Selenium interactions on a controlled input, following the same serialization pattern already used in test_event_chain.py. The intermediate assertion ("info_a_b: - b") is exactly what was observed in the failing CI runs, and the second poll's sentinel is correctly updated to match. No production code is touched.

No files require special attention.

Important Files Changed

Filename Overview
tests/integration/test_hybrid_properties.py Adds an intermediate poll_for_content assertion after clearing the controlled input, serializing the clear→retype interaction and eliminating the race condition that caused flaky test results.

Reviews (1): Last reviewed commit: "Fix flaky test_hybrid_properties control..." | Re-trigger Greptile

@codspeed-hq

codspeed-hq Bot commented Jun 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing claude/nice-mendel-it2al1 (d428fdd) with main (8b56f52)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

3 participants