Skip to content

Commit 83d0ec8

Browse files
committed
Fixes UI test failures
Corrects failing UI tests by adjusting assertions and adding exception handling. The fixes improve the stability and reliability of the UI test suite.
1 parent 93c096d commit 83d0ec8

File tree

7 files changed

+22
-13
lines changed

7 files changed

+22
-13
lines changed

Directory.packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
<PackageVersion Include="VirtualizingWrapPanel" Version="1.5.8" />
3131
<PackageVersion Include="XAMLTest" Version="1.3.0-ci616" />
3232
</ItemGroup>
33-
</Project>
33+
</Project>

tests/MaterialDesignThemes.UITests/WPF/AutoSuggestBoxes/AutoSuggestTextBoxTests.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.ComponentModel;
22
using MaterialDesignThemes.UITests.Samples.AutoSuggestBoxes;
33
using MaterialDesignThemes.UITests.Samples.AutoSuggestTextBoxes;
4+
using TUnit.Core.Exceptions;
45
namespace MaterialDesignThemes.UITests.WPF.AutoSuggestBoxes;
56

67
public class AutoSuggestBoxTests : TestBase
@@ -231,7 +232,14 @@ static async Task AssertViewModelProperty(AutoSuggestBox autoSuggestBox)
231232

232233
private static async Task AssertExists(IVisualElement<ListBox> suggestionListBox, string text, bool existsOrNotCheck = true)
233234
{
234-
_ = await suggestionListBox.GetElement(ElementQuery.PropertyExpression<TextBlock>(x => x.Text, text));
235-
await Assert.That(existsOrNotCheck).IsTrue();
235+
try
236+
{
237+
_ = await suggestionListBox.GetElement(ElementQuery.PropertyExpression<TextBlock>(x => x.Text, text));
238+
await Assert.That(existsOrNotCheck).IsTrue();
239+
}
240+
catch (Exception e) when (e is not TUnitException)
241+
{
242+
await Assert.That(existsOrNotCheck).IsFalse();
243+
}
236244
}
237245
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public async Task OnDatePicker_WithClearButton_ClearsSelectedDate()
4444

4545
DateTime? selectedDate = await datePicker.GetSelectedDate();
4646

47-
await Assert.That(selectedDate).IsNull();
47+
await Assert.That(selectedDate).IsNotNull();
4848

4949
await clearButton.LeftClick();
5050

tests/MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ namespace MaterialDesignThemes.UITests.WPF.DialogHosts;
99

1010
public class DialogHostTests : TestBase
1111
{
12+
public DialogHostTests()
13+
{
14+
AttachedDebuggerToRemoteProcess = false;
15+
}
16+
1217
[Test]
1318
public async Task OnOpenDialog_OverlayCoversContent()
1419
{
@@ -341,7 +346,7 @@ public async Task DialogHost_WithOpenDialog_ShowsPopupWhenLoaded()
341346

342347
await unloadButton.LeftClick();
343348

344-
await Wait.For(async () => await Assert.That(await closeButton.GetIsVisible()).IsFalse());
349+
await Wait.For(async () => await Assert.That(await closeButton.GetIsVisible()).IsFalse() == false);
345350

346351
await loadButton.LeftClick();
347352

tests/MaterialDesignThemes.UITests/WPF/ListBoxes/ListBoxTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public async Task OnListBoxAssist_WithShowSelectDisabled_SelectionIsDisabled()
135135
var earth = await listBox.GetElement<ListBoxItem>("/ListBoxItem[2]");
136136
await earth.LeftClick();
137137
var selectedBorder = await earth.GetElement<Border>("SelectedBorder");
138-
await Wait.For(async () => await Assert.That(await selectedBorder.GetIsVisible()).IsFalse());
138+
await Wait.For(async () => await Assert.That(await selectedBorder.GetIsVisible()).IsFalse() == false);
139139

140140
recorder.Success();
141141
}

tests/MaterialDesignThemes.UITests/WPF/UpDownControls/DecimalUpDownTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public async Task NumericButtons_IncreaseAndDecreaseValue(string culture)
3333
await Wait.For(async () =>
3434
{
3535
await Assert.That(await textBox.GetText()).IsEqualTo(Convert.ToString(1.1, CultureInfo.GetCultureInfo(culture)));
36-
await Assert.That(await textBox.GetText()).IsEqualTo("2");
37-
await Assert.That(await numericUpDown.GetValue()).IsEqualTo(2);
36+
await Assert.That(await numericUpDown.GetValue()).IsEqualTo((decimal)1.1);
3837
});
3938

4039
await minusButton.LeftClick();
@@ -225,8 +224,8 @@ public async Task LostFocusWhenTextIsInvalid_RevertsToOriginalValue(string input
225224
await textBox.SendKeyboardInput($"{ModifierKeys.Control}{Key.A}{ModifierKeys.None}{inputText}");
226225
await button.MoveKeyboardFocus();
227226

228-
await Assert.That(await textBox.GetText()).IsEqualTo("2.5");
229-
await Assert.That(await decimalUpDown.GetValue()).IsEqualTo(2.5m);
227+
await Assert.That(await textBox.GetText()).IsEqualTo(expectedValue.ToString());
228+
await Assert.That(await decimalUpDown.GetValue()).IsEqualTo(expectedValue);
230229

231230
recorder.Success();
232231
}

tests/MaterialDesignThemes.UITests/WPF/UpDownControls/NumericUpDownTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using System;
21
using System.ComponentModel;
3-
using System.Windows.Controls;
42
using System.Windows.Data;
5-
using Google.Protobuf.WellKnownTypes;
63
using MaterialDesignThemes.UITests.Samples.UpDownControls;
74

85

0 commit comments

Comments
 (0)