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
This commit is contained in:
+50
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user