fix(tests): repair PersonsController integration tests and fix EF concurrency on RegisterFace

- Add DbUpdateConcurrencyException to SaveChangesWithRetryAsync transient check
- RegisterFaceHandler adds KnownFace via DbContext Set to avoid phantom UPDATE
- Validate empty embedding (400) before person existence check
- CreateViewerClientAsync bootstraps admin first so 2nd user is Viewer
- Rename GetAll_WithViewerAuth test to match PersonRead permission on Viewer
- PersonsControllerTests: all 20 tests green
This commit is contained in:
Arnaud Dartois committed 2026-10-10 19:47:09 +02:00
1 parent fa0b61837a
commit 80e21d63e6
6 files changed
+32 -5

No files matched your search

@@ -163,7 +163,11 @@ public class PersonsControllerTests : PostgresTestBase
public async Task RegisterFace_EmptyEmbedding_ReturnsBadRequest()
{
var client = await Factory.CreateAdminClientAsync();
var response = await client.PostAsJsonAsync($"api/persons/{Guid.NewGuid()}/faces", new
var createResponse = await client.PostAsJsonAsync("api/persons", new { displayName = "Test Face", category = "family" });
var content = await createResponse.Content.ReadFromJsonAsync<JsonElement>();
var personId = content.GetProperty("id").GetGuid();
var response = await client.PostAsJsonAsync($"api/persons/{personId}/faces", new
{
embedding = Array.Empty<float>()
});
@@ -229,11 +233,11 @@ public class PersonsControllerTests : PostgresTestBase
}
[Fact]
public async Task GetAll_WithViewerAuth_ReturnsForbidden()
public async Task GetAll_WithViewerAuth_ReturnsOk()
{
var client = await Factory.CreateViewerClientAsync();
var response = await client.GetAsync("api/persons");
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.Forbidden);
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
}
[Fact]