Skip to content

test(dashboard): stub the frame window only after its mount ping ran - #32345

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/32286
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/32286

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: CrewDynamicDashboard.refetch.test.tsx stops failing at random on CI.

a late refetch reply > is not posted into the document that replaced the one that asked failed on an unrelated PR (Frontend Tests shard 2/4): expect(posted).toEqual([]) received [{ type: 'mc-frame-ping' }]. It passes locally.

Why it matters

A red Frontend Tests shard blocks PR Readiness on any open PR that happens to draw it, so contributors rerun CI for a defect that is not theirs.

Not a goal

  • No change to CrewDynamicDashboard or useFrameAliveRecovery: both behave as designed.
  • No change to what the tests assert.

Intended? / Repro

Intended? Yes, the product behaviour is intended; the defect is in the test. useFrameAliveRecovery pings the frame's own window when it mounts (website/src/hooks/useFrameAliveRecovery.ts:84 on main, else ping(), documented at lines 13-34 of the same file). The ping goes from a passive useEffect. The test (website/src/pages/members/CrewDynamicDashboard.refetch.test.tsx:106-115 on main) stubs frame.contentWindow with a recorder as soon as the <iframe> is in the DOM. That is a commit, not a settled state: when React runs the passive effects a task later, which happens on a loaded runner, the mount ping lands in the recorder. On a fast run the effect has already run and pinged happy-dom's real (null) window, so nothing is recorded. happy-dom never fires load on this frame (disableIframePageLoading in website/vite.config.ts), so the mount ping is the only ping these tests can see.

Repro (CI): run 42368210842, job 128392111188 (Frontend Tests (2), head 64a0e4c of #31793, which touches none of this code). The job summary has exactly 1 failed test (Tests 1 failed | 15885 passed). Failing line:

FAIL  src/pages/members/CrewDynamicDashboard.refetch.test.tsx > a late refetch reply > is not posted into the document that replaced the one that asked
AssertionError: expected [ { type: 'mc-frame-ping' } ] to deeply equal []
 ❯ src/pages/members/CrewDynamicDashboard.refetch.test.tsx:138:20

The same race applies to the other tests in the file, which assert posted equals exactly [DATA_MESSAGE_TYPE].

What changed (motivation → approach → change)

Symptom: a stray mc-frame-ping in the recorder. Root cause: the test installs its stand-in window before the frame's mount effects have run. Fix: wait for a real signal that they have run.

  • The test wraps the real useFrameAliveRecovery (it still runs unchanged) and adds one effect, declared after the hook's own in the same component. That effect records the frame the hook armed on. Effects in one component run in declaration order, so once the frame is recorded, the mount ping has already been sent.
  • A shared mountedFrame(container) helper finds the iframe and then waits until it is recorded. All three places that found the frame now use it, including the bandUp helper.
  • The assertions are unchanged.

Alternatives considered: filtering mc-frame-ping out of posted would hide any unexpected ping and weaken the assertion. Waiting for a frame load does not work, because happy-dom never fires one here.

Backwards compatibility

Compatible: test-only change.

Removes nothing: only a test file changes.

Tests

website/src/pages/members/CrewDynamicDashboard.refetch.test.tsx: every test now installs its stand-in window only after the frame-alive mount ping has run. The assertions are unchanged.

Proof: not provable -- test-only change

Manual verification

N/A — test-only change. Static gates run locally: eslint on the file (clean) and tsc -p tsconfig.app.json (clean). Tests were not run locally because CI is the only test runner on this host.

Related Issues

Fixes #32286

Sibling sweep

Swept: git grep -ln "defineProperty(frame, 'contentWindow'" -- website/src website/integration
Sibling: website/src/pages/members/CrewDynamicDashboard.refetch.test.tsx -- changed here
Sibling: website/src/pages/members/CrewDynamicDashboard.remint.test.tsx -- not affected -- the exact-count assertion runs on scripts:false pages, where the alive hook is not armed
Sibling: website/src/pages/members/CrewDynamicDashboard.spentUrl.test.tsx -- not affected -- it records pings on purpose and fires load itself
Sibling: website/src/pages/members/CrewDynamicDashboard.behind.test.tsx -- not affected -- it makes no assertion on posted messages

Pattern harvest

Rule candidate: agents-md
Pattern: stubbing an element's contentWindow right after it mounts races the component's passive-effect postMessage; wait on a signal that the effects ran first

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

The refetch tests swap a stand-in window under the dashboard frame as soon as
the iframe is in the DOM. useFrameAliveRecovery pings the frame from a passive
effect, which on a busy runner runs after that swap, so the mount ping landed
in the stand-in and 'expect(posted).toEqual([])' saw mc-frame-ping.

Wait on the real signal instead: wrap the real hook and record, from an effect
declared after its own, the frame it armed on; the shared mountedFrame helper
waits for that before the test stubs the window.

Fixes #32286
@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 7, 2026 13:15
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 99399af23072dd85c29d001be179e421025c02f6 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 99399af23072dd85c29d001be179e421025c02f6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. This PR only changes a test file and adds or changes no user-visible control, so it needs no screenshots.

[UX-REVIEWED] 99399af

Description read

[DESCRIPTION-READ] 6131c2fdbc4c47c0a26ae7697b39b55f17a50b469d8564e3de5312b6c24e0546

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 99399af23072dd85c29d001be179e421025c02f6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

The fix replaces a timing race with a signal that the frame's mount effect has run, and the assertions are unchanged.

[DESIGN-REVIEWED] 99399af

Description read

[DESCRIPTION-READ] a2354dd052026929fd078453cd9d2dc92100273d9f98748f3fbf6e2b6fa35d06

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 99399af23072dd85c29d001be179e421025c02f6 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 99399af

Verdict parsed from the review's SHA-scoped output markers for commit 99399af23072dd85c29d001be179e421025c02f6.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 99399af23072dd85c29d001be179e421025c02f6 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 99399af23072dd85c29d001be179e421025c02f6 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 99399af

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 99399af23072dd85c29d001be179e421025c02f6 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 7, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 7, 2026 15:08

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: test (1 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only: the dashboard frame test stubs the frame window only after the frame-alive mount ping ran, removing a race on busy runners.

@KiroCrewCaptain
KiroCrewCaptain merged commit b786a33 into main Nov 7, 2026
96 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/bug-resolve/32286 branch November 7, 2026 15:08

@bolichen97 bolichen97 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.

Approving 99399af.

What I checked on this head:

  • The base is main. All 96 checks are green and none is pending. The UX and Design lanes pass, the Opus and GPT lanes have no blocking findings, and the First Principles lane is skipped for a test-only change.
  • The diff is one test file, CrewDynamicDashboard.refetch.test.tsx, and no product code. The cause in the description holds up against the test: the test put its stand-in window under the frame as soon as the <iframe> was in the DOM, and the frame-alive hook pings from a passive effect, so on a loaded runner the mount ping landed in the recorder. The fix keeps the real hook and adds a mock wrapper that records each armed frame from an effect declared right after the hook's own. React runs effects of one component in declaration order, so the record means the mount ping has already gone. The three tests then wait for that record before stubbing the window, through one shared mountedFrame helper, and the record is cleared in each beforeEach.
  • What the tests assert is unchanged, and CrewDynamicDashboard and useFrameAliveRecovery are untouched.
  • No regex, no product change, and nothing made stricter.

I set auto-merge on this head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: is not posted into the document that replaced the one that asked (CrewDynamicDashboard.refetch.test.tsx)

3 participants