Skip to content

Commit 2a99dc4

Browse files
committed
Improves UI test reliability
Adds retry logic to clear button click in date picker test; captures a screenshot of the split button popup during UI test.
1 parent 239e61f commit 2a99dc4

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

tests/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ public async Task OnDatePicker_WithClearButton_ClearsSelectedUncommittedText()
7676
await datePickerTextBox.SendKeyboardInput($"invalid date");
7777
await Assert.That(await datePickerTextBox.GetText()).IsEqualTo("invalid date");
7878

79-
// Act
80-
await clearButton.LeftClick();
81-
await Task.Delay(50, TestContext.Current!.CancellationToken);
79+
// Act & Assert
80+
await Wait.For(async () => {
81+
await clearButton.LeftClick();
82+
await Task.Delay(50, TestContext.Current!.CancellationToken);
8283

83-
// Assert
84-
await Assert.That(await datePickerTextBox.GetText()).IsNull();
84+
string? text = await datePickerTextBox.GetText();
85+
await Assert.That(text).IsNull();
86+
});
8587

8688
recorder.Success();
8789
}

tests/MaterialDesignThemes.UITests/WPF/SplitButtons/SplitButtonTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,16 @@ public async Task SplitButton_WithButtonInPopup_CanBeInvoked()
9393
//NB: give the popup some time to show
9494
await Wait.For(async () => await popupContent.GetIsVisible());
9595
await Wait.For(async () => await popupContent.GetActualHeight() > 10);
96+
97+
await recorder.SaveScreenshot("PopupOpen");
98+
9699
await popupContent.LeftClick();
97100
await Task.Delay(50, TestContext.Current!.CancellationToken);
98101

99102
// Assert
100-
await Wait.For(async () =>
101-
{
102-
var invocations = await clickEvent.GetInvocations();
103-
await Assert.That(invocations).HasSingleItem();
104-
});
103+
var invocations = await clickEvent.GetInvocations();
104+
await Assert.That(invocations).HasSingleItem();
105+
105106
recorder.Success();
106107
}
107108

0 commit comments

Comments
 (0)