Skip to content

Commit 42cc0ad

Browse files
committed
Improved the UiTest
1 parent e175751 commit 42cc0ad

File tree

1 file changed

+38
-5
lines changed
  • src/Controls/tests/TestCases.Shared.Tests/Tests/Issues

1 file changed

+38
-5
lines changed

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue17823.cs

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using NUnit.Framework;
32
using UITest.Appium;
43
using UITest.Core;
@@ -15,16 +14,50 @@ public Issue17823(TestDevice device) : base(device)
1514

1615
[Test]
1716
[Category(UITestCategories.CollectionView)]
18-
public void ReorderLastItemWithHeaderPlacesItemAtStart()
17+
public void ReorderingItemToEndWithHeaderDoesNotCrash()
1918
{
20-
Assert.That(App.WaitForTextToBePresentInElement("ReorderStatusLabel", "Item 1, Item 2, Item 3, Item 4", TimeSpan.FromSeconds(3)), Is.True);
21-
19+
// Verify header is present
2220
App.WaitForElement("HeaderLabel");
21+
22+
// Verify all items are present
23+
App.WaitForElement("ReorderItem0");
2324
App.WaitForElement("ReorderItem3");
25+
26+
// Verify initial state
27+
var initialText = App.FindElement("ReorderStatusLabel").GetText();
28+
Assert.That(initialText, Is.EqualTo("Item 1, Item 2, Item 3, Item 4"));
29+
30+
// The bug: dragging first item to the end would crash with header present
31+
// This is because adapter indices include header (0=header, 1=item0, 2=item1, etc.)
32+
// but item source indices don't (0=item0, 1=item1, etc.)
33+
App.DragAndDrop("ReorderItem0", "ReorderItem3");
34+
35+
// Verify reorder succeeded without crash by checking status label updated
36+
var afterDrag = App.FindElement("ReorderStatusLabel").GetText();
37+
Assert.That(afterDrag, Is.EqualTo("Item 2, Item 3, Item 4, Item 1"));
38+
}
39+
40+
[Test]
41+
[Category(UITestCategories.CollectionView)]
42+
public void ReorderingLastItemWithHeaderDoesNotCrash()
43+
{
44+
// Verify header is present
45+
App.WaitForElement("HeaderLabel");
46+
47+
// Verify items are present
2448
App.WaitForElement("ReorderItem0");
49+
App.WaitForElement("ReorderItem3");
50+
51+
// Verify initial state
52+
var initialText = App.FindElement("ReorderStatusLabel").GetText();
53+
Assert.That(initialText, Is.EqualTo("Item 1, Item 2, Item 3, Item 4"));
2554

55+
// Test dragging last item to first position
56+
// This tests the opposite direction
2657
App.DragAndDrop("ReorderItem3", "ReorderItem0");
2758

28-
Assert.That(App.WaitForTextToBePresentInElement("ReorderStatusLabel", "Item 4, Item 1, Item 2, Item 3", TimeSpan.FromSeconds(5)), Is.True);
59+
// Verify reorder succeeded without crash
60+
var afterDrag = App.FindElement("ReorderStatusLabel").GetText();
61+
Assert.That(afterDrag, Is.EqualTo("Item 4, Item 1, Item 2, Item 3"));
2962
}
3063
}

0 commit comments

Comments
 (0)