f7e683703d
Add integration tests for SearchApiClient covering: - GetUserSearchesAsync with authentication returns success - GetUserSearchesAsync without authentication returns unauthorized - GetSearchAsync with non-existent ID returns not found
51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
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();
|
|
}
|
|
}
|