Skip to content

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

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-automations-agenda-flake
Nov 14, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-automations-agenda-flake

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

Related: #2193 (same one-shot lookup class in the Dashboards fixture test)

What Problem This Solves

Fixes: the Automations Mock Gateway fixture UI tests intermittently fail with NullReferenceException when the test reads an editor or row control that UI Automation has not published yet. Latest occurrence: Automations_DesignerAgendaBudgetAndResizeKeepExpansionAndDialogDraft on main b713f345, run 43544397293, job 132292249802 (fixture UI shard B, 6 s in). Automations_DesignerValidationFocusAndDraftsStayIsolated had the same NullReferenceException on main on 11-13.

User Impact

User impact: there is no product change. Contributors stop seeing false Automations fixture failures.

Why This Change Was Made

The CI stack points at AutomationsUiTests.cs:96, Invoke(FindById(run, "AutomationEditorSave")!). It runs right after a wait for the editor's Name field.

The failure screenshot shows the New automation editor open, with its Create automation button rendered. So the app was fine. The Name field's UI Automation element was published before the footer button's element was reachable, and the single lookup caught that moment. Both are rendered by the same Reactor editor (AutomationEditor.cs), so a wait on one does not guarantee the other.

This file had 68 such one-shot lookups. All of them are now bounded waits:

  • An action waits until its control is present and enabled, then invokes it once. A UIA action is never retried. The Save and Cancel buttons are enabled except while saving, so this matches what the old code needed.
  • A read waits until the control is present and keeps the element it found.
  • Code inside an existing wait treats a missing control as "not ready yet" instead of throwing.
  • The Pause and Remove confirmation buttons are found again inside the wait, not taken from an earlier lookup of the dialog.

State assertions are unchanged. They still read the value once, right after the wait. The error-toast persistence check stays a single immediate read on purpose, because it proves the toast is still there after a fixed time.

From review, the same race was also fixed on the failing tests' paths in three places the guard does not count: the editor values read right after a resize, the Discard draft presence check, and the navigation-pane toggle invoke.

The repository timing baseline entry for this file is removed: its one-shot lookup count drops from 68 to 0. The change adds no retries, sleeps, fixed settle counts, skips or weaker assertions.

Evidence

  • Root cause: the CI stack (line 96, the one-shot Save lookup after the Name wait), and the CI failure screenshot showing the editor and its footer button rendered.
  • Deterministic RED/GREEN: not feasible. A local probe opened the editor 36 times. Each time the Name field first appeared, Save was already reachable, so the CI publishing gap does not reproduce here. The fix makes each lookup wait for the element it uses, rather than claiming a reproduced race.
  • Review: dual-model Hanselman review (Claude Opus 5.5 and GPT-6 Astra long-context, both high effort), plus a delta review of the follow-up.
    • Neither found a CRITICAL or HIGH issue. Astra found no issues.
    • Applied: Opus MEDIUM (one model only). Three one-shot lookups on the failing tests' paths use a form the guard does not count. They are converted as described above.
    • Deferred: the rest of that Opus MEDIUM. Other Assert.NotNull(FindById(...)) presence checks, and the ?? throw lookups inside ExpandAutomation and SetEditorValue, are left for a follow-up to keep this PR scoped. No CI failures are known at those lines.
    • Both delta reviews were clean.

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
Automations_DesignerAgendaBudgetAndResize… and Automations_DesignerValidationFocus… 10/10 passed, then 5/5 on the final source
Automations_ResponsiveShellWidthsHaveDistinctMeasuredFrames 5/5 passed on the final source
Every other Automations fixture test in this file (12 test cases, including theory variants) 3/3 passed
SessionHistoryRestoresSelectionTranscriptAndDraftAcrossAgents (other caller of the refactored InvokeWhenEnabledAsync) 3/3 passed
Automations_HeroWashScrollsWhileTheBackplateStaysAnchored Fails locally, and also fails the same way on unmodified main d1316cc09 ("The wash did not follow the hero"). This is a local DPI issue, not caused by this change.
  • .\scripts\validate-test-timing-patterns.ps1: passed. The AutomationsUiTests.cs one-shot lookup entry is removed (68 to 0).
  • ./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: 6668 passed, 0 failed.
  • Rebased onto main a7fd19432. That commit did not touch these test files, and the guard passed after the rebase.

Real Behavior Proof

  • Environment tested: local Windows x64 desktop, 175% DPI, isolated profiles.
  • PR head or commit tested: 614dc95. The test source is identical to the validated pre-rebase 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 repeated filters above.
  • Evidence after fix: the pass counts above.
  • Observed result: every editor, row and dialog action in these tests waits for its own control before use.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A (local artifacts only).
  • Not verified or blocked:
    • The first-attempt CI result for this PR is pending.
    • Automations_PinnedHostToggleHitTabAndBanner (keyboard proof, in another file) also fails locally at 175% DPI on main. It does not use any helper changed 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.

Automations_DesignerAgendaBudgetAndResizeKeepExpansionAndDialogDraft threw a
NullReferenceException on main b713f34 at Invoke(FindById("AutomationEditorSave")!)
right after waiting for AutomationEditorName. The failure screenshot shows the
editor open with its footer button rendered, so Reactor had published the Name
peer before the footer Save peer was reachable through UIA.

Sweep every one-shot FindById(...)! read in AutomationsUiTests.cs into bounded
waits: invocations wait for the peer to be present and enabled and invoke once,
reads wait for presence and keep the polled peer, and lambdas inside waits treat
a missing peer as not ready. Assertions on state stay immediate after the wait.
The one-shot lookup baseline for this file drops from 68 to 0.

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. 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. 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

The PR replaces one-shot Automations UI Automation lookups with bounded readiness waits and lowers the timing-pattern baseline.

Example: Automations_DesignerAgendaBudgetAndResizeKeepExpansionAndDialogDraft opens the new automation editor.

  • Before: AutomationEditorName appears before AutomationEditorSave, and invoking the missing Save element throws NullReferenceException.
  • After: The test waits for AutomationEditorSave to exist and be enabled, then invokes it once.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-supported; validation consists of reported native fixture runs and partially completed CI, without deterministic reproduction of the intermittent gap.
Proof confidence 🦐 gold shrimp (3/6) This test-only maintainer PR needs no separate shipped-behavior proof; its reported Windows fixture runs exercise the changed readiness helpers, and deterministic pre-fix reproduction is explicitly unavailable.
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 encounter false Automations fixture failures when required UIA elements appear after sibling controls.
Reason: The maintainer-authored repair follows documented test policy and preserves the underlying product assertions.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs a null-dereference path still present on main; no introduced correctness or security defect was found.

Priority: P3
Reviewed head: 614dc95ad7511001bcdd710d6414e401316d3769

Before merge

None.

Findings

None.

Agent review details

How this fits together

The fixture UI tests drive the real Windows app through UI Automation against a synthetic Gateway and turn rendered control state into assertions.

flowchart LR
  A[Fixture UI test] --> B[Bounded readiness wait]
  B --> C[Windows UI Automation]
  C --> D[Native Automations controls]
  D --> E[State assertions]
Loading

Technical review

Best possible solution:

Use the existing fixture readiness owners to acquire each required control before use while preserving single invocations and independent state assertions.

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

Source confirms that a missing Save peer after the Name-field wait reaches an unguarded invocation; the intermittent publication gap was not reproduced locally, as the author explicitly reports.

Is this the best way to solve the issue?

The change follows the existing readiness contract, retains each successful capture, and preserves invoke-once semantics without weakening the tested state.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Automations fixture readiness and invocation keeps the original intent (994539b: The native Automations feature added fixture coverage and an enabled-control helper that explicitly invokes mutations only once.)
  • Hero-wash geometry checks keeps the original intent (df302df: The earlier repair settled maximized geometry before comparing hero and viewport measurements; this PR preserves those assertions.)
  • Timing-pattern baseline keeps the original intent (ee8edbc: The ratchet blocks growth in timing-sensitive patterns and allows its baseline to shrink when matched occurrences are removed.)

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 and baseline +132/-105 Growth is confined to readiness handling in existing tests; no production machinery or additional test processes are introduced.

Labels

Label changes:

  • add P3: This improves contributor-facing fixture 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 fixture 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, 12:20 AM ET / 05:20 UTC.

@bkudiess
bkudiess merged commit 86b17b7 into openclaw:main Nov 14, 2026
35 checks passed
bkudiess added a commit that referenced this pull request Nov 14, 2026
…ditor write runs before its control appears (#2225)

* test(automations): wait for sibling peers before presence checks and edits

Follow-up from the #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]>

* test(automations): wait for agenda rows before counting them

Automations_LargeAgendaPagesBeyondBrowseAndJumpsToInlineRow failed on
#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]>

---------

Co-authored-by: Copilot App <[email protected]>
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