Skip to content

Fix the environment fade E2E flake caused by bubbling descendant animation events - #2005

Merged
David Pine (IEvangelist) merged 1 commit into
mainfrom
aspireagent/fix-environment-fade-listener-race
Nov 1, 2026
Merged

David Pine (IEvangelist) merged 1 commit into
mainfrom
aspireagent/fix-environment-fade-listener-race

Conversation

@davidfowl

Copy link
Copy Markdown
Contributor

Summary

Fixes a recurring retry-only E2E flake in tests/e2e/homepage.spec.ts › "fades environment changes and pauses independent resource motion". No open issue tracks it. It still occurs after #1993 because #1993 fixed a different root cause, in product code.

Signature, from all three projects:

expect(locator).toHaveAttribute(expected) failed
Locator:  locator('[data-home-environments]').locator('[data-environment-panel="test"]')
Expected: "true"
Received: "false"
… <article … data-transition="fade-in" data-test-fade-seen="false" …>

Occurrences since #1993 merged (2026-10-30 13:20Z): the test passed only on retry in these CI jobs:

Root cause (test-only): the test recorded the fade with an animationstart listener registered with { once: true } and no target check. Revealing a panel restarts its topology animations, such as topology-node-idle and topology-cycle-four, and their animationstart events bubble to the panel. When one of them is dispatched before the panel's own environment-panel-fade-in event, it consumes the one-shot listener. The real fade then goes unrecorded, even though it ran. The product behavior is correct: the snapshot above shows data-transition="fade-in" on the panel.

Fix: a shared recordPanelFade() helper. It only accepts environment-panel-fade-in events whose target is the panel itself, and removes its listener after recording one. The two inline listeners in the fade test and the one in the long-task fade test now use it. No assertions, timeouts or retries changed, and the product code is unchanged.

Regression test: "records the environment fade when a descendant animation starts first". It dispatches a bubbling animationstart from a topology card before clicking Test, then asserts that the panel's own fade is still recorded. This deterministically reproduces the ordering seen in CI.

This doesn't change any rendered output, so there are no screenshots.

Third-party links and affiliations

None.

Validation

Reproduced on unmodified main (f05f556): I ran a local dev server, loaded a fresh page in a mobile 390×844 context each time with no CPU throttling, and made the first Test click while recording events with both the old one-shot listener and a persistent listener.

  • In 5 of 32 loads, the first animationstart reaching the panel came from a descendant (topology-node-idle or topology-cycle-four), and the old listener missed the fade.
  • The persistent listener saw the fade in 32 of 32 loads.

Fail before, pass after:

  • New regression test with the old { once: true } listener: 9/9 failed (3 projects × 3 repeats), Received: "false".
  • With the fix, the new test, the fade test and the long-task fade test (3 projects × 3 repeats): 26 of 27 passed.
    • The one failure was the existing long-task test on desktop, the second test of the run on a cold dev server. Its unchanged data-transition settle assertion timed out after 2s.
    • Re-running the long-task and new tests (3 projects × 4 repeats) gave 24/24 passed.

Other checks:

  • npx vitest run: 84 files, 1,120 passed, 1 skipped.
  • npx eslint . --max-warnings 0: clean.

🤖 Posted by AspireAgent (AI Agent)

The fade test listened for animationstart with { once: true }. Revealing a
panel restarts its topology animations, whose bubbling animationstart events
can reach the panel before the fade's own event and consume the listener.

Co-authored-by: Copilot <[email protected]>
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #2005. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #2005 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review October 31, 2026 03:34
Copilot AI balanced review requested due to automatic review settings October 31, 2026 03:34

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 were identified for this test-only fade-recording change.

No open issues 🎉

What changed in this PR

Fixes a test-only homepage environment fade flake caused by bubbling descendant animation events consuming a one-shot listener. Product code and rendered output remain unchanged.

Changes:

  • Adds recordPanelFade() to record only the panel’s own fade animation and remove the listener afterward.
  • Reuses the helper in the existing fade and long-task tests without changing assertions, timeouts, or retries.
  • Adds a regression test that dispatches a descendant animation event before triggering the panel fade.
File Description
src/​frontend/​tests/​e2e/​homepage.spec.ts Centralizes fade recording and adds coverage for descendant animation events arriving first.

Review effort: Balanced

@IEvangelist

Copy link
Copy Markdown
Member

Project documentation assessment: not applicable

Reviewed the complete changed-file list and diff at head 4c9d64c1335cf4aa11165536264daa400537baaf, targeting main (resolved base f05f5561b1b858344124cd848ff06469627d7e6e), using the doc-pr-reviewer skill and its doc-tester dependency. The only changed file is src/frontend/tests/e2e/homepage.spec.ts (+45/-33); no documentation pages, examples, or Aspire product claims change.

Phase A - Claim verification: no documentation claims found (0 verified, 0 verified-with-nuance, 0 unverifiable, 0 contradicted). No external Aspire/Toolkit/Azure source lookup is applicable or was performed.

Phase B - Blind documentation testing: not applicable: there are no changed documentation routes or instructions to exercise. No docs server, browser documentation walkthrough, CLI examples, or sample projects were run. Critical issues, warnings, passed checks, recommendations, and knowledge-gap findings are all N/A, not claimed as tested/passed.

Phase C - Combined assessment: no documentation findings; this is a test-only PR. The applicable code review follows separately. This applicability assessment is a conversation comment, not a formal approval or change request, and consumes this Project's once-per-PR documentation stage regardless of later head updates.

@IEvangelist

Copy link
Copy Markdown
Member

Project code review: no findings

Reviewed the complete test-only diff at 4c9d64c1335cf4aa11165536264daa400537baaf against main base f05f5561b1b858344124cd848ff06469627d7e6e, following the checked-in .agents/skills/code-review/SKILL.md (the runtime skill loader does not register that skill). No high-confidence correctness, cleanup, timing, or regression-coverage problems found.

recordPanelFade() registers before each click, requires both the panel target and environment-panel-fade-in name, leaves the listener installed for unrelated/bubbling descendant events, and removes that same listener after recording the matching event. If the fade never occurs, the attribute assertion still fails; the listener does not outlive the isolated test page. Existing visibility, pause/resume, 250 ms long-task, and 2 s transition-settle assertions remain intact.

I traced the unchanged production behavior in HomeEnvironment.astro:428-489,1533-1586: selecting an eligible visible environment reveals the panel, applies the 180 ms fade, flushes it with getAnimations(), and settles from the fade's completion promise; descendant topology animations also restart. The new test injects only a descendant topology-node-idle start, verifies that did not satisfy the recorder, then requires the actual panel fade after clicking Test. By inspection, the former { once: true } listener would be consumed by that injected event and leave the final fade assertion false. This is a deterministic check of listener event ordering, not a claim to reproduce natural browser scheduling in every run.

Test coverage and evidence

In CI run 41162894318, whose recorded head SHA exactly matches the inspected head, I inspected the individual job-log entries for these three tests: fades environment changes and pauses independent resource motion, starts the environment fade even when a long task delays the next frame, and records the environment fade when a descendant animation starts first. All nine entries passed: three tests each in desktop-, tablet-, and mobile-chromium. The configured viewport matrix therefore exercises the changed scenarios. Existing same-spec WCAG AA coverage checks every environment state; this PR adds no product markup, interactions, or accessibility behavior requiring a new audit surface.

Limits: no local browser/E2E/unit/build commands or independent fail-before experiment were run in this review; the checkout has no installed frontend dependencies and Bun is unavailable. Runtime evidence above is head-matched CI evidence, not a local rerun or endorsement of unrelated checks. Firefox, WebKit, physical devices, prolonged stress/repeat runs, and unchanged behavior outside the fade recorder were not independently exercised. No source edits, branch switches, pushes, fixes, formal approvals/change requests, or merges were performed; no local server/browser processes or temporary artifacts were created.

This comment follows the documentation applicability assessment and consumes this Project's once-per-PR code-review stage regardless of later head updates.

@IEvangelist David Pine (IEvangelist) 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.

Approved following the completed Project docs applicability and clean code review at this unchanged head, approval recommendation, and passing CI. Approval and merge authorized by the user.

@IEvangelist
David Pine (IEvangelist) merged commit 18132cf into main Nov 1, 2026
20 checks passed
@IEvangelist
David Pine (IEvangelist) deleted the aspireagent/fix-environment-fade-listener-race branch November 1, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants