COG-6482 fix: Rearm jest fetch mocking and guard server config - #4831
Merged
Conversation
Review follow-ups on COG-6342 and COG-6343. Nothing here was broken at runtime; two of them were traps waiting for the next person. jest.setup.ts paired enableMocks() with dontMock(). dontMock() sets the library's isMocking predicate to a permanent false, and mockResponseOnce and friends only swap the implementation without flipping it back, so the stubbing API was silently dead repo-wide and any unstubbed call went to the real network. Dropping to a bare import is not enough either: it installs the fetch API classes jsdom lacks but leaves global fetch unmocked, so there is still nothing to intercept. enableMocks() alone is the combination that gives both. A new test reaches for an unroutable host to keep both halves honest. serverRuntimeConfig.ts gained `import "server-only"`. Without it, pulling that module into a client component makes Next replace COGNEE_BACKEND_URL with undefined at build time and the module silently returns the localhost default, with no error anywhere. The package was not installed, so it is added as a dependency. The rest is smaller: modulePathIgnorePatterns so the standalone output stops colliding with the root package in jest's haste map, a jest.config comment that contradicted the mapping below it, two examples that recommended a backend URL the browser cannot resolve, and an unreachable fallback in ApiKeysPage whose import was the only thing keeping it alive. Three modules the COG-6342 deletions orphaned are deliberately left in place: cognee-frontend is synced from cognee-saas, so removing them only here invites the sync to put them back. They go at the source first.
Vasilije1990
merged commit Aug 31, 2026
b4343aa
into
feature/cog-6319-publish-cognee-ui-docker-image
3 checks passed
Vasilije1990
deleted the
fix/cog-6482-rearm-jest-mocking-and-drop-orphans
branch
August 31, 2026 07:04
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.
Description
Follow-ups from a review pass over COG-6342 and COG-6343, both already in the 6319 feature branch. Nothing here is broken at runtime; two of them are traps.
jest.setup.tshadenableMocks()followed bydontMock().dontMock()kills the isMocking predicate for good, andmockResponseOnceonly swaps the implementation without turning it back on, so stubbing was dead repo-wide and any unstubbed call went to the real network.enableMocks()alone is what works. Dropping to a bare import is not enough either, it gives youResponseand friends but leaves global fetch unmocked. There is a new test that reaches for an unroutable host so neither half can regress quietly.serverRuntimeConfig.tsgetsimport "server-only". Without it, pulling that module into a client component makes Next replaceCOGNEE_BACKEND_URLwith undefined at build time and the module silently returns the localhost default, no error anywhere. The package was not installed, so it is added as a dependency: package.json +1 line, lockfile +7, nothing else moved.Smaller stuff:
modulePathIgnorePatternsso the standalone output stops colliding with the root package in jest's haste map, a jest.config comment that contradicted the mapping right below it, two examples recommending a backend URL the browser cannot resolve, and a dead fallback in ApiKeysPage whose import was the only thing keeping it alive.Three modules the COG-6342 deletions orphaned (
switchTenant,workspaceCreationLock,getUserAppState) stay for now. Verified they have no importers, but cognee-frontend is synced from cognee-saas, so deleting only here just invites the sync to put them back. Same reasoning as COG-6480. Left open on the ticket.Base is the 6319 feature branch, not
dev.Acceptance Criteria
fetchMock.mockResponseOnce(...)actually intercepts, covered by a testserverRuntimeConfigfrom a client component fails the buildType of Change
Screenshots
Also built the image with this branch applied on top of the 6319 packaging commit, since
server-onlyis a new dependency and the two had never been built together:docker buildpasses,npm cipicks it up, and the container still refuses to start on a malformedCOGNEE_BACKEND_URL, serves the right one, and reports healthy. Full round trip against a real backend container works, login and dashboard, all API calls 200.Pre-submission Checklist
CONTRIBUTING.md)DCO Affirmation
I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.