Release 0.69.0 - #3391
Merged
Merged
Conversation
…3383) `frontends/api/src/test-utils/mockAxios.ts` previously mocked the whole axios module — re-implementing `create()`, per-method shims, interceptors, baseURL join, and a `defaults` map. Tests effectively ran against a parallel implementation of axios that drifted from the real one. Replace that with a thin mock adapter installed on real axios via `axios.defaults.adapter`. URL resolution, interceptors, transforms, headers, and AxiosError construction now go through real axios; the adapter is the single divergence point. Defense in depth: the factory mutates `axios.defaults.adapter` AND wraps `axios.create()` to force the adapter onto every instance, even when callers pass an explicit `adapter` in config. A `beforeEach` canary asserts both install layers stay hooked so a future regression fails loud rather than silently hitting the network. Mock-registration timing: `jest.mock("axios", () => mockAxiosFactory())` is called at the top level of setupJest, where @swc/jest's babel transform hoists it above all imports — including any module that imports axios at load time. Earlier prototypes wrapped this in a `setupMockAxios()` helper that called `jest.mock` internally; that pattern is NOT hoisted because the `jest.mock` call sits inside a function body, so modules that imported axios during setup-phase resolution would see the unwrapped `create` and miss the adapter install. Exposing `mockAxiosFactory` as the factory itself and registering it from the setup file's top level is what keeps the hoist intact. The `() => mockAxiosFactory()` wrapper is required to defer the identifier lookup past TDZ; passing `mockAxiosFactory` directly throws `Cannot access '_mockAxios' before initialization` because the hoisted jest.mock evaluates its arguments above the import that binds the symbol. Also change `makeRequest` from positional `(method, url, body)` to a single object arg `{ method, url, body }` — assertions can use `objectContaining` to ignore fields, no more `undefined` placeholders, and the shape is additively extensible (e.g. headers) without breaking call sites. Drop `mockAxiosInstance` entirely; migrate its ~30 assertion sites to `makeRequest`. A leaf package export `api/test-utils/mockAxios` bypasses the barrel to avoid a setup-time import cycle (the barrel transitively pulls in generated client modules that import axios, which would load axios before the mock factory runs). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat: Handle nullable page field from MITx Online client update
* upgrade qdrant client * upgrade qdrant client
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shankar Ambady
Zaman Afzal
Chris Chudzicki