Skip to content

Conversation

@HarishKumarSF4517
Copy link
Contributor

This pull request updates the VerifyEditorFocusedEvent test 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:

  • Changed VerifyEditorFocusedEvent in EditorFeatureTests.cs to be an async Task, and added a Task.Delay(100) after tapping the editor to ensure the focus event has time to trigger before the test assertion.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Oct 7, 2025
@HarishKumarSF4517 HarishKumarSF4517 marked this pull request as ready for review October 7, 2025 13:22
Copilot AI review requested due to automatic review settings October 7, 2025 13:22
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

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);
Copy link

Copilot AI Oct 7, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Member

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 ?

Copy link
Contributor Author

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 :

@rmarinho
Copy link
Member

rmarinho commented Oct 7, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@sheiksyedm sheiksyedm added the area-testing Unit tests, device tests label Oct 7, 2025
@rmarinho
Copy link
Member

rmarinho commented Oct 8, 2025

/rebase

@github-actions github-actions bot force-pushed the harish_flakytest_fix04 branch from b68c8f6 to b042bf7 Compare October 8, 2025 18:43
@rmarinho
Copy link
Member

rmarinho commented Oct 9, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

{
App.WaitForElement("TestEditor");
App.Tap("TestEditor");
await Task.Delay(100);
Copy link
Contributor

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)
?

Copy link
Contributor Author

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.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@sheiksyedm
Copy link
Contributor

/rebase

@github-actions github-actions bot force-pushed the harish_flakytest_fix04 branch from 3df4086 to e821c1d Compare December 17, 2025 08:23
@github-project-automation github-project-automation bot moved this from Todo to Approved in MAUI SDK Ongoing Dec 17, 2025
@jfversluis jfversluis merged commit c72249f into dotnet:main Dec 17, 2025
141 of 159 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-testing Unit tests, device tests community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration testing-flakiness

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants