Skip to content

Commit a9034d7

Browse files
csharpfritzCopilot
andcommitted
fix(tests): add retry loop for ListView edit click on CI
The Edit button click can be swallowed before the Blazor interactive circuit is fully established. Use NetworkIdle + retry pattern (3 attempts with 3s timeout each) to handle hydration timing differences on CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 931d63e commit a9034d7

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

samples/AfterBlazorServerSide.Tests/InteractiveComponentTests.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,25 +2640,35 @@ public async Task ListView_CrudOperations_EditButton_ShowsEditMode()
26402640
{
26412641
await page.GotoAsync($"{_fixture.BaseUrl}/ControlSamples/ListView/CrudOperations", new PageGotoOptions
26422642
{
2643-
WaitUntil = WaitUntilState.DOMContentLoaded,
2643+
WaitUntil = WaitUntilState.NetworkIdle,
26442644
Timeout = 30000
26452645
});
26462646

2647-
// Wait for the ListView to render rows with Edit buttons
2647+
// Wait for the ListView to render rows with Edit buttons (requires Blazor circuit)
26482648
await page.WaitForSelectorAsync("button:has-text('Edit')", new PageWaitForSelectorOptions { Timeout = 10000 });
26492649

26502650
// Verify initial status shows "Ready"
26512651
var statusLocator = page.Locator("p").Filter(new() { HasTextString = "Status:" });
26522652
var statusText = await statusLocator.TextContentAsync();
26532653
Assert.Contains("Ready", statusText);
26542654

2655-
// Click the first Edit button
2656-
var editButton = page.Locator("button:has-text('Edit')").First;
2657-
await editButton.ClickAsync();
2658-
2659-
// Wait for Blazor re-render — Update button appears when edit mode activates
2655+
// Click Edit with retry — first click may be swallowed during Blazor hydration on CI
26602656
var updateButton = page.Locator("button:has-text('Update')");
2661-
await updateButton.WaitForAsync(new() { State = WaitForSelectorState.Visible, Timeout = 10000 });
2657+
for (var attempt = 0; attempt < 3; attempt++)
2658+
{
2659+
var editButton = page.Locator("button:has-text('Edit')").First;
2660+
await editButton.ClickAsync();
2661+
try
2662+
{
2663+
await updateButton.WaitForAsync(new() { State = WaitForSelectorState.Visible, Timeout = 3000 });
2664+
break;
2665+
}
2666+
catch (TimeoutException) when (attempt < 2)
2667+
{
2668+
// Retry — circuit may not have been ready
2669+
}
2670+
}
2671+
Assert.True(await updateButton.IsVisibleAsync(), "Update button should be visible in edit mode");
26622672

26632673
var cancelButton = page.Locator("button:has-text('Cancel')");
26642674
Assert.True(await cancelButton.IsVisibleAsync(), "Cancel button should be visible in edit mode");

0 commit comments

Comments
 (0)