Skip to content

test: make the profile suites actually run (#592, #593) - #604

Merged
thinkclay merged 2 commits into
mainfrom
claude/fix-593-test-reach
Aug 12, 2026
Merged

thinkclay merged 2 commits into
mainfrom
claude/fix-593-test-reach

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Closes #592, #593. Part of #594. The audit found these bugs by hand precisely because nothing automated could.

#593 — scf-core was excluded from the default test run

scf-core holds every line of profile UI logic and was named in test:unit's exclude list, so pnpm test and CI never ran any of it: 146 test files, ~1,000 assertions, none executing on the command the repo treats as "the tests".

Running it directly: 955 passed, 61 skipped, 2 failed — and it completes. It does not OOM, contrary to the premise of #504; the pool: 'forks' workaround already in packages/scf-core/vitest.config.ts is doing its job. What remained was the flag.

The two failures were the harness, not the components

Both were the same assertion:

expect(container.firstChild).toBeNull()

renderWithProviders wraps in BeyondUIThemeWrapper, which renders a real element — so container.firstChild is that wrapper and can never be null. The assertion failed whether or not the widget rendered. Both now assert the widget's own testid is absent, which is what "should not render widget when assessment is completed" actually means.

With those fixed the suite is green and the exclude comes off.

#592 — the profile e2e specs pointed at deleted routes

Twelve specs visited a URL space the app no longer serves. Seven targeted /profile/general, /profile/employment, /profile/education, /profile/certifications — redirect stubs since the nine-screens-to-four consolidation — and asserted expect(page.url()).toContain(<old path>), which the redirect makes false. They now visit the live routes, and their titles name the section they exercise rather than a deleted screen.

PROFILE_AUDIT_PLAN.md listed /dashboard/profile/*, a prefix the app has never served, with half its entries pointing at screens that no longer exist. Replaced with the live routes plus an explicit stub→destination table.

Deliberately not flipped on yet

The specs are corrected but not added to testMatch. Turning them on needs one verified green run — Supabase up, api function served, dev server warm, seeded workers present — and this environment has no Docker, so they are fixed but unexecuted. Adding them unrun would ship exactly the "known-red selection" playwright.config.ts already warns about for the office specs. The config now carries the precise command to finish it:

pnpm supa start && pnpm supa functions serve api && pnpm web
pnpm exec playwright test tests/e2e/profile --project=chromium

Bonus: 34 Deno assertions that had never run

functions/api/__tests__/lib/*.test.ts was in no runner glob — test:api:rest:suite and the CI workflow both listed only routes/ and integration/. So profile-completion-calc.test.ts had never executed, nor the request-schema tests added in #597, nor the parity tests added in #601. Added to both, plus a standalone test:api:lib.

Verification

  • scf-core suite: 955 passed / 0 failed / 61 skipped, completes without OOM.
  • pnpm test:api:lib: 34 passed.
  • pnpm prepush green.

CI checks will show red without running — Actions billing block, see #375.

🤖 Generated with Claude Code

thinkclay and others added 2 commits August 12, 2026 00:24
… Deno lib tests (#592)

Twelve specs under tests/e2e/profile/ visited a URL space the app no longer
serves. Seven targeted /profile/general, /profile/employment, /profile/education
and /profile/certifications — all redirect stubs since the nine-screens-to-four
consolidation — and asserted expect(page.url()).toContain(<old path>), which the
redirect makes false. They now visit the live routes, and their titles name the
section they actually exercise ("/profile/resume (General Information)") rather
than a screen that was deleted.

PROFILE_AUDIT_PLAN.md listed /dashboard/profile/*, a prefix the app has never
served, and half its entries were screens that no longer exist. Replaced with
the live route list plus an explicit stub-to-destination table.

Separately: functions/api/__tests__/lib/*.test.ts was in no runner glob.
test:api:rest:suite and the CI workflow both listed only routes/ and
integration/, so profile-completion-calc.test.ts had never run, and neither had
the schema tests added in #597 or the parity tests added in #601. Added to both,
plus a standalone test:api:lib. That is 34 assertions moving from "written" to
"executed".

The profile specs are corrected but deliberately NOT added to testMatch yet.
Turning them on needs one verified green run — Supabase up, api function served,
dev server warm, seeded workers present — and this environment has no Docker, so
they have been fixed but not executed. Adding them unrun would ship exactly the
"known-red selection" playwright.config.ts already warns about. The config now
carries the precise command to finish the job.

Co-Authored-By: Claude Opus 5 <[email protected]>
scf-core holds every line of profile UI logic and was explicitly excluded from
test:unit, so `pnpm test` and CI never ran any of it. 146 test files, ~1,000
assertions, none of them executing on the command the repo treats as "the
tests".

Running the suite directly: 955 passed, 61 skipped, 2 failed. It also completes
— it does not OOM, contrary to the premise of #504. The `pool: 'forks'`
workaround already in packages/scf-core/vitest.config.ts is doing its job; what
remained was simply the exclude flag.

The two failures were the same wrong assertion in two assessment widgets:

    expect(container.firstChild).toBeNull()

renderWithProviders wraps in BeyondUIThemeWrapper, which renders a real element,
so container.firstChild is that wrapper and can never be null. The assertion
failed whether or not the widget rendered — it was testing the harness, not the
component. Both now assert the widget's own testid is absent, which is what
"should not render widget when assessment is completed" actually means.

With those fixed the suite is green, so the exclude comes off.

Co-Authored-By: Claude Opus 5 <[email protected]>
@thinkclay
thinkclay merged commit fc11936 into main Aug 12, 2026
6 of 11 checks passed
@thinkclay
thinkclay deleted the claude/fix-593-test-reach branch August 12, 2026 04:37
thinkclay added a commit that referenced this pull request Aug 12, 2026
…it clean (#504, #593) (#606)

I un-excluded scf-core from test:unit in #604 on the strength of a JSON report
showing 957 passed / 0 failed. That was the wrong signal. `vitest run` exits 1
regardless, so `pnpm test` went red on main for anyone running it locally.

Two things were wrong with how I checked.

The OOM is real. I grepped the background task's output file for "heap out of
memory" and got nothing, because that file held only my own echo lines — vitest's
stderr went elsewhere and I never read it. #504 is not stale: at
--max-old-space-size=4096 the main process dies with "Ineffective mark-compacts
near heap limit" at ~4GB. Raising it to 8192 does not fix it either; with the two
collection failures below repaired, more files collect, more memory is retained,
and it OOMs again at 8GB. Every test passes and the report says success: true —
the failure is entirely the parent process at teardown, not the tests.

My pass/fail summary could not see a broken file. A file that fails to *collect*
contributes zero passed and zero failed, so it is invisible to a count of
assertions. Two files were failing that way and I shipped both:

  - ScaffaldLogo.test.tsx (mine, #599) — "Unexpected token 'typeof'".
    react-native-svg's untransformed source. A mock for it has existed at
    tests/infrastructure/vitest/mocks/react-native-svg.tsx since it was written
    but was never aliased in vitest.config.ts, unlike the react-native, lucide
    and expo-updates mocks. Now aliased, which fixes any test rendering an SVG.
  - ProfileWizard.test.tsx (mine, #605) — the commit hook I added pulled
    @scf/core/provider, and through it UniversalThemeProvider ->
    expo-router/react-navigation, which does not resolve under vitest. Mocked in
    the test; the commit path keeps its own unit tests.

The logo test also asserted something false: that two separate render() calls
produce byte-identical markup. They are two React roots, and useId is only
required to be deterministic by position within a root, so a correct
implementation fails that. It now asserts what actually regresses if the id goes
random again — not drawn from a random source, stable across re-renders, distinct
between two logos in one tree, and referenced by the url(#id) that fills the mark.

scf-core goes back in the exclude list. Making it runnable is #504's job and it
needs the parent-process retention fixed, not a bigger ceiling.

Co-authored-by: Claude Opus 5 <[email protected]>
thinkclay added a commit that referenced this pull request Aug 12, 2026
…called (#447) (#614)

core.reviews and its five child tables have been in place since migration 099,
and ReviewWizard drives a full multi-step flow against @scaffald/sdk. The router
implemented four of the thirteen endpoints the SDK exposes, so every step of
writing a review 404'd. Same shape as the profile epic: a good database, a built
UI, and no wire between them.

Added:

  GET   /reviews/my-reviews                    reviews the caller has written
  GET   /reviews/soft-skills/by-category       the catalog grouped for the tabs
  GET   /reviews/{id}/draft                    reopen a part-written review
  PATCH /reviews/{id}/draft                    whole-blob autosave
  PATCH /reviews/{id}/step                     wizard progress
  PATCH /reviews/{id}/skill-ratings            technical scores
  PATCH /reviews/{id}/category-rating          one category at a time
  PATCH /reviews/{id}/soft-skill-votes         strengths and improvements
  PATCH /reviews/{id}/comment                  body + public visibility
  GET   /reviews/analytics                     aggregates for a subject

Ownership is the review system's whole integrity, so it lives in one helper
rather than being retyped per handler: loadOwnReview filters on id AND
author_user_id, and a miss is a 404 rather than a 403 — the convention #608/#609
settled on, because "exists but not yours" leaks that it exists. Verified
against a live stack: another user's draft is 404 on both read and write.

Mutations additionally require the review to still be a draft. A submitted
review is a published statement about someone; letting the author keep editing
would change what a reader already saw.

Three things the live run caught that static reading would not have:

- **Two endpoints 500'd on "permission denied".** `authenticated` had no DELETE
  grant on review_skill_ratings or review_soft_skill_votes, and both endpoints
  replace their set rather than merging — the reviewer sends the full list, so a
  removed skill has to actually disappear. Migration 346 adds the grants, plus a
  DELETE policy on review_skill_ratings mirroring its insert predicate
  (review_soft_skill_votes already had an author-scoped ALL policy). Same class
  as #481: RLS and a policy exist, the GRANT that makes the policy reachable
  does not, and it surfaces as a server error rather than a permission one.

- **Analytics resolved skill names from the wrong table.** I joined
  data.masterformat; review_skill_ratings.skill_id has a foreign key to
  core.skills. It returned blank names until a live call showed it.

- **POST /{id}/submit was destroying the review.** It set
  `metadata: { status: "submitted" }` — a whole-object write over the jsonb
  column holding the draft body, the wizard's step progress and the is_public
  flag the comment step had just saved. Everything the reviewer filled in was
  dropped at the moment they submitted it. Now merged, and it checks ownership
  like the rest.

KNOWN_GAPS drops 83 -> 73, and the contract suite is added to
test:api:rest:suite — it has never run in CI, which is the same gap #604 fixed
for __tests__/lib.

Co-authored-by: Claude Opus 5 <[email protected]>
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.

test(e2e): 26 of 27 profile specs never run, and the one that does targets deleted routes

1 participant