Skip to content

test(api): the profiles suite asserted the contract #482 retired, and hid an anonymous-viewer bug - #745

Merged
thinkclay merged 1 commit into
mainfrom
fix/482-org-profile-contract
Sep 11, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/482-org-profile-contract

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Closes #482.

Re-checked against the running API first, as asked. GET /v1/profiles/organizations/{slug} is healthy — 200 anonymous and signed-in for blackstone-corporation, industry embedded as the taxonomy row, job_count real — 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 industry as a string, size, location, founded_year, and passed an is_public flag the fixture silently ignored. They now assert what the table has — industry joined through industry_id to a real core.industries row (construction), address as 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_id and address, and throws on insert errors instead of returning whatever the swallowed failure left. That surfaced a second dead test:

the job-count test inserted jobs with status: "published", which core.jobs' CHECK (draft|open|paused|closed) rejects. The error was unawaited, so the count it expected (2) was unreachable — the same bug #617 found in the route, still sitting in the test.

The 27th test was red for a reason inside #732

resolves a slug that differs from the username asserts a location. It was null — but only for anonymous callers. 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 literally true; 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 hit organizations_slug_key. Slugs are unique per run now.

Tabs in the test mock, and #740's regression test

tests/infrastructure/vitest/mocks/beyond-ui.tsx had Tabs as a bare div, so any screen using Tabs.Item / Trigger / Content threw "Element type is invalid". That is what kept two IPIPResultsPage tests 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. Tabs is 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, as useMutation does: 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; main still recorded sdk#25.

Verified

profiles suite            27/27 against the running API
scf-core IPIPResultsPage   7/7  (was 4 passing + 2 skipped)
Tabs-consuming suites     32/32 (ImportReviewScreen, CalendarScheduling, EEOReport)
scf-core:typecheck        clean against sdk#26
deno check profiles.ts    unchanged at the 5 pre-existing errors (#704 family)
pnpm prepush              exit 0

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

… 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.
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


@thinkclay
thinkclay merged commit e76f414 into main Sep 11, 2026
14 checks passed
@thinkclay
thinkclay deleted the fix/482-org-profile-contract branch September 11, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): both /v1/profiles slug endpoints always 500 — org selects 5 nonexistent columns, core.employers does not exist

1 participant