Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion _tests/UdapEd.E2E/UdapEdPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
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();
}

Expand Down
Loading