From 938b1f0838e3aa2f4c0c144ad9ddc1c2cf9b4de3 Mon Sep 17 00:00:00 2001 From: Joe Shook Date: Mon, 30 Nov 2026 12:58:53 -0800 Subject: [PATCH] E2E: retry a checkbox click that was lost On the CI runner the forced click on Enable PKCE sometimes lands while the box is mid re-render or its panel is still expanding. CheckAsync clicked once and then waited, so the box stayed unchecked and the deploy gate failed (v0.9.2507, twice). Now it clicks again if the box has not shown as checked within 3 s, up to 20 s, looking before each click so a late render is not undone. Co-Authored-By: Claude Opus 5.5 --- _tests/UdapEd.E2E/UdapEdPage.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/_tests/UdapEd.E2E/UdapEdPage.cs b/_tests/UdapEd.E2E/UdapEdPage.cs index 306ffa6..ce426e7 100644 --- a/_tests/UdapEd.E2E/UdapEdPage.cs +++ b/_tests/UdapEd.E2E/UdapEdPage.cs @@ -98,13 +98,32 @@ public async Task ExpandAsync(ILocator panel) /// Ticks a MudCheckBox input unless it is already checked. MudCheckBox shows the new state when Blazor re-renders /// after the click; Playwright's CheckAsync looks right after clicking and fails when that render is slow (the page /// busy saving app state, say). So: click, then wait for the box to show as checked. + /// A click can also be lost outright on a slow machine (the CI runner): the box is mid re-render, or its panel is + /// still expanding, when the forced click lands. Nothing would retry it, so the box stayed unchecked and the test + /// failed. So: if the box has not shown as checked a few seconds after a click, click again, until a deadline. /// public async Task CheckAsync(ILocator checkBoxInput) { - if (!await checkBoxInput.IsCheckedAsync()) + var deadline = DateTime.UtcNow.AddSeconds(20); + while (DateTime.UtcNow < deadline) { + if (await checkBoxInput.IsCheckedAsync()) + { + return; + } + await checkBoxInput.ClickAsync(new LocatorClickOptions { Force = true }); + try + { + await Assertions.Expect(checkBoxInput).ToBeCheckedAsync(new LocatorAssertionsToBeCheckedOptions { Timeout = 3_000 }); + return; + } + catch (PlaywrightException) + { + // The click was lost or the render is slow; look again before clicking, so a late render isn't undone. + } } + await Assertions.Expect(checkBoxInput).ToBeCheckedAsync(); }