Skip to content

Commit 22526cc

Browse files
authored
Fix flaky test (#3381)
Also fixes some tests that were always outputting screenshots on success.
1 parent 91b82a3 commit 22526cc

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

MaterialDesignThemes.UITests/AllStyles.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,7 @@ await App.Initialize(applicationResourceXaml,
8383
""");
8484

8585
Assert.True(await window.GetIsVisible());
86+
87+
recorder.Success();
8688
}
8789
}

MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,23 @@ public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated()
6060
Assert.True(await suggestBox.GetIsSuggestionOpen());
6161
Assert.True(await popup.GetIsOpen());
6262

63+
double? lastHeight = null;
64+
await Wait.For(async () =>
65+
{
66+
double currentHeight = await suggestionListBox.GetActualHeight();
67+
68+
bool rv = currentHeight == lastHeight && currentHeight > 50;
69+
lastHeight = currentHeight;
70+
if (!rv)
71+
{
72+
await Task.Delay(100);
73+
}
74+
return rv;
75+
});
76+
6377
//Choose Item from the list
64-
await Task.Delay(200);
6578
var bananas = await suggestionListBox.GetElement<ListBoxItem>("/ListBoxItem[0]");
66-
await Wait.For(async () => await bananas.GetIsVisible());
79+
await recorder.SaveScreenshot("BeforeClick");
6780
await bananas.LeftClick();
6881
var suggestBoxText = await suggestBox.GetText();
6982
//Validate that the current text is the same as the selected item

MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ await Wait.For(async() =>
610610

611611
Assert.Equal("Some error + more", await textBlock.GetText());
612612
});
613+
614+
recorder.Success();
613615
}
614616
}
615617

MaterialDesignThemes.Wpf/AutoSuggestBox.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ public class AutoSuggestBox : TextBox
1010
{
1111
private const string AutoSuggestBoxListPart = "PART_AutoSuggestBoxList";
1212

13-
#region Properties
14-
1513
protected ListBox? _autoSuggestBoxList;
1614

17-
#endregion
18-
1915
#region Dependency Properties
2016

2117
public IEnumerable Suggestions

0 commit comments

Comments
 (0)