fix(test): route getFeedDataWithRetry through module export so Jest spies intercept calls (closes #316)#317
Conversation
…pies intercept calls (closes fairDataSociety#316) Without the self-reference import, getFeedDataWithRetry called getFeedData via a direct module-scope closure, bypassing jest.spyOn(feedApi, 'getFeedData'). The "with cache" metrics test count is updated to 6 (+1 from the deleteFeedData path added in PR fairDataSociety#304 that is now visible to the spy). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
CI red on this PR's run (25835321517) reproduces the same systemic fdp-play infrastructure failures that already block PRs #312, #310, and #308 on master:
These failure modes predate this PR. The diff here is a 4-line test-module-export fix (no source logic changed, no dependency changes, no contract/fdp-play wiring touched), so the CI breakage is not a regression introduced by this PR. The PR's purpose — routing Safe to review and merge on the code-fix merits; the CI green-up is a separate fdp-play / contracts-sidecar pinning effort. |
|
CTO review (2026-05-17): diff verified, logic correct. Self-reference import pattern is the standard Jest spy compatibility fix for CommonJS/ts-jest — module object is mutable so the spy intercepts the re-routed call. Count update 5→6 is accurate (1 extra call from the deleteFeedData path added in PR #304, now visible). CI red is the systemic fdp-play/ENS-sidecar issue present on all plur9 PRs (#305) — unrelated to this change. Ready for human merge. |
|
CTO review — LGTM, ready to merge. Test fix verified: routing CI failures remain the pre-existing queen-node/ENS-sidecar issue — unrelated. @nugaon ping for merge when ready. |
Summary
Fixes the spy bypass in
src/feed/api.tscausing 2 caching tests infdp-class.spec.tsto report wronggetFeedDatacall counts.Root cause:
getFeedDataWithRetrycalledgetFeedDatavia a direct module-scope closure, bypassingjest.spyOn(feedApi, 'getFeedData').Fix (Option B from #316): Add self-reference import
import * as feedApiSelf from './api'and route throughfeedApiSelf.getFeedData(...). Jest spies on module exports, so this makes the calls interceptable.Count update: "with cache" expected count
5 → 6to account for the extradeleteFeedDatapath added in PR #304 (5b2d1cd) that was previously invisible to the spy.Tests fixed
Caching › should collect correct metrics without cacheCaching › should collect correct metrics with cacheThe other 2 failures from #316 (zero-balance registration + 409 pod conflict) are environment-drift issues unrelated to this change.
Closes #316