Skip to content

Commit

Permalink
Feature/#1361_-_Add sort on edge models listing (#1500)
Browse files Browse the repository at this point in the history
* resolve #1361

* add new test
  • Loading branch information
Sben65 authored Nov 2, 2022
1 parent f0ba7a1 commit 15971e3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<MudTh></MudTh>
<MudTh><MudTableSortLabel SortLabel="Id" T="IoTEdgeListItem" id="sortDeviceId">Device ID</MudTableSortLabel></MudTh>
<MudTh Style="text-align: center"><MudTableSortLabel SortLabel="IsEnabled" T="IoTEdgeListItem">Allowed</MudTableSortLabel></MudTh>
<MudTh Style="text-align: center"><MudTableSortLabel SortLabel="Nb devices" T="IoTEdgeListItem">Nb devices</MudTableSortLabel></MudTh>
<MudTh Style="text-align: center"><MudTableSortLabel SortLabel="NbDevices" T="IoTEdgeListItem">Nb devices</MudTableSortLabel></MudTh>
<MudTh Style="text-align: center">See details</MudTh>
<MudTh Style="text-align: center">Delete</MudTh>
</HeaderContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</ToolBarContent>
<HeaderContent>
<MudTh></MudTh>
<MudTh>Name</MudTh>
<MudTh Style="text-align: center">Description</MudTh>
<MudTh><MudTableSortLabel SortBy="new Func<IoTEdgeModelListItem, object>(x => x.Name)" id="NameLabel" >Name</MudTableSortLabel></MudTh>
<MudTh Style="text-align: center"><MudTableSortLabel SortBy="new Func<IoTEdgeModelListItem, object>(x => x.Description)" id="DescriptionLabel">Description</MudTableSortLabel></MudTh>
<MudTh Style="text-align: center">Details</MudTh>
<MudTh Style="text-align: center">Delete</MudTh>
</HeaderContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,40 @@ public void ClickOnDeleteShouldDisplayConfirmationDialogAndReloadDeviceModelIfCo
cut.WaitForAssertion(() => this.mockEdgeModelServiceClient.Verify(service => service.GetIoTEdgeModelList(), Times.Exactly(2)));
cut.WaitForAssertion(() => MockRepository.VerifyAll());
}

[Test]
public void ClickOnSortLabel()
{
// Arrange
_ = this.mockEdgeModelServiceClient.Setup(x => x.GetIoTEdgeModelList())
.ReturnsAsync(new List<IoTEdgeModelListItem>()
{
new IoTEdgeModelListItem()
{
ModelId = Guid.NewGuid().ToString(),
Name = Guid.NewGuid().ToString()
},
new IoTEdgeModelListItem()
{
ModelId = Guid.NewGuid().ToString(),
Name = Guid.NewGuid().ToString()
},
});

// Act
var cut = RenderComponent<EdgeModelListPage>();

cut.WaitForAssertion(() => cut.WaitForElement("#NameLabel").Should().NotBeNull());
var sortNameButtons = cut.WaitForElement("#NameLabel");
sortNameButtons.Click();

cut.WaitForAssertion(() => cut.WaitForElement("#DescriptionLabel").Should().NotBeNull());
var sortDescriptionButtons = cut.WaitForElement("#DescriptionLabel");
sortDescriptionButtons.Click();

// Assert
cut.WaitForAssertion(() => Assert.AreEqual(3, cut.FindAll("tr").Count));
cut.WaitForAssertion(() => MockRepository.VerifyAll());
}
}
}

0 comments on commit 15971e3

Please sign in to comment.