From c6279e927e485ef5397577c10f8ad60d73f94cf7 Mon Sep 17 00:00:00 2001 From: Ivan Vydrin Date: Thu, 30 Jul 2026 15:39:38 +0300 Subject: [PATCH] Assert the side-menu filter by invariant, not by row totals The test read the total row count and the target group's count on the way in, then asserted the filtered board matched them. The board settles as states arrive, so both were races: it failed on a loaded runner during the 4.0.0 release rehearsal, having passed on the pull request minutes earlier. Asserts what narrowing to a group actually means instead -- one section, named the group, and every row in it carrying that group -- and that picking it again brings a second section back. No count taken before the board is settled. Three consecutive local runs green. --- .../DashboardGroupingTests.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/Healthie.Tests.E2E/DashboardGroupingTests.cs b/tests/Healthie.Tests.E2E/DashboardGroupingTests.cs index b985c55..c83ee23 100644 --- a/tests/Healthie.Tests.E2E/DashboardGroupingTests.cs +++ b/tests/Healthie.Tests.E2E/DashboardGroupingTests.cs @@ -136,19 +136,27 @@ public async Task Dashboard_SideMenu_NarrowsTheListToOneGroup(ProviderSetup setu await using var app = await SampleApp.StartAsync(setup, Ct); var page = await OpenDashboardAsync(app); - var everything = await page.Locator(".hpm-row").CountAsync(); - var inTarget = await GroupFor(page, TargetGroup).Locator(".hpm-row").CountAsync(); - Assert.True(inTarget > 0 && inTarget < everything); + // Asserted as invariants rather than against row totals taken up front: the board settles as + // states arrive, so a count read on the way in is a race, and this failed once on a loaded + // runner for exactly that reason. + await Assertions.Expect(page.Locator(".hpm-group").First).ToBeVisibleAsync(); var entry = page.Locator(".hpm-nav-item").Filter(new() { HasTextString = TargetGroup }); await entry.ClickAsync(); - - await Assertions.Expect(page.Locator(".hpm-row")).ToHaveCountAsync(inTarget); await Assertions.Expect(entry).ToHaveAttributeAsync("aria-current", "true"); + // Narrowed to one group: exactly one section, and every row in it carries that group. + await Assertions.Expect(page.Locator(".hpm-group")).ToHaveCountAsync(1); + await Assertions.Expect(page.Locator(".hpm-group-name")).ToHaveTextAsync(TargetGroup); + + var groups = await page.Locator(".hpm-row .hpm-chip--group").AllTextContentsAsync(); + Assert.NotEmpty(groups); + Assert.All(groups, group => Assert.Equal(TargetGroup, group.Trim())); + // Picking it again is the way back, so the menu cannot strand anyone in one group. await entry.ClickAsync(); - await Assertions.Expect(page.Locator(".hpm-row")).ToHaveCountAsync(everything); + await Assertions.Expect(entry).Not.ToHaveAttributeAsync("aria-current", "true"); + await Assertions.Expect(page.Locator(".hpm-group").Nth(1)).ToBeVisibleAsync(); browser.AssertNoErrors(page); }