Repository navigation
Fix bUnit JS timeout flakes in StructuredLogs/Traces/TraceDetails tests - #21503
David Fowler (davidfowl) wants to merge 1 commit into
Conversation
StructuredLogs, Traces and TraceDetails test setups re-registered focusElement without a result, overriding the resolved handler from SetupFluentMenu. The tooltip initialize module handler also had no result. bUnit faults pending planned invocations after DefaultWaitTimeout (10s), so slow CI runs failed with JSRuntimeInvocationNotSetException. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21503Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21503" |
Tests selector1 / 100 PR test projects · 0 PR jobs, from 4 changed files. Selected PR test projects (1 / 100)
Selected PR jobs (0)none How these were chosen — grouped by what changed🧪 🧪 🧪 🧪 Job reasonsnone Selection computed for commit |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the test-only changes that complete pending JavaScript interop mocks.
No open issues 🎉
What changed in this PR
This test-only change addresses intermittent bUnit JavaScript interop timeouts in Dashboard component tests by completing mock invocations that previously remained pending. Production dashboard behavior is unchanged.
Changes:
- Add
.SetVoidResult()to the three page-specificfocusElementhandlers and shared tooltip initialization handler. - Add four regression tests that verify these configured JavaScript calls complete immediately, without timeout-based waits.
| File | Description |
|---|---|
tests/Aspire.Dashboard.Components.Tests/Shared/FluentUISetupHelpers.cs |
Complete the shared tooltip initialization handler. |
tests/Aspire.Dashboard.Components.Tests/Pages/TracesTests.cs |
Complete the focus handler and add focus and tooltip regression tests. |
tests/Aspire.Dashboard.Components.Tests/Pages/TraceDetailsTests.cs |
Complete the focus handler and add a focus regression test. |
tests/Aspire.Dashboard.Components.Tests/Pages/StructuredLogsTests.cs |
Complete the focus handler and add a focus regression test. |
Review effort: Balanced
Description
Fixes an intermittent Dashboard.Components flake:
EmptyState_HelpDisappearsAfterAnySignalAndStaysHiddenAfterClear(StructuredLogs/Traces), plus TraceDetails tests, fail withBunit.JSRuntimeInvocationNotSetExceptionon slow runners (mostly Windows).Root cause
In bUnit 2.x, a planned JS handler without a result leaves the invocation pending. After
BunitContext.DefaultWaitTimeout(10s, set inDashboardPageTestContext), bUnit faults the invocation. That fault surfaces from the component'sOnAfterRenderAsyncand is rethrown by the nextWaitForAssertion. So any test still running 10s after the first render fails.Two kinds of handlers were left without a result:
focusElement:StructuredLogsTests,TracesTestsandTraceDetailsTestseach callJSInterop.SetupVoid("focusElement", _ => true)without a result. They do this afterSetupFluentMenuregistered a resolved handler. The last registration wins, so the resolved handler is overridden. Each page awaitsfocusElement(<scrollContainer>, true)on first render.AddCommonDashboardServicesregisters the Tooltip module'sFluentTooltipInitializewithout a result.This is the same bug class #21412 fixed for
Select.InitializeandobserveAttributeChange, and #21434 fixes inManageDataDialogTests. This PR doesn't touch those files.Fix
Add
.SetVoidResult()to the four handlers. Test-only change.CI evidence (attempt-1 failures,
ci.yml, about Oct 16–31)Survey: 1000
ci.ymlruns (466 with Dashboard jobs). Dashboard.Components had 10 attempt-1 failures in 181 Windows jobs and 1 in 181 Ubuntu jobs. These 3 jobs failed on pending calls this PR fixes:Select.Initialize, fixed since by #21412)focusElement("structuredLogsScrollContainer", true)focusElement("traceDetailScrollContainer", true),FluentTooltipInitialize(plus handlers since fixed on main)A fourth job, PR run 40390542875 (StructuredLogsTests.EmptyState… on Windows), faulted on
observeAttributeChange, which #21412 has since fixed. On the same head the Ubuntu job passed. Locally, the 9 EmptyState cases passed 15/15 loops on main because they finish well under 10s. The other 6 Components failures were the MetricsTests histogram test (tracked separately in #21394).Before/after
Slow-runner simulation (not committed). Added
await Task.Delay(11s)before the finalWaitForAssertionin the StructuredLogs/Traces EmptyState tests:JSRuntimeInvocationNotSetException:focusElement("structuredLogsScrollContainer"/"tracesScrollContainer", true)×5,FluentTooltipInitialize×1Committed regression tests. These run fast and need no waits. Each replays the page's first-render JS call through the configured bUnit runtime and asserts the call completed immediately:
StructuredLogsTests.Setup_FirstRenderFocusInvocationCompletesTracesTests.Setup_FirstRenderFocusInvocationCompletesTracesTests.Setup_TooltipInitializeInvocationCompletesTraceDetailsTests.Setup_FirstRenderFocusInvocationCompletesAssert.True() Failure)Validation
Aspire.Dashboard.Components.Testsfull suite: 1165 passed, 0 failed.Checklist
🤖 Posted by AspireAgent (AI Agent)