test(e2e): use web-first toast assertion in notification tests (review fix)

This commit is contained in:
Joseph Doherty
2026-06-05 10:47:06 -04:00
parent 1cbf260969
commit fac0bcbb01
@@ -121,11 +121,9 @@ public class NotificationActionTests
// The retry resolves purely against the central row (no site relay), so a // The retry resolves purely against the central row (no site relay), so a
// single success toast appears. We assert exactly one toast (the single-toast // single success toast appears. We assert exactly one toast (the single-toast
// contract), tolerant of the exact outcome text. The wait is generous (15s) // contract), tolerant of the exact outcome text. The wait is generous (15s)
// and the toast auto-dismisses 5s after it appears, so the assertion must // and the toast auto-dismisses 5s after it appears, so we use a single
// catch it inside that window. // web-first retrying assertion to avoid a TOCTOU race with the auto-dismiss.
var toast = page.Locator(".toast"); await Assertions.Expect(page.Locator(".toast")).ToHaveCountAsync(1, new() { Timeout = 15_000 });
await Assertions.Expect(toast).ToBeVisibleAsync(new() { Timeout = 15_000 });
Assert.Equal(1, await toast.CountAsync());
} }
finally finally
{ {
@@ -159,10 +157,9 @@ public class NotificationActionTests
await deleteButton.ClickAsync(); await deleteButton.ClickAsync();
// The discard moves the central row to Discarded and surfaces a single success // The discard moves the central row to Discarded and surfaces a single success
// toast. Same single-toast / outcome-tolerant assertion as Retry. // toast. Same single-toast / outcome-tolerant assertion as Retry: a single
var toast = page.Locator(".toast"); // web-first retrying assertion to avoid a TOCTOU race with the auto-dismiss.
await Assertions.Expect(toast).ToBeVisibleAsync(new() { Timeout = 15_000 }); await Assertions.Expect(page.Locator(".toast")).ToHaveCountAsync(1, new() { Timeout = 15_000 });
Assert.Equal(1, await toast.CountAsync());
} }
finally finally
{ {