From f7e683703df5490906ffe731c588fdd4942ecfca Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 6 Jan 2026 11:37:43 -0500 Subject: [PATCH] test: add SearchApiClientIntegrationTests for search endpoint validation Add integration tests for SearchApiClient covering: - GetUserSearchesAsync with authentication returns success - GetUserSearchesAsync without authentication returns unauthorized - GetSearchAsync with non-existent ID returns not found --- .../SearchApiClientIntegrationTests.cs | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 NEW/tests/JdeScoping.Api.IntegrationTests/ClientIntegration/SearchApiClientIntegrationTests.cs diff --git a/NEW/tests/JdeScoping.Api.IntegrationTests/ClientIntegration/SearchApiClientIntegrationTests.cs b/NEW/tests/JdeScoping.Api.IntegrationTests/ClientIntegration/SearchApiClientIntegrationTests.cs new file mode 100644 index 0000000..35ce747 --- /dev/null +++ b/NEW/tests/JdeScoping.Api.IntegrationTests/ClientIntegration/SearchApiClientIntegrationTests.cs @@ -0,0 +1,50 @@ +using JdeScoping.Client.Services; +using Shouldly; + +namespace JdeScoping.Api.IntegrationTests.ClientIntegration; + +public class SearchApiClientIntegrationTests : ClientIntegrationTestBase +{ + public SearchApiClientIntegrationTests(TestWebApplicationFactory factory) : base(factory) { } + + [Fact] + public async Task GetUserSearchesAsync_WithAuth_ReturnsSearchList() + { + // Arrange + await LoginAsync(); + + // Act + var result = await SearchClient.GetUserSearchesAsync(); + + // Assert + result.IsSuccess.ShouldBeTrue(); + result.Value.ShouldNotBeNull(); + } + + [Fact] + public async Task GetUserSearchesAsync_WithoutAuth_ReturnsUnauthorized() + { + // Arrange - use fresh client without cookies + var freshClient = new SearchApiClient(CreateFreshClient()); + + // Act + var result = await freshClient.GetUserSearchesAsync(); + + // Assert + result.IsUnauthorized.ShouldBeTrue(); + } + + [Fact] + public async Task GetSearchAsync_NotFound_ReturnsNotFound() + { + // Arrange + await LoginAsync(); + var nonExistentId = 999999; + + // Act + var result = await SearchClient.GetSearchAsync(nonExistentId); + + // Assert + result.IsNotFound.ShouldBeTrue(); + } +}