Skip to content

Fix Dashboard Playwright tab-navigation race in DesktopNavMenu and ResourcePane tests - #21480

Merged
Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
davidfowl/fix-dashboard-tab-click-race
Nov 5, 2026
Merged

Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
davidfowl/fix-dashboard-tab-click-race

Conversation

@davidfowl

Copy link
Copy Markdown
Collaborator

Description

Fixes a flaky race in two Dashboard Playwright outerloop tests added or changed by #21412:

  • DesktopNavMenuTests.MainNavigation_NavigatesBetweenSectionsAndMarksActiveItem
  • ResourcePaneInteractionTests.AllResourcesRow_ClearsSelectionAndListsResourcesInOverview

Root cause

A resource tab click changes the URL in the browser right away, before the server renders the destination. Until that render batch reaches the browser, the tab strip on the page is still the one rendered for the previous location. The FluentTabs in ResourcesLayout is @keyed by renderedLocation, and OnTabChanged deliberately ignores change events from a strip rendered for an earlier location. The comment in ResourcesLayout.razor explains that this guard stops queued native change events from a torn-down strip from looking like new user navigations.

Both tests click a second tab as soon as the URL or aria-selected changes. Both of those update on the client, so neither proves the server has rendered the new strip. When the second click lands in that window, it is dropped by design and the test times out waiting for a navigation that never happens.

Server-side tracing (temporary logging, not in this PR) confirmed the sequence locally:

  1. Click Console logs; OnParametersSetAsync runs for /consolelogs (t=.956).
  2. The test clicks Structured logs at about .96–.99 on the strip still keyed to /resources.
  3. The new strip is rendered at 45.019. The queued event then arrives with renderedLocation=/resources while _lastLocation=/consolelogs, and is ignored.

Fix (test-only)

Add PlaywrightTestsBase.ClickResourceTabAndWaitForRenderAsync. It takes a handle to the current .resources-tab-header element, clicks, and waits until that element is detached. Because the strip is keyed by location, detachment means the server's render for the new location has been applied. The tests then make the same assertions as before. No sleeps or retries are added and no assertion is weakened. AssertActiveItemAsync now checks the server-rendered active tab rather than only the client's optimistic selection.

The product guard is intentional, so it is unchanged.

Evidence

CI (outerloop, outerloop_tests / Dashboard.Playwright; these tests only run in tests-outerloop.yml):

  • Run 41050874298 is the only outerloop run with Playwright jobs that includes Modernize the dashboard experience #21412. On Ubuntu, both tests failed:
    • MainNavigation: Assert.NotNull() Failure for the next tab's bounding box.
    • AllResourcesRow: Page URL expected to match regex '/resources$' But was: '.../consolelogs'.
  • On Windows, both passed in the same run.
  • Denominator so far: Ubuntu 1/1, Windows 0/1 runs that executed the tests. DesktopNavMenuTests failed 0/28 jobs in the 14 scheduled main runs from Oct 16–30, before Modernize the dashboard experience #21412. ResourcePaneInteractionTests didn't exist yet.

Local (Linux, 2 cores):

Scenario Before After
MainNavigation, idle 8/8 failed 10/10 passed
MainNavigation, CPU stress (2× yes) 10/10 failed 10/10 passed
AllResourcesRow, idle and stress 18/18 passed (window too narrow locally) 20/20 passed
AllResourcesRow with deterministic repro harness ¹ 5/5 failed with the exact CI message (But was: .../consolelogs) 5/5 passed
Full Aspire.Dashboard.Playwright.Tests n/a 126/127 ²

¹ Repro harness (not committed): an init script delays every server-to-browser Blazor WebSocket message by 300 ms, in order, after the Console logs click. This widens the window between the client URL change and the server render:

await page.AddInitScriptAsync("""
    (() => {
        const desc = Object.getOwnPropertyDescriptor(WebSocket.prototype, 'onmessage');
        Object.defineProperty(WebSocket.prototype, 'onmessage', {
            configurable: true,
            get() { return desc.get.call(this); },
            set(handler) {
                let chain = Promise.resolve();
                desc.set.call(this, handler && (e => {
                    const due = Date.now() + (window.__delayBlazor ? 300 : 0);
                    chain = chain.then(() => new Promise(r => setTimeout(r, Math.max(0, due - Date.now())))).then(() => handler.call(this, e));
                }));
            }
        });
    })();
    """);
// ... then before the Console logs click:
await page.EvaluateAsync("() => window.__delayBlazor = true");

² The only failure is TerminalTests.HeaderMetadata_LiveUpdatesAndFallbackPreserveFocusAndCopyCurrentValues. It's a local culture artifact ('42 %' vs '42%') in a test that doesn't use the new helper and isn't touched by this PR.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

A tab click changes the browser URL before the server renders the
destination. Until that render arrives, the strip on the page is the one
keyed to the previous location, and ResourcesLayout deliberately ignores
its change events. A second click in that window is dropped, which made
DesktopNavMenuTests.MainNavigation and
ResourcePaneInteractionTests.AllResourcesRow flaky. Wait for the old
strip element to detach before continuing.

Co-authored-by: Copilot <[email protected]>
@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 -- 21480

Or

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

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

0 / 100 PR test projects · 1 PR job, from 3 changed files.

Selected PR test projects (0 / 100)

none — no PR-gated .NET test projects run for this change.

Selected PR jobs (1)

native-dashboard-validation


How these were chosen — grouped by what changed

Job reasons

Job Triggered by
native-dashboard-validation tests/Aspire.Dashboard.Playwright.Tests/Integration/Playwright/Infrastructure/PlaywrightTestsBase.cs

Selection computed for commit 4563057.

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

There are no active review issues for the test-only resource-tab synchronization changes.

No open issues 🎉

What changed in this PR

This test-only PR addresses resource-tab navigation races in Dashboard Playwright tests introduced or changed by #21412. It synchronizes subsequent interactions with server rendering while leaving product behavior unchanged.

Changes:

  • Adds a shared helper that clicks a resource tab and waits for the previous tab strip to detach.
  • Uses the helper in desktop navigation and resource-pane tests, preserving existing assertions without adding sleeps or retries.
File Description
tests/​Aspire.Dashboard.Playwright.Tests/​Integration/​Playwright/​ResourcePaneInteractionTests.cs Waits for the Console logs tab render before continuing.
tests/​Aspire.Dashboard.Playwright.Tests/​Integration/​Playwright/​Infrastructure/​PlaywrightTestsBase.cs Adds the shared tab-click and render-wait helper.
tests/​Aspire.Dashboard.Playwright.Tests/​Integration/​Playwright/​DesktopNavMenuTests.cs Waits for tab-strip replacement after navigation clicks.

Review effort: Balanced

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review October 30, 2026 18:20
David Pine (IEvangelist) added a commit that referenced this pull request Nov 4, 2026
## Description

Make the dashboard resource pane's **Select all** action discoverable
without hovering. The existing localized label is now visible beside the
icon. Remove toggle-button semantics: clicking this action always
returns to all resources; it never clears selection. The existing
selected styling and tooltip continue to indicate when all resources are
selected. At the supported 200px pane minimum, the kind/action toolbar
wraps so the complete action stays inside the pane.

Covers **UX-01** from the dashboard UX backlog. This is one independent
item, not a combined PR. Base:
`9f0961d0c7173732f45ce88d571c8b53f8059934` from freshly fetched
`upstream/main`.

Public context: [AspiriFridays discussion at
02:13:22](https://www.youtube.com/watch?v=azL0fCMFqG4&t=8002s).

### User-facing usage

Select a resource in the sidebar, then click the visible **Select all**
action above the scrolling list to return to all resources. Clicking it
again keeps all resources selected. Keyboard users can activate the
native button with Enter or Space.

### Validation

Passed (4 cases): `dotnet test --project
tests\Aspire.Dashboard.Components.Tests\Aspire.Dashboard.Components.Tests.csproj
--no-launch-profile -- --filter-method
'*.SelectAll_IsLabeledActionAndAlwaysSelectsEverything' --filter-method
'*.Landing_WithoutRememberedSelection_KeepsAllResourcesSelected'
--filter-not-trait 'quarantined=true' --filter-not-trait
'outerloop=true'`

Passed (81 cases): `dotnet test --project
tests\Aspire.Dashboard.Components.Tests\Aspire.Dashboard.Components.Tests.csproj
--no-launch-profile -- --filter-class '*.ResourcesLayoutTests'
--filter-not-trait 'quarantined=true' --filter-not-trait
'outerloop=true'`

Passed (3 browser cases, desktop 1280px at default and minimum 200px
pane widths, plus mobile 640px): `.\.dotnet\dotnet.exe test --project
tests\Aspire.Dashboard.Playwright.Tests\Aspire.Dashboard.Playwright.Tests.csproj
--no-launch-profile
'-p:ArtifactsDir=D:\GitHub\copilot-worktrees\aspire\ievangelist-turbo-potato\artifacts\ux01-minimum-pane\'
-- --filter-method
'*.SelectAll_VisibleLabelAndKeyboardActivationRestoreAllResources'
--filter-not-trait 'quarantined=true'`

The new minimum-width case uses the real splitter's Home key and checks
that the complete action is inside the pane. Before the wrapping
correction, this case failed while the two existing desktop/mobile
controls passed; after the correction, all three passed with no skips.
Additional actual 1440x900/768x1024/390x844 captures were inspected
locally: the desktop pane was resized to 200px, while tablet/mobile used
their existing full-width drawers.

Failed (1 broader existing browser case): `dotnet test --project
tests\Aspire.Dashboard.Playwright.Tests\Aspire.Dashboard.Playwright.Tests.csproj
--no-launch-profile -- --filter-method
'*.AllResourcesRow_ClearsSelectionAndListsResourcesInOverview'
--filter-not-trait 'quarantined=true'`. Its subsequent tab-navigation
assertion timed out. A control run restoring the original button markup
and original test expectations also failed, but earlier at the initial
resource-title assertion, so that control does not establish an
identical root cause. The known tab-render navigation race has a
separate proposed fix in #21480; this PR does not import it or weaken
the navigation assertions.

`git diff --check` passed. Rendered-DOM and focused browser coverage
check the visible label, non-toggle semantics, minimum-pane containment,
selection restoration and repeated keyboard activation. No
usability-study outcome or all-green CI result is claimed.

### Screenshots / Recordings

Existing responsive browser renders using the repository dashboard test
host and its running sample resource. At all three sizes, the complete
**Select all** action was visible within the viewport, one resource was
selected, and activating the action restored the **All resources**
scope. At mobile and tablet widths the existing resource drawer was
opened before capturing the affected action. These hosted images show
the original standard-width states, not the additional 200px regression
capture described above. Images were inspected for clipping; they are
not resized desktop copies. Other themes have not been captured.

**Mobile — 390x844**

![Mobile 390x844 - Select all in open resource
drawer](https://github.com/user-attachments/assets/0ae09b12-3538-48d5-b378-e66e6f138dd4)

**Tablet — 768x1024**

![Tablet 768x1024 - Select all in open resource
drawer](https://github.com/user-attachments/assets/f2806caa-e471-4cdb-b940-322cfadf56c2)

**Desktop — 1440x900**

![Desktop 1440x900 - Select all in resource
sidebar](https://github.com/user-attachments/assets/28e95132-2341-4d28-a0df-a4412bd622d1)

<!-- Add screenshots/recordings here -->

Fixes # (issue)

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
    - If yes, did you have an API Review for it?
      - [ ] Yes
      - [ ] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
      - [ ] Yes
      - [ ] No
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [ ] No
  - [x] No

---------

Co-authored-by: David Pine <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@eerhardt
Eric Erhardt (eerhardt) merged commit d22882d into main Nov 5, 2026
58 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 5, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

docs_optional → test_only. No signals triggered. All 3 changed files match tests/** (Dashboard Playwright tests).

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