Skip to content

fix(test): stop counting unrelated requests in "stops posting" tests - #3770

Merged
EmilyRagan merged 3 commits into
mainfrom
fix-flaky-stops-posting-tests
Aug 28, 2026
Merged

fix(test): stop counting unrelated requests in "stops posting" tests#3770
EmilyRagan merged 3 commits into
mainfrom
fix-flaky-stops-posting-tests

Conversation

@EmilyRagan

@EmilyRagan EmilyRagan commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Problem

Both stops posting to the api after closing tests counted every request the page made:

page.on('request', () => { requestCount++ })

The intent is to verify a tool tears down its polling interval when you navigate away. But because the listener is unfiltered, any unrelated periodic traffic that happens to fire in the 2 second window after the count snapshot fails the test — auth token refresh, notification polling, cable reconnects.

Seen in enterprise CI (run 32767849978, run 32073575025, etc), off by exactly one request:

Error: expect(received).toBe(expected)
Expected: 172
Received: 173
  > 160 |   expect(requestCount).toBe(count) // no change

Fix

Count only the polling call each tool actually makes:

  • packet-viewer.p.spec.tsget_tlm_packet, from the setInterval in PacketViewer.vue. The test navigates to INST/ADCS, so it takes the regular-packet branch, not the LATEST / get_tlm_values one.
  • cmd-tlm-server/file-menu.p.spec.tsget_all_interface_info, from InterfacesTab's update() driven by the shared Updater.js mixin. That tab is the default child route.

Matching is on the JSON-RPC body (openc3Api.js posts { jsonrpc, method, ... } to /openc3-api/api), with the quotes included so "get_tlm_packet" can't prefix-match get_tlm_values.

Each test also now asserts expect(requestCount).toBeGreaterThan(0) before navigating away. This is load-bearing: if the filter string were ever wrong the count would stay 0 and the test would pass vacuously, silently testing nothing.

Verification

  • Ran against a local enterprise stack, --repeat-each=3, both files — all pass. Prettier clean.
  • Enterprise run in CI against this branch: run 32902428251 (other failures here, will be addressed separately)

🤖 Generated with Claude Code

Both tests counted every request the page made, so unrelated periodic
traffic (auth token refresh, notifications, cable reconnects) firing
after the count snapshot failed them intermittently.

Count only each tool's polling call (get_tlm_packet, get_all_interface_info)
and assert polling actually happened before navigating away.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.13%. Comparing base (7a8e9f2) to head (992ca0c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3770      +/-   ##
==========================================
- Coverage   79.16%   79.13%   -0.04%     
==========================================
  Files         894      894              
  Lines       66865    66865              
  Branches     2599     2599              
==========================================
- Hits        52936    52912      -24     
- Misses      13266    13292      +26     
+ Partials      663      661       -2     
Flag Coverage Δ
frontend 66.05% <ø> (-0.12%) ⬇️
python 79.27% <ø> (-0.05%) ⬇️
ruby-api 82.09% <ø> (ø)
ruby-backend 84.44% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@EmilyRagan EmilyRagan self-assigned this Aug 25, 2026
EmilyRagan and others added 2 commits August 25, 2026 16:50
The fixed 2 second sleep assumed the tool was already polling. On a
loaded CI runner app boot can take longer than that, so the tests
counted zero requests and failed the pre-navigation sanity check.

Wait for the first polling request explicitly, which also subsumes the
sanity check: if no poll ever arrives, waitForRequest times out rather
than the test passing vacuously.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Navigating to another tool with page.goto is a full document load, so the
JS context and any setInterval in it are destroyed by the browser. That
made the "no more requests" assertion pass regardless of whether the tool
cleared its own interval.

Switch both tests to a client-side route change that unmounts the polling
component while keeping the page alive: Packet Viewer switches packets via
the chooser, CmdTlmServer switches to the Targets tab. Rename both to
describe what they now verify.

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

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@EmilyRagan
EmilyRagan marked this pull request as ready for review August 26, 2026 17:47
@EmilyRagan
EmilyRagan merged commit 83472d0 into main Aug 28, 2026
35 checks passed
@EmilyRagan
EmilyRagan deleted the fix-flaky-stops-posting-tests branch August 28, 2026 15:52
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