Skip to content

test: await fire-and-forget waitFor calls in Course.test.jsx - #2060

Merged
arbrandes merged 1 commit into
masterfrom
bsmith/course-test-waitfor-hygiene
Sep 18, 2026
Merged

arbrandes merged 1 commit into
masterfrom
bsmith/course-test-waitfor-hygiene

Conversation

@brian-smith-tcril

@brian-smith-tcril brian-smith-tcril commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Four waitFor(...) calls in Course.test.jsx ran without await, so their background polls threw after their own test finished, and Jest misattributed the rejection to whichever test ran next. Three of them also wrapped an un-awaited findByText (which returns a Promise) in the matcher, so those three assertions were vacuous (matching against a promise object, and never awaited). This awaits them so they genuinely assert.

Pre-existing latent bug — the file already documents this class in its it.skip notes (see #1669); the base suite passed only because the leaks' timing happened not to collide. Split out as the bottom of the stack so the sequence-data → React Query conversion (#2011, on top) stays sequence-only — but it's a prerequisite: the async seed timing in #2011 makes the line-351 leak collide reliably and turn the suite red.

What changed

Only src/courseware/course/Course.test.jsx:

  • await the fire-and-forget waitFor in "passes handlers to the sequence".
  • Rewrite the three "Sequence alerts display" assertions as expect(await screen.findByText(X)).toBeInTheDocument() so they genuinely assert.

Left untouched: three un-awaited waitFors inside it.skip blocks (they don't run).

Testing

npm run types (0 errors), npm run lint (clean), and the full suite green. The four cases pass in isolation and the suite is green consecutively. No production behavior change — with the line-351 waitFor properly awaited, "passes handlers to the sequence" still renders Previous/Next and fires its handlers as before.

🤖 Generated with Claude Code

Four waitFor(...) calls ran without await, so their background polls threw
after their own test finished — Jest then misattributed the rejection to the
next test. Three of them also wrapped an un-awaited findByText (a Promise) in
the matcher, so those assertions were vacuous.

await the line-351 waitFor, and rewrite the three Sequence-alert assertions as
`expect(await screen.findByText(X)).toBeInTheDocument()` so they genuinely
assert. Pre-existing latent bug (see the file's it.skip notes, #1669); surfaced
by the async seed timing in the sequence-data React Query conversion (#2011).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@brian-smith-tcril
brian-smith-tcril added this pull request to stack #2062 September 15, 2026 03:34
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.66%. Comparing base (09a89b7) to head (9074e29).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2060      +/-   ##
==========================================
+ Coverage   93.59%   93.66%   +0.06%     
==========================================
  Files         368      368              
  Lines        6015     6015              
  Branches     1420     1383      -37     
==========================================
+ Hits         5630     5634       +4     
+ Misses        369      365       -4     
  Partials       16       16              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arbrandes
arbrandes merged commit 65dbeb8 into master Sep 18, 2026
7 checks passed
@arbrandes
arbrandes deleted the bsmith/course-test-waitfor-hygiene branch September 18, 2026 14:58
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.

2 participants