-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Re-enabled flaky UI test TextInEditorShouldScroll #29167
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
Merged
PureWeen
merged 4 commits into
dotnet:inflight/current
from
NirmalKumarYuvaraj:fix-29025
May 5, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
496e560
Fixed flaky editor test
NirmalKumarYuvaraj 9768c82
Added scroll down again to double check
NirmalKumarYuvaraj 44eb18d
Optimized code changes and added new test snapshots
NirmalKumarYuvaraj 7857d87
Added missing WinUI snap
NirmalKumarYuvaraj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
+6.86 KB
(130%)
...ls/tests/TestCases.Android.Tests/snapshots/android/TextInEditorShouldScroll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| #if MACCATALYST | ||
| using UIKit; | ||
| using Microsoft.Maui.Platform; | ||
| #endif | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 19500, "[iOS] Editor is not be able to scroll if IsReadOnly is true", PlatformAffected.iOS)] | ||
| public partial class Issue19500 : TestContentPage | ||
| { | ||
| const string BaseEditorText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla porttitor mauris non ornare ultrices. Ut semper ultrices justo eget semper.Ut imperdiet dolor ut vestibulum molestie. Duis a libero ex. Etiam mi urna, lobortis sed tincidunt in, tempus eget magna. Aenean quis malesuada eros. Phasellus felis eros, condimentum et tortor sed, condimentum convallis turpis. Sed in varius metus, at auctor orci. Maecenas luctus nibh nibh, nec aliquam est fermentum in. Etiam consectetur lectus erat, sed placerat sapien rutrum eu. Suspendisse tincidunt fermentum tempor.Maecenas egestas neque nec lacinia fringilla."; | ||
|
|
||
| protected override void Init() | ||
| { | ||
| var rootLayout = new VerticalStackLayout | ||
| { | ||
| Spacing = 10, | ||
| Padding = 10 | ||
| }; | ||
|
|
||
| var descriptionLabel = CreateLabel( | ||
| "This test case is to verify that the Editor is scrollable when IsReadOnly is set to true.", | ||
| "descriptionLabel"); | ||
|
|
||
| var yPositionLabel = CreateLabel("0", "yPositionLabel"); | ||
|
|
||
| var editor = CreateEditor(yPositionLabel); | ||
|
|
||
| rootLayout.Children.Add(descriptionLabel); | ||
| rootLayout.Children.Add(editor); | ||
| rootLayout.Children.Add(yPositionLabel); | ||
|
|
||
| Content = rootLayout; | ||
| } | ||
|
|
||
| Label CreateLabel(string text, string automationId) => | ||
| new Label | ||
| { | ||
| Text = text, | ||
| AutomationId = automationId | ||
| }; | ||
|
|
||
| Editor CreateEditor(Label yPositionLabel) | ||
| { | ||
| var editor = new Editor | ||
| { | ||
| HeightRequest = 100, | ||
| IsReadOnly = true, | ||
| AutomationId = "editor", | ||
| Text = GetEditorText() | ||
| }; | ||
|
|
||
| #if MACCATALYST | ||
| editor.HandlerChanged += (_, _) => | ||
| { | ||
| if (editor.Handler?.PlatformView is MauiTextView mauiTextView) | ||
| { | ||
| mauiTextView.Scrolled += (s, e) => | ||
| { | ||
| if (s is UIScrollView scrollView) | ||
| { | ||
| yPositionLabel.Text = scrollView.ContentOffset.Y.ToString(); | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
| #endif | ||
|
|
||
| return editor; | ||
| } | ||
|
|
||
| private string GetEditorText() | ||
| { | ||
| #if MACCATALYST | ||
| return BaseEditorText + " " + BaseEditorText; | ||
| #else | ||
| return BaseEditorText; | ||
| #endif | ||
| } | ||
| } |
14 changes: 0 additions & 14 deletions
14
src/Controls/tests/TestCases.HostApp/Issues/Issue19500.xaml
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/Controls/tests/TestCases.HostApp/Issues/Issue19500.xaml.cs
This file was deleted.
Oops, something went wrong.
42 changes: 22 additions & 20 deletions
42
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19500.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,31 @@ | ||
| #if TEST_FAILS_ON_CATALYST // Since this test verifies the scrolling behavior in the editor control and the App.ScrollDown function is inconsistent, relying on screenshot verification causes flakiness in CI. It needs to be validated using an alternative approach, or else it would be better to consider this for manual testing. | ||
| // Issue for reenable: https://github.com/dotnet/maui/issues/29025 | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
| public class Issue19500 : _IssuesUITest | ||
| { | ||
| public class Issue19500 : _IssuesUITest | ||
| { | ||
| public override string Issue => "[iOS] Editor is not be able to scroll if IsReadOnly is true"; | ||
| public override string Issue => "[iOS] Editor is not be able to scroll if IsReadOnly is true"; | ||
|
|
||
| public Issue19500(TestDevice device) : base(device) | ||
| { | ||
| } | ||
| const string yPositionLabel = "yPositionLabel"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Editor)] | ||
| public void TextInEditorShouldScroll() | ||
| { | ||
| _ = App.WaitForElement("editor"); | ||
| App.ScrollDown("editor"); | ||
| public Issue19500(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| // The test passes if the text inside the editor scrolls down | ||
| VerifyScreenshot(); | ||
| } | ||
| [Test] | ||
| [Category(UITestCategories.Editor)] | ||
| public void TextInEditorShouldScroll() | ||
| { | ||
| var yPosLabel = App.WaitForElement(yPositionLabel); | ||
| App.ScrollDown("editor"); | ||
| #if MACCATALYST | ||
| App.ScrollDown("editor"); // To make sure the editor is scrolled down | ||
| var yPos = yPosLabel.GetText(); | ||
| Assert.That(yPos,Is.GreaterThan("0")); // The Y position should be greater than 0 after scrolling down | ||
| #else | ||
| // The test passes if the text inside the editor scrolls down | ||
| VerifyScreenshot(); | ||
| #endif | ||
| } | ||
| } | ||
| #endif | ||
| } | ||
Binary file modified
BIN
+2.52 KB
(110%)
...rols/tests/TestCases.WinUI.Tests/snapshots/windows/TextInEditorShouldScroll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+7.65 KB
(120%)
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/TextInEditorShouldScroll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just a note — since this is a UITest, ideally we should verify that scrolling is visually reflected in the UI. Relying on
ContentOffset.Y > 0introduces a logical check, but it doesn’t fully guarantee a visible change occurred on screen.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.
@bhavanesh2001 , The test is to check whether the editor is scrollable or not. The previous UI test was flaky because the content was scrolled a pixel off from its original position. So instead of relying on a visual confirmation, I went with an alternative approach. The Y position label text will be updated only if the editor is scrolled. Otherwise it stays as 0.
This is added only to MAC to resolve flaky issue on CI.