Skip to content

Fix bUnit JS timeout flakes in StructuredLogs/Traces/TraceDetails tests - #21503

Merged
Ankit Jain (radical) merged 2 commits into
mainfrom
aspireagent/fix-telemetry-page-js-results
Nov 10, 2026
Merged

Ankit Jain (radical) merged 2 commits into
mainfrom
aspireagent/fix-telemetry-page-js-results

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes an intermittent Dashboard.Components flake: EmptyState_HelpDisappearsAfterAnySignalAndStaysHiddenAfterClear (StructuredLogs/Traces), plus TraceDetails tests, fail with Bunit.JSRuntimeInvocationNotSetException on 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 in DashboardPageTestContext), bUnit faults the invocation. That fault surfaces from the component's OnAfterRenderAsync and is rethrown by the next WaitForAssertion. So any test still running 10s after the first render fails.

Two kinds of handlers were left without a result:

  • focusElement: StructuredLogsTests, TracesTests and TraceDetailsTests each call JSInterop.SetupVoid("focusElement", _ => true) without a result. They do this after SetupFluentMenu registered a resolved handler. The last registration wins, so the resolved handler is overridden. Each page awaits focusElement(<scrollContainer>, true) on first render.
  • Tooltip: AddCommonDashboardServices registers the Tooltip module's FluentTooltipInitialize without a result.

This is the same bug class #21412 fixed for Select.Initialize and observeAttributeChange, and #21434 fixes in ManageDataDialogTests. This PR doesn't touch those files.

Fix

Add .SetVoidResult() to the four handlers above. Also complete the other shared void stubs these pages exercise: the three handlers in SetupFluentAnchoredRegion (goToNextFocusableElement, initializeKeyboardNavigation, removeKeyboardNavigation) and the two in SetupFluentOverflow (fluentOverflowInitialize, fluentOverflowDispose). Test-only change.

CI evidence (attempt-1 failures, ci.yml, about Oct 16–31)

Survey: 1000 ci.yml runs (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:

Run / job Head Failing tests Pending invocation
main push 40534267321 (Windows) b1b850f StructuredLogsTests.EmptyState… (and MetricsTests.EmptyState… on Select.Initialize, fixed since by #21412) focusElement("structuredLogsScrollContainer", true)
PR 40563038552 (Windows) and job 122398564683 (Ubuntu) f1cc41e TraceDetailsTests.ExpandAllSpans…, Render_TraceUpdateWithNewSpans…, ToggleCollapse… 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 final WaitForAssertion in the StructuredLogs/Traces EmptyState tests:

EmptyState (9 cases) Failure
main 6 failed / 9 JSRuntimeInvocationNotSetException: focusElement("structuredLogsScrollContainer"/"tracesScrollContainer", true) ×5, FluentTooltipInitialize ×1
this PR 9 passed / 9 n/a

No new tests are added. The existing render tests for these pages already cover the first-render calls.

Validation

  • Aspire.Dashboard.Components.Tests full suite: 1161 passed, 0 failed.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • No. Test-only fix; existing render tests cover it.
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

🤖 Posted by AspireAgent (AI Agent)

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>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21503

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21503"

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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-specific focusElement handlers 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the test-only change. No blocking correctness issues found.

@davidfowl David Fowler (davidfowl) added the agent:working An AI agent is actively working on this issue or PR label Nov 10, 2026 — with Copilot SWE Agent

David Fowler (davidfowl) commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

AspireAgent stopped: both review threads are addressed in 326e9e4 and CI Final Results passed; awaiting JamesNK re-approval.

🤖 Posted by AspireAgent (AI Agent)

Add SetVoidResult to the SetupFluentAnchoredRegion and SetupFluentOverflow
handlers, and remove the setup tests that only asserted mock configuration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator Author

James Newton-King (@JamesNK) I pushed 326e9e4 to address both threads. The ruleset requires your re-approval on this new head.

🤖 Posted by AspireAgent (AI Agent)

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

1 / 101 PR test projects · 0 PR jobs, from 4 changed files.

Selected PR test projects (1 / 101)

Aspire.Dashboard.Components.Tests

Selected PR jobs (0)

none


How these were chosen — grouped by what changed

🧪 tests/Aspire.Dashboard.Components.Tests/Pages/StructuredLogsTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Pages/TraceDetailsTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Pages/TracesTests.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

🧪 tests/Aspire.Dashboard.Components.Tests/Shared/FluentUISetupHelpers.cs (changed test)
→ 1 directly: Aspire.Dashboard.Components.Tests

Job reasons

none


Selection computed for commit 326e9e4.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the test-only JavaScript interop stub updates.

No open issues 🎉

Review effort: Balanced

@davidfowl David Fowler (davidfowl) removed the agent:working An AI agent is actively working on this issue or PR label Nov 10, 2026

@radical Ankit Jain (radical) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the updated PR after merging main locally; no issues found.

@radical
Ankit Jain (radical) merged commit 3aba713 into main Nov 10, 2026
49 checks passed
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

docs_optional → test_only. No signals triggered (signal_count == 0); all 4 changed files match tests/** (Aspire.Dashboard.Components.Tests). No user-facing change.

@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 10, 2026
Maddy Montaquila (maddymontaquila) added a commit that referenced this pull request Nov 13, 2026
…s, trace log previews, test flakes (#22232)

The remaining dashboard work for `release/17.0`, as one squashable PR:
one commit per change, in this order.

**Backported from `main` (cherry-picked with `-x`):**

1. #21500: Fix flaky terminal
WebSocket close handshake abort (test only)
2. #21503: Fix bUnit JS timeout
flakes in StructuredLogs/Traces/TraceDetails tests (test only)
3. #21471: Fix flaky
TerminalWebSocketTests final-output drain (test only)
4. #21924: Read resource row
state at every density in dashboard browser tests (test only)
5. #22142: Fix inconsistent
dashboard action icon colors. It conflicted with #22188 in
`ResourcesLayout.razor`: the resolution keeps the row menu on every row,
parameters included, with #22142's icon color.

**From open PRs against `main`, applied as they stand:**

6. #22228: Fix resource sidebar
hover state after selection
7. #22229: Keep resource picker
popup width consistent

**New:**

8. Render the trace log preview only for the marker that's hovered or
focused. Each log marker rendered its own hidden preview for the
tooltip, so a span with many logs built over a million hidden elements.
The page now renders one preview, filled on hover or focus. This
addresses Copilot's review on #22230.

9. Center tag group chevrons over the state dot column. In the compact
sidebar at rest, the rows' state dots form a column at the end of the
list, and the group header's chevron sat 13px past it. This replaces
#21996.
10. Fix two resource pane Playwright tests:
- `Rows_KeepDensity` expected parameter rows in the expanded list to
have no overflow menu, but every row has one now.
- `FilterAndGrouping` could hover before the feedback prompt pushed the
page down 40px, leaving the pointer on the brand. It now waits for the
prompt.

When `release/17.0` merges back into `main`, the `Rows_KeepDensity`
change has to come along with it, because #22228's version of that test
expects no menu on parameter rows.

Once this is in `release/17.0`, `release/17.0` merges back into `main`.
#22228 and #22229 can then close on `main`.

## Customer Impact

Fixes and polish to the 17.0 dashboard: icon colors, the resource
sidebar and picker, and trace pages with many logs.

## Testing

- `Aspire.Dashboard.Components.Tests`: 1,447 passed, 0 failed.
- `ResourcePaneResponsiveTests.FilterAndGrouping_*` and
`Rows_KeepDensity*`: 11 passed. `FilterAndGrouping` passed 5 runs in a
row after the fix; before it, the 2000px cases failed in about half the
runs.
- The chevron alignment was checked in the browser at 1440px: the
chevron and the dots are both centered 25px from the list's end.

## Risk

Low. Dashboard-only, and the backports are unchanged apart from the one
conflict described above.

## Regression?

No.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: David Fowler <davidfowl@gmail.com>
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Maddy Montaquila <maddy@MadBook-Pro-20.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: James Newton-King <james@newtonking.com>
Co-authored-by: Sébastien Ros <1165805+sebastienros@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants