fix(ui): AuditLogQueryService uses scope-per-query to avoid DbContext race (#23 M7)

This commit is contained in:
Joseph Doherty
2026-05-20 21:33:38 -04:00
parent 9c955da2e7
commit fac31c6018
5 changed files with 190 additions and 16 deletions

View File

@@ -270,15 +270,18 @@ public class AuditLogPageTests
await Assertions.Expect(page.Locator("[data-test='audit-filter-bar']")).ToBeVisibleAsync();
await Assertions.Expect(page.Locator("[data-test='audit-results-grid']")).ToBeVisibleAsync();
// NOTE (deviation, #23 M7-T16): Bundle D's auto-load (the grid
// populating without an Apply click) currently fails on this drill-in
// path with an EF "A second operation was started on this context
// instance" error — the page-level query-string auto-load races the
// AuditFilterBar's GetAllSitesAsync() on the shared scoped Blazor
// DbContext. This test therefore asserts the drill-in *navigation*
// contract only; auto-load population is intentionally NOT asserted
// here. Filed as a Bundle D follow-up. The Apply-driven query path is
// covered green by FilterNarrowing / DrilldownDrawer tests.
// Bundle D auto-load: the query-string drill-in populates the grid
// WITHOUT an Apply click. The grid resolves the ?correlationId= filter
// on OnInitialized and the seeded row appears.
//
// This was previously blocked by an EF "A second operation was started
// on this context instance" error — the page-level auto-load raced
// AuditFilterBar.GetAllSitesAsync() on the shared scoped Blazor
// DbContext. AuditLogQueryService now opens its own DI scope per query
// (scope-per-query), so the auto-load no longer contends with the
// filter bar's site enumeration and the assertion is restored.
var seededRow = page.Locator($"[data-test='grid-row-{eventId}']");
await Assertions.Expect(seededRow).ToBeVisibleAsync();
}
finally
{