Skip to content

Commit a65abe1

Browse files
csharpfritzCopilot
andcommitted
fix: wait for Blazor interactivity before redirect button click
The Redirect_NavigatesToSessionPage test was timing out because it clicked the button before Blazor's interactive circuit was ready. The old check (WaitForSelectorState.Attached) only verified DOM presence, not interactivity. Now waits for __doPostBack function (bootstrapped by WebFormsPageBase. OnAfterRenderAsync) as a reliable signal that Blazor event handlers are wired up same pattern used in PostBackTests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c4bfed7 commit a65abe1

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

samples/AfterBlazorServerSide.Tests/Migration/ResponseRedirectTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ public async Task Redirect_NavigatesToSessionPage()
3232
Timeout = 30000
3333
});
3434

35+
// Wait for Blazor interactive circuit — OnAfterRenderAsync bootstraps __doPostBack
36+
await page.WaitForFunctionAsync("typeof window.__doPostBack === 'function'",
37+
null, new PageWaitForFunctionOptions { Timeout = 10000 });
38+
3539
var card = page.Locator("[data-audit-control='redirect-basic-demo']");
3640
var button = card.Locator("button:has-text('Response.Redirect')");
3741

38-
// Ensure Blazor interactive circuit is ready before clicking
39-
await button.WaitForAsync(new LocatorWaitForOptions { State = WaitForSelectorState.Attached, Timeout = 10000 });
4042
await button.ClickAsync();
4143

42-
// forceLoad: true triggers full page navigation (HTTP + prerender + SignalR)
43-
// which needs generous timeout in CI
44+
// forceLoad: true triggers full page navigation
4445
await page.WaitForURLAsync("**/migration/session", new PageWaitForURLOptions
4546
{
4647
WaitUntil = WaitUntilState.Load,

0 commit comments

Comments
 (0)