diff --git a/test/Admin.Test/AdminConsole/Components/Pages/ListOrganizationsPageTests.cs b/test/Admin.Test/AdminConsole/Components/Pages/ListOrganizationsPageTests.cs index ddf936079..f951d783c 100644 --- a/test/Admin.Test/AdminConsole/Components/Pages/ListOrganizationsPageTests.cs +++ b/test/Admin.Test/AdminConsole/Components/Pages/ListOrganizationsPageTests.cs @@ -1,4 +1,5 @@ using Bit.Admin.AdminConsole.Components.Pages.Organizations; +using Bit.Core.AdminConsole.Entities; using Bit.Core.Repositories; using Bit.Core.Settings; using Bunit; @@ -35,4 +36,39 @@ public class ListOrganizationsPageTests : TestContext // Assert Assert.Contains("invalid", cut.Find("input[name='SearchForm.Email']").Attributes["class"].Value); } + + [Fact] + public void ListOrganizationsPage_PopulatesTable_WhenSearchFormIsSubmitted() + { + // Arrange + var expectedOrganization = new Organization { Id = Guid.NewGuid(), Name = "Example" }; + _organizationRepository.SearchAsync( + "Example", + "johndoe@example.com", + null, + Arg.Any(), + Arg.Any()).Returns(new List + { + expectedOrganization + }); + var cut = RenderComponent(); + + // Act + cut.Find("input[name='SearchForm.Name']").Change("Example"); + cut.Find("input[name='SearchForm.Email']").Change("johndoe@example.com"); + cut.Find("form").Submit(); + + // Assert + _organizationRepository.Received(1).SearchAsync( + "Example", + "johndoe@example.com", + null, + Arg.Any(), + Arg.Any()); + + var rows = cut.FindAll("tbody>tr"); + Assert.Single(rows); + + Assert.Contains(expectedOrganization.Name, rows[0].TextContent); + } }