Repository navigation
test(api): the profiles suite asserted the contract #482 retired, and hid an anonymous-viewer bug - #745
Merged
Conversation
… hid an anonymous-viewer bug Closes #482. The organizations route was fixed in #617 and its schema in #743, but profiles.test.ts still asserted the phantom contract — industry as a string, size, location, founded_year, an is_public fixture flag — so the suite stayed red at 24/27 after the code was right. The three tests now assert what the table has: industry joined through industry_id to a real core.industries row, address as the jsonb object it was stored as, and an explicit check that none of the four phantom columns come back. The fixture seeds visibility, industry_id and address, and throws on insert errors instead of returning whatever the swallowed failure left behind. Two things the old tests could never have caught surfaced on the way: The job-count test inserted jobs with status "published", which core.jobs' CHECK (draft|open|paused|closed) rejects; the insert error was unawaited, so the count it expected (2) was unreachable. Now "open", and the error throws. The 27th test — a vanity slug resolving to a profile with a location — was red for a reason outside #482 and inside #732: GET /v1/profiles/slug/{slug} read core.profile with the request client, and every SELECT policy on that table is granted to `authenticated` (profile_public_read is `true`, so every signed-in viewer sees it). Anonymous viewers, the audience the public page exists for, got location: null. The read now goes through the service-role client alongside the preferences read that already did, after the user row is resolved, so nothing about who can find a profile changes. Verified against the running API: 27/27, with the edge runtime confirmed to be serving this worktree (it had been serving another one — the memory-noted gotcha — for the earlier runs). Fixed-name fixtures poisoned reruns: a run that died before cleanup left acme-corp / private-org behind and every later run hit organizations_slug_key. Slugs are now unique per run. tests/infrastructure/vitest/mocks/beyond-ui.tsx: Tabs was a bare div, so any screen using Tabs.Item / Tabs.Trigger / Tabs.Content threw "Element type is invalid". That is what kept two IPIPResultsPage tests skipped since #566 and what stopped the XP-award test from ever rendering the page it asserted on. Tabs is now a compound; both skips are lifted, and a regression test for #740 renders the page three times plus a tab switch and asserts the award fires once — with the hook mock returning a fresh object per call, as useMutation does, because a shared object cannot reproduce the loop. SDK pointer: 759b7ec -> sdk main (Scaffald/sdk#26 + #28). #743 recorded the bump to #26 in its description but main still pointed at sdk#25 — and #26 itself was red at 7: it moved the type, method and tests to the { data } envelope but not the msw handler. sdk#28 fixes the handler; 776/776. This is what `pnpm prepush` refused to stamp until it was fixed, which is the gate doing its job. profiles 27/27 · scf-core IPIPResultsPage 7/7 (was 4 + 2 skipped) and the three other Tabs-consuming suites 32/32 · scf-core:typecheck · sdk 776/776 · deno check profiles.ts unchanged at the 5 pre-existing errors · prepush stamped.
3 of 10 tasks
Contributor
📊 Performance Benchmark Results |
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.
Closes #482.
Re-checked against the running API first, as asked.
GET /v1/profiles/organizations/{slug}is healthy — 200 anonymous and signed-in forblackstone-corporation,industryembedded as the taxonomy row,job_countreal — and/employers/{slug}is the 404 #618 made it. The route was fixed in #617 and its schema in #743. What was still red was the test suite, which nobody had brought along: 24/27, and the acceptance on #482 is 27/27.The tests asserted the contract #482 retired
Three organizations tests still expected
industryas a string,size,location,founded_year, and passed anis_publicflag the fixture silently ignored. They now assert what the table has —industryjoined throughindustry_idto a realcore.industriesrow (construction),addressas the jsonb object it was stored as,visibility: "private"→ 404 — and check explicitly that none of the four phantom columns come back, so the response cannot quietly grow them again.The fixture seeds
visibility,industry_idandaddress, and throws on insert errors instead of returning whatever the swallowed failure left. That surfaced a second dead test:The 27th test was red for a reason inside #732
resolves a slug that differs from the usernameasserts alocation. It wasnull— but only for anonymous callers.GET /v1/profiles/slug/{slug}readcore.profilewith the request client, and every SELECT policy on that table is granted toauthenticated(profile_public_readis literallytrue; the data is not private, the anonymous role just has no policy). So the public profile page showed no location to exactly the audience it exists for. The read now goes through the service-role client next to the preferences read that already did, after the user row is resolved — nothing about who can find a profile changes. Noted on #732, whose widget endpoints fail the same way one step earlier.Fixed-name fixtures (
acme-corp,private-org,slugowner) also poisoned reruns: a run that died before cleanup left the row behind and every later run hitorganizations_slug_key. Slugs are unique per run now.Tabsin the test mock, and #740's regression testtests/infrastructure/vitest/mocks/beyond-ui.tsxhadTabsas a bare div, so any screen usingTabs.Item / Trigger / Contentthrew "Element type is invalid". That is what kept twoIPIPResultsPagetests skipped since #566 — and why the one test that asserted the XP award never rendered the page it asserted on, which is how #740 hid.Tabsis a compound now; both skips are lifted, and a regression test renders the page three times plus a tab switch and asserts the award fires once. The hook mock returns a fresh object per call, asuseMutationdoes: a shared object cannot reproduce the loop, which is why the old test could not have caught it.SDK pointer
759b7ec→a3de197(Scaffald/sdk#26). #743's description says it bumped this;mainstill recorded sdk#25.Verified
One thing worth knowing for the next person: the edge runtime had been restarted from a different worktree by a concurrent session, so the earlier runs of this suite were exercising that checkout's code, not this one's — the memory-noted gotcha, live. Confirmed the mount before trusting the 27/27.
🤖 Generated with Claude Code