-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable search on concentrator page (#1755)
* enable search on concentrator page * update unit tests ConcentratorSearch component * update unit tests services + list page * update Lorawan Concentrator Service * update concentrator list page
- Loading branch information
1 parent
9271f83
commit ee3547a
Showing
12 changed files
with
346 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/AzureIoTHub.Portal.Client/Components/Concentrators/ConcentratorSearch.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<MudExpansionPanels> | ||
<MudExpansionPanel Text="Search panel"> | ||
<MudGrid> | ||
<MudItem xs="12" md="6"> | ||
<MudTextField @bind-Value="searchKeyword" Placeholder="DeviceID / DeviceName" id="searchKeyword"></MudTextField> | ||
</MudItem> | ||
<MudGrid> | ||
<MudItem sm="12" md="6"> | ||
<MudText>Status</MudText> | ||
<MudRadioGroup @bind-SelectedOption="@searchStatus" Style="display:flex;align-items:baseline" id="searchStatus"> | ||
<MudItem md="4" sm="12"> | ||
<MudRadio Option=@("true") Color="Color.Primary" id="searchStatusEnabled">Enabled</MudRadio> | ||
</MudItem> | ||
<MudItem md="4" sm="12"> | ||
<MudRadio Option=@("false") Color="Color.Primary" id="searchDisabled">Disabled</MudRadio> | ||
</MudItem> | ||
<MudItem md="4" sm="12"> | ||
<MudRadio Option=@("") Color="Color.Secondary" id="searchStatusAll">All</MudRadio> | ||
</MudItem> | ||
</MudRadioGroup> | ||
|
||
</MudItem> | ||
<MudItem xs="12" md="6"> | ||
<MudText>Connection state</MudText> | ||
<MudRadioGroup @bind-SelectedOption="@searchState" Style="display:flex;align-items:baseline"> | ||
<MudItem md="4" sm="12"> | ||
<MudRadio Option=@("true") Color="Color.Primary" id="searchStateConnected">Connected</MudRadio> | ||
</MudItem> | ||
<MudItem md="4" sm="12"> | ||
<MudRadio Option=@("false") Color="Color.Primary" id="searchStateDisconnected">Disconnected</MudRadio> | ||
</MudItem> | ||
<MudItem md="4" sm="12"> | ||
<MudRadio Option=@("") Color="Color.Secondary" id="searchStateAll">All</MudRadio> | ||
</MudItem> | ||
</MudRadioGroup> | ||
</MudItem> | ||
</MudGrid> | ||
|
||
<MudItem xs="12"> | ||
<MudButton Variant="Variant.Outlined" Color="Color.Success" Style="margin:0.5em;" id="searchButton" OnClick=Search>Search</MudButton> | ||
<MudButton Variant="Variant.Outlined" Color="Color.Primary" Style="margin:0.5em;" OnClick="Reset" id="resetSearch">Reset</MudButton> | ||
</MudItem> | ||
|
||
</MudGrid> | ||
|
||
</MudExpansionPanel> | ||
</MudExpansionPanels> | ||
|
||
@code { | ||
[Parameter] | ||
public EventCallback<ConcentratorSearchInfo> OnSearch { get; set; } | ||
|
||
private string? searchKeyword = string.Empty; | ||
private string? searchStatus = string.Empty; | ||
private string? searchState = string.Empty; | ||
|
||
private async Task Search() | ||
{ | ||
var searchInfo = new ConcentratorSearchInfo | ||
{ | ||
SearchKeyword = searchKeyword, | ||
SearchStatus = searchStatus, | ||
SearchState = searchState | ||
}; | ||
await OnSearch.InvokeAsync(searchInfo); | ||
} | ||
|
||
private async Task Reset() | ||
{ | ||
searchKeyword = string.Empty; | ||
searchStatus = string.Empty; | ||
searchState = string.Empty; | ||
|
||
await Search(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/AzureIoTHub.Portal.Client/Models/ConcentratorSearchInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Client.Models | ||
{ | ||
public class ConcentratorSearchInfo | ||
{ | ||
public string? SearchKeyword { get; set; } | ||
public string? SearchStatus { get; set; } | ||
public string? SearchState { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/AzureIoTHub.Portal.Shared/Models/v1.0/Filters/ConcentratorFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Shared.Models.v10.Filters | ||
{ | ||
|
||
public class ConcentratorFilter : PaginationFilter | ||
{ | ||
public string Keyword { get; set; } | ||
|
||
public bool? Status { get; set; } | ||
|
||
public bool? State { get; set; } | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
src/AzureIoTHub.Portal.Tests.Unit/Client/Components/Concentrators/ConcentratorSearchTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (c) CGI France. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Tests.Unit.Client.Components.Concentrators | ||
{ | ||
using AutoFixture; | ||
using System.Collections.Generic; | ||
using AzureIoTHub.Portal.Tests.Unit.UnitTests.Bases; | ||
using Bunit; | ||
using NUnit.Framework; | ||
using AzureIoTHub.Portal.Client.Components.Concentrators; | ||
using FluentAssertions; | ||
using System.Linq; | ||
using AzureIoTHub.Portal.Client.Models; | ||
|
||
[TestFixture] | ||
public class ConcentratorSearchTests : BlazorUnitTest | ||
{ | ||
public override void Setup() | ||
{ | ||
base.Setup(); | ||
} | ||
|
||
[Test] | ||
public void SearchConcentrators_ClickOnSearch_SearchIsFired() | ||
{ | ||
// Arrange | ||
var searchKeyword = Fixture.Create<string>(); | ||
var receivedEvents = new List<ConcentratorSearchInfo>(); | ||
var expectedConcentratorSearchInfo = new ConcentratorSearchInfo | ||
{ | ||
SearchKeyword = searchKeyword, | ||
SearchState = string.Empty, | ||
SearchStatus = string.Empty | ||
}; | ||
|
||
var cut = RenderComponent<ConcentratorSearch>(parameters => parameters.Add(p => p.OnSearch, (searchInfo) => | ||
{ | ||
receivedEvents.Add(searchInfo); | ||
})); | ||
|
||
cut.WaitForElement("#searchKeyword").Change(searchKeyword); | ||
cut.WaitForElement("#searchStatusAll").Click(); | ||
cut.WaitForElement("#searchStateAll").Click(); | ||
|
||
// Act | ||
cut.WaitForElement("#searchButton").Click(); | ||
|
||
// Assert | ||
cut.WaitForAssertion(() => receivedEvents.Count.Should().Be(1)); | ||
_ = receivedEvents.First().Should().BeEquivalentTo(expectedConcentratorSearchInfo); | ||
cut.WaitForAssertion(() => MockRepository.VerifyAll()); | ||
} | ||
|
||
[Test] | ||
public void SearchConcentrators_ClickOnReset_SearchKeyworkIsSetToEmptyAndSearchIsFired() | ||
{ | ||
// Arrange | ||
var searchKeyword = Fixture.Create<string>(); | ||
var receivedEvents = new List<ConcentratorSearchInfo>(); | ||
var expectedConcentratorSearchInfo = new ConcentratorSearchInfo | ||
{ | ||
SearchKeyword = string.Empty, | ||
SearchState = string.Empty, | ||
SearchStatus = string.Empty | ||
}; | ||
|
||
var cut = RenderComponent<ConcentratorSearch>(parameters => parameters.Add(p => p.OnSearch, (searchInfo) => | ||
{ | ||
receivedEvents.Add(searchInfo); | ||
})); | ||
|
||
cut.WaitForElement("#searchKeyword").Input(searchKeyword); | ||
cut.WaitForElement("#searchStatusAll").Click(); | ||
cut.WaitForElement("#searchStateAll").Click(); | ||
|
||
// Act | ||
cut.WaitForElement("#resetSearch").Click(); | ||
|
||
// Assert | ||
cut.WaitForAssertion(() => receivedEvents.Count.Should().Be(1)); | ||
_ = receivedEvents.First().Should().BeEquivalentTo(expectedConcentratorSearchInfo); | ||
_ = cut.Find("#searchKeyword").TextContent.Should().Be(string.Empty); | ||
cut.WaitForAssertion(() => MockRepository.VerifyAll()); | ||
} | ||
} | ||
} |
Oops, something went wrong.