Repository navigation
fix(profiles): getUser declared a bare body for a route that wraps, and #26 lost its mock - #29
Merged
Merged
Conversation
#26 lost its mock Two things, one of them mine to own. **The mock correction from #26 never landed.** That PR changed four files; src/__tests__/mocks/server.ts was not among them. While proving the new assertions actually bite, I temporarily reverted `industry` to a string, ran the suite, and restored the file with `git checkout --` — which restores from HEAD, not from my edit, so it discarded the correction rather than the experiment. I committed without re-running the full suite. The result has been sitting on main: the corrected assertions run against the old bare mock, and `vitest run src/__tests__/profiles.test.ts` is 6 failed | 3 passed with no changes at all. The organization handler is restored here — wrapped in `{ data }`, `description` a rich-text document, `industry` the embedded row, `address` structured, and no size/location/founded_year. **getUser had the same defect getOrganization did.** `GET /v1/profiles/{username}` wraps its payload in `{ data }` and the http client returns the body verbatim, so the method resolves to `{ data: UserProfile }` while declaring the profile bare. Its msw handler returned the payload bare too, so the suite agreed with the type and neither was checked against the wire. Confirmed against the running api rather than inferred — the live response is `{ data: { ... } }`. Corrected here: the method signature, the hook generic (tsc rejected the old `UseQueryOptions<UserProfile>` the moment the method stopped lying), the mock, and the assertions. One new assertion checks the envelope itself — `Object.keys(res)` is exactly `['data']` — so a silent revert to a bare body fails loudly instead of yielding undefined. A correction to what I wrote on Scaffald/SaaS#744: I said getUser "has consumers" and that any of them would be reading undefined. It does not. The screens that import a hook named `useUserProfile` import it from `user-profiles-sdk-hooks`, which is a different resource (`/v1/user-profiles`). The only importer of `profiles-sdk-hooks` is the barrel. This is latent, not live. tsc clean; 777 tests across 36 files pass. Refs Scaffald/SaaS#744 Co-Authored-By: Claude Opus 5 <[email protected]>
thinkclay
force-pushed
the
fix/744-getuser-envelope
branch
from
September 11, 2026 16:24
6f47ebe to
221e72d
Compare
Contributor
Author
|
Rebased onto #28, which fixed the org mock independently — I took that version wholesale. What remains here is only the The |
3 tasks
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.
Two things, one of them mine to own.
#26's mock correction never landed
That PR changed four files;
src/__tests__/mocks/server.tswas not among them.While proving the new assertions actually bite, I temporarily reverted
industryto a string, ran the suite, and restored the file withgit checkout --— which restores from HEAD, not from my edit. So it discarded the correction rather than the experiment. I then committed without re-running the full suite.The result has been sitting on
main. With no changes at all:The corrected assertions have been running against the old bare mock. The organization handler is restored here — wrapped in
{ data },descriptiona rich-text document,industrythe embedded row,addressstructured, nosize/location/founded_year.I should have re-run the suite after a destructive
git checkout --; that is the lesson, and it is why the envelope assertion below exists.getUserhad the same defect asgetOrganizationGET /v1/profiles/{username}wraps its payload in{ data }, and the http client returns the body verbatim, so the method resolves to{ data: UserProfile }while declaring the profile bare. Its msw handler returned the payload bare too — so the suite agreed with the type, and neither was checked against the wire.Confirmed against the running api rather than inferred: the live response is
{ data: { … } }.Corrected: the method signature, the hook generic, the mock, and the assertions.
tscrejected the oldUseQueryOptions<UserProfile>the moment the method stopped lying — the same way it caughtgetOrganization.One new assertion checks the envelope itself:
so a silent revert to a bare body fails loudly instead of yielding
undefined.A correction to what I wrote on Scaffald/SaaS#744
I said
getUser"has consumers" and that any of them would be readingundefined. It does not. The screens that import a hook nameduseUserProfileimport it fromuser-profiles-sdk-hooks— a different resource (/v1/user-profiles) that happens to export a same-named hook. The only importer ofprofiles-sdk-hooksis the barrel.So this is latent, not live. The issue is being updated.
Verified
tsc --noEmitclean; 777 tests across 36 files pass.Refs Scaffald/SaaS#744