Skip to content

fix(tests): Automations fixture tests fail when a presence check or editor write runs before its control appears - #2225

Merged
bkudiess merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-automations-presence-waits
Nov 14, 2026
Merged

bkudiess merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-automations-presence-waits

Conversation

@bkudiess

@bkudiess bkudiess commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #2216 (fix(tests): Automations fixture tests fail when an editor control's UI Automation element appears late)

What Problem This Solves

Fixes: Automations Mock Gateway fixture UI tests can still fail when a presence check, an expand or an editor write runs right after a wait on a different control, before UI Automation has published the control the test needs.

User Impact

User impact: there is no product change. Contributors see fewer false Automations fixture failures.

Why This Change Was Made

#2216 converted every FindById(...)! read in AutomationsUiTests.cs. Its review found the same race in forms the timing guard does not count, and that follow-up was deferred to this PR:

  • 17 readiness checks: Assert.NotNull(Find*(...)) checks that ran right after a wait on another control now wait for the control they check.
  • ExpandAutomation becomes ExpandAutomationAsync: it waits for the row's expander, then calls Expand once.
  • SetEditorValue becomes SetEditorValueAsync: it waits until the editor field is present and enabled, then writes once. A UIA write is never retried. The editor text fields are never disabled by the product, and a write to a disabled field already threw, so this matches what the old code needed.

Two presence checks stay immediate on purpose. They are retention checks: the loaded row must still be there after a refresh failure and after going offline. A wait there could hide a row that disappears and comes back, so each keeps its single read with a comment explaining why.

Added after this PR's first CI attempt. Shard B failed Automations_LargeAgendaPagesBeyondBrowseAndJumpsToInlineRow with Assert.InRange() Failure: Range (1 - 6), Actual: 0 (run 43572367590, job 132379360946). That line was not changed by this PR. The agenda list's UI Automation element appeared before its row buttons, and the test counted the rows once. The same "wait for the container, then read its children once" pattern is now fixed in three places:

  • Initial agenda rows: the test waits until the list has at least one agenda row. Assert.InRange(1, 6) then checks the rows from that same poll, so the upper limit is still checked immediately.
  • Expanded group: the wait for more list items now also requires the "Scheduled fixture 204" item and keeps it. Before, a later .First() read failed if the item wasn't there yet.
  • Offline "Schedule as of" text: the app shows this text only when it goes offline, and the test had waited on a different control. This is a readiness check, so it now waits for the text.

Deliberately left as immediate reads:

  • the baseline item count (it only sets the starting point for a later "more items" wait);
  • the toast close-button check (it is part of the toast persistence proof);
  • absence checks.

The remaining ?? throw lookups are left as they are:

  • the editor-scroll helper (already preceded by a wait for all of its controls);
  • the page scroll helper;
  • the screenshot helper SaveAutomationsWindow, which has about 30 synchronous call sites and belongs in a separate change.

Evidence

  • Root cause: the same Reactor sibling-publishing gap documented in fix(tests): Automations fixture tests fail when an editor control's UI Automation element appears late #2216, where the CI screenshot showed the control rendered while the test's single lookup returned null. A local probe could not force that gap, so there is no deterministic RED. Each converted step now waits for the control it uses.
  • Review: dual-model Hanselman review (Claude Opus 5.5 and GPT-6 Astra long-context, both high effort), plus a delta review.
    • Both models (HIGH consensus): converting the two retention checks into waits would weaken them. Fixed: both are restored as immediate reads with a comment.
    • Opus LOW, not changed: the retention checks could compare UIA runtime IDs before and after. The restored reads are as strict as on main.
    • Opus LOW, pre-existing: on the second Save pass, the "Complete the required fields" message may still be showing from the first pass.
    • Both delta reviews were clean.
    • A second delta review covered the agenda-row fix. Both models found no issues, and both confirmed the "Schedule as of" check is a readiness check, not a retention check.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • none: test-only change to Mock Gateway fixture UI tests that CI runs directly.

Validation

All runs were local on Windows x64 at 175% DPI, with isolated profiles. Metadata for the real %APPDATA%/%LOCALAPPDATA%\OpenClawTray was unchanged after every run.

Check Result
All Automations fixture tests in this file except HeroWash and ScopesToAgents (12 test cases) 3/3 passed
Automations_LoadingErrorsRefreshAndOfflineKeepHonestStates (retention checks) on the final source 3/3 passed
Automations_LargeAgendaPagesBeyondBrowseAndJumpsToInlineRow and Automations_LoadingErrorsRefreshAndOfflineKeepHonestStates after the agenda-row fix 5/5 passed
Automations_ScopesToAgentsAndCoversMainStates Change: 3 of 4 isolated runs passed, and it failed in both full-file runs. Unmodified main 86b17b750: 2 of 3 runs passed. Every failure is the same intermittent local Axe "BoundingRectangle must be at least 25 pixels" result at a different scan (editor or remove confirmation). This test passed on #2216's CI, including its soak.
Automations_HeroWashScrollsWhileTheBackplateStaysAnchored Not run. It fails locally on main too (DPI), as recorded in #2216.
  • .\scripts\validate-test-timing-patterns.ps1: passed. These patterns are not counted by the guard, so the baseline is unchanged.
  • ./build.ps1: all builds succeeded.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj: 5876 passed, 0 failed, 29 skipped.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj: 6669 passed, 0 failed.

Real Behavior Proof

  • Environment tested: local Windows x64 desktop, 175% DPI, isolated profiles.
  • PR head or commit tested: eafd3f5 (on main 86b17b750). The test source is identical to the validated tree.
  • Exact steps or command run: dotnet test tests/OpenClaw.Tray.UITests -c Debug -r win-x64 -p:DevBuild=false --no-build --filter "FullyQualifiedName~.Automations_" with OPENCLAW_RUN_GATEWAY_FIXTURE_UI=1, plus the filters above.
  • Evidence after fix: the pass counts above.
  • Observed result: presence checks, expands and editor writes wait for their own control. Retention checks still read once.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A (local artifacts only).
  • Not verified or blocked:
    • The first CI attempt (head d31c6ea) failed on the agenda-row race described above. The result for head eafd3f5 is pending.
    • The intermittent local Axe size result in ScopesToAgents is pre-existing and not addressed here.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): No
  • Command or tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

…edits

Follow-up from the openclaw#2216 review. Presence checks and helper lookups that
ran right after a wait on a different control could still miss a Reactor
sibling whose UIA peer was not published yet.

- 17 Assert.NotNull(Find*(...)) readiness checks now wait for the control.
- ExpandAutomation and SetEditorValue become async: they wait for the
  expander or the enabled value peer, then act once.
- The two retention checks (the loaded row after a refresh failure and
  after going offline) stay immediate reads, so a removed row still fails.

Co-authored-by: Copilot App <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR makes Automations fixture presence checks, expands, and editor writes wait for their own UI Automation controls.

Example: The editor name field appears before AutomationEditorPrompt is reachable through UI Automation.

  • Before: Writing "Resize-kept prompt" can throw because the prompt field lookup returns null.
  • After: The test waits for the enabled prompt field and writes the value once.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-correct; validation confidence rests on reported native runs while exact-head fixture and soak checks remain unfinished.
Proof confidence 🦐 gold shrimp (3/6) Only fixture readiness changes; no shipped-entry-point proof is required, and the reported native runs are supporting test evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Contributors can encounter false Automations fixture failures when UI Automation publishes sibling controls at different times.
Reason: The maintainer-authored follow-up addresses documented deferred work with a small test-only change and preserves the existing behavioral assertions.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it completes useful readiness handling left by the merged predecessor, and the reviewed diff introduces no concrete defect. Maintainer authorship also prevents automatic closure.

Priority: P3
Reviewed head: d31c6eace7e4c10d18914ae9c19eb4013146219c

Before merge

None.

Findings

None.

Agent review details

How this fits together

Automations fixture tests drive the native Companion against a synthetic Gateway, inspect controls through UI Automation, and assert rendered state and Gateway requests.

flowchart LR
  A[Fixture scenario] --> B[Synthetic Gateway]
  B --> C[Native Companion]
  C --> D[UI Automation controls]
  D --> E[Existing readiness helpers]
  E --> F[Test actions and assertions]
Loading

Technical review

Best possible solution:

Keep readiness handling in the existing fixture helpers while preserving single-attempt mutations and immediate retention assertions.

Do we have a high-confidence way to reproduce the issue?

Main's immediate lookups demonstrably fail if the required UIA peer appears late, but the precise publishing gap at these follow-up sites has no deterministic reproduction or observed failing run.

Is this the best way to solve the issue?

The patch is a focused extension of the existing readiness strategy: wait for the actual control, retain that capture, and perform mutations once without weakening retention checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against bb9cc8acdc1b.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Change footprint Production +0/-0; tests +43/-40 The small net growth reuses existing readiness helpers without adding test cases, fixture processes, or production machinery.

Labels

Label changes:

  • add P3: This improves contributor-facing test reliability without changing shipping product behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This improves contributor-facing test reliability without changing shipping product behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 14, 2026, 2:55 AM ET / 07:55 UTC.

Automations_LargeAgendaPagesBeyondBrowseAndJumpsToInlineRow failed on
openclaw#2225's first attempt with "Assert.InRange() Failure: Range (1 - 6),
Actual: 0": the agenda list peer was published before its row buttons and
the test counted them once.

- Wait until the list has at least one agenda row, and keep the 1-6 range
  assertion on the rows from that same poll.
- The expanded-group wait now also requires the target item and captures
  it, instead of a later .First() read.
- The offline "Schedule as of" text is a readiness check after waiting on
  another control, so it now waits for the text.

Co-authored-by: Copilot App <[email protected]>
@bkudiess
bkudiess merged commit f40d5d0 into openclaw:main Nov 14, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant