Skip to content

test: Fix flaky NavigationView toggle test on WinUI - #23610

Merged
MartinZikmund merged 1 commit into
masterfrom
dev/xygu/20260630/fix-win-flaky-navview-test
Jul 1, 2026
Merged

MartinZikmund merged 1 commit into
masterfrom
dev/xygu/20260630/fix-win-flaky-navview-test

Conversation

@Xiaoy312

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #23561

PR Type:

🐞 Bugfix

What changed? 🚀

Given_NavigationView.When_CompactPaneLength_Changed_PaneToggleButton_Updates was flaky on native WinUI (winappsdk) — it intermittently failed with Toggle button should grow: 200 -> 200 (only on WinUI, not Skia Desktop).

Root cause (test timing, not a product bug): the test runs against Microsoft's own NavigationView on WinUI, which is the reference implementation, so its behavior is correct by definition. After CompactPaneLength changes, the value flows source → TemplateSettings → binding → TogglePaneButton.MinWidth synchronously, but the re-arrange that updates ActualWidth happens asynchronously. A single WaitForIdle() sometimes returned before that arrange pass flushed. The failure state was internally inconsistent (MinWidth=292 while ActualWidth=200), confirming the layout simply hadn't settled — the value arrives, just late.

Fix: the upstream TemplateSettings/MinWidth assertions stay eager (they settle first, preserving the granular diagnostic), and only the racy ActualWidth check is replaced with a polling WindowHelper.WaitFor(...) (3s timeout). This corrects a wrong timing assumption in the test — a root-cause fix, not defensive hardening.

Validation: built the WinAppSDK SamplesApp MSIX and ran the test against native WinUI — 9/9 consecutive passes (1 initial + 8 reruns). Previously it flaked on this path.

PR Checklist ✅

🤖 Generated with Claude Code

The When_CompactPaneLength_Changed_PaneToggleButton_Updates test was
unstable on native WinUI (winappsdk). After changing CompactPaneLength,
the binding-driven MinWidth updates before the button is re-arranged, so
ActualWidth catches up asynchronously and a single WaitForIdle was
sometimes insufficient. Poll for the width to settle instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 30, 2026 22:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates a NavigationView runtime test to reduce flakiness by avoiding an immediate ActualWidth assertion after CompactPaneLength changes, which can race with an asynchronous layout pass (notably on native WinUI).

Changes:

  • Replaces the immediate toggleButton.ActualWidth assertion with a WindowHelper.WaitFor(...) poll (3s timeout).
  • Adds a comment explaining the WinUI layout/binding timing behavior that motivated the change.

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

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund enabled auto-merge July 1, 2026 06:18
@MartinZikmund
MartinZikmund merged commit 6141cb1 into master Jul 1, 2026
48 checks passed
@MartinZikmund
MartinZikmund deleted the dev/xygu/20260630/fix-win-flaky-navview-test branch July 1, 2026 06:18
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.

[Tests] NavigationView When_CompactPaneLength_Changed_PaneToggleButton_Updates is flaky on WinUI

4 participants