-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Testing] Fix for flaky test(VerifyEditorFocusedEvent) in CI #31895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Testing] Fix for flaky test(VerifyEditorFocusedEvent) in CI #31895
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Stabilizes a flaky UI test by converting it to async and inserting a delay to allow the focus event to propagate before assertion.
- Change test signature to async Task to support awaiting operations
- Insert 100 ms Task.Delay after tapping the editor to mitigate timing race
- Preserve existing assertion logic for the Focused event label
| { | ||
| App.WaitForElement("TestEditor"); | ||
| App.Tap("TestEditor"); | ||
| await Task.Delay(100); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a fixed delay introduces a magic number and can remain flaky on slower CI agents while adding unnecessary wait on fast machines. Prefer a condition-based wait/poll that exits as soon as the label reflects the focused state, e.g., loop with small delays until App.WaitForElement("FocusedLabel").GetText() == "Focused: Event Triggered" or timeout. This removes the arbitrary 100 ms constant and makes the test both faster and more reliable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I m not sure just adding the delay is going to work, do we have another way to know the keyboard is dismissed ? is there a event that fires when the keyboard is hidden ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rmarinho, similar delay adjustments were added in .NET 10 to dismiss the keyboard on CI. Therefore, I used the same approach in the Main branch, and the test has now passed in this PR.
.NET 10 Code reference :
maui/src/Controls/tests/TestCases.Shared.Tests/Tests/FeatureMatrix/EditorFeatureTests.cs
Line 74 in 7114e69
| await Task.Delay(100); |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
b68c8f6 to
b042bf7
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| { | ||
| App.WaitForElement("TestEditor"); | ||
| App.Tap("TestEditor"); | ||
| await Task.Delay(100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could include a Label in the sample, and verify the text ("Focused Editor" for example). Also, before close the keyboard, can use
| public static bool IsKeyboardShown(this IApp app) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jsuarezruiz, I have added isKeyboardShown method to the test and the label were already added to the sample to verify that the focused editor event is triggered correctly.
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
8894139 to
3df4086
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
3df4086 to
e821c1d
Compare
This pull request updates the
VerifyEditorFocusedEventtest method to be asynchronous, improving reliability by adding a short delay after tapping the editor. This ensures the focus event is properly triggered before the assertion is made.Test reliability improvement:
VerifyEditorFocusedEventinEditorFeatureTests.csto be anasync Task, and added aTask.Delay(100)after tapping the editor to ensure the focus event has time to trigger before the test assertion.