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(); + } +}