Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Fixes a race condition in the RemoveInnerPage unit test that was causing random failures on CI.

Issue

The test was failing randomly on CI because it didn't wait for the async navigation to complete after calling nav.Navigation.RemovePage(pageToRemove).

Root Cause

  • The TestNavigationHandler simulates async navigation with a 10ms delay
  • The test would complete immediately after calling RemovePage
  • If the navigation completed after the test finished, the Appearing/Disappearing event handlers would throw exceptions that weren't caught by the test framework
  • This created a race condition where the test would pass or fail randomly depending on timing

Changes

  1. Changed nav declaration from NavigationPage to var to preserve the TestNavigationPage type
  2. Added await nav.NavigatingTask; after RemovePage call to ensure the test waits for navigation to complete

This matches the pattern used in the RemoveLastPage test in the same file (line 122).

Testing

  • Ran the test 50+ times locally - all passed
  • The fix ensures deterministic behavior by properly awaiting async operations

API Changes

None

Behavioral Changes

None - this only fixes test infrastructure

PR Checklist

  • Has tests (existing test is fixed)
  • Focused on a single change
  • Follows code style guidelines

The RemoveInnerPage test was failing randomly on CI due to a race condition:
- The test removed a page but didn't wait for navigation to complete
- TestNavigationHandler simulates async navigation with a 10ms delay
- If the test completed before navigation finished, Appearing/Disappearing
  events could fire after test completion, throwing uncaught exceptions

Fixed by:
1. Changed nav declaration from NavigationPage to var (TestNavigationPage)
2. Added await nav.NavigatingTask after RemovePage call

This matches the pattern used in the RemoveLastPage test and ensures
the test waits for async navigation to complete before finishing.
Copilot AI review requested due to automatic review settings November 21, 2025 07:33
Copilot finished reviewing on behalf of StephaneDelcroix November 21, 2025 07:35
Copy link
Contributor

Copilot AI left a comment

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 race condition in the RemoveInnerPage unit test that was causing intermittent failures on CI. The test was completing before asynchronous navigation finished, causing event handlers to fire after test completion and throw uncaught exceptions.

Key changes:

  • Modified variable declaration to preserve TestNavigationPage type access
  • Added proper await for navigation completion to ensure deterministic test behavior

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