test(portal): fix vitest config (jsdom + @/ alias)#3458
Merged
Conversation
The portal vitest config (added in #3454 / CS-760) had two gaps that would break any test beyond the current pure-logic one: - No resolve.alias for the tsconfig `@/*` path, so any test importing via `@/...` fails at module resolution. Mirror `@` -> ./src, matching apps/app and apps/framework-editor. - environment was 'node' while the include glob targets .jsx/.tsx component tests, which need DOM APIs. Switch to jsdom (both sibling configs use it); node-only tests still run fine under it. Follow no-plugin approach (hand-mapped alias) like framework-editor to avoid the vite plugin type clash with Next's build-time typecheck on Vercel. Add jsdom + vitest as portal devDependencies so resolution no longer relies on workspace hoisting.
Contributor
|
🎉 This PR is included in version 3.104.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
What
Fixes two real gaps in the portal vitest config that was introduced in #3454 (CS-760), flagged by the cubic review on #3456.
resolve.aliasfor@/*→./src. The config had no alias mapping, so any test importing via@/...fails at module resolution. Bothapps/appandapps/framework-editorconfigs already do this.environmentfromnode→jsdom. Theincludeglob targets.jsx/.tsxcomponent tests, which need DOM APIs (e.g. testing-library'srender). Both sibling configs usejsdom; node-only tests still run fine under it.Uses the hand-mapped-alias / no-plugin approach (like
apps/framework-editor) to avoid the vite plugin type clash with Next's build-time typecheck on Vercel. Addsjsdom+vitestas portal devDependencies so resolution no longer relies on workspace hoisting.What was NOT changed (and why)
The cubic review also flagged a P2 in
auth-callback.ts— "invite recovery breaks after an OAuth error; the/authredirect dropsinviteCode." This is not a real bug. In the portal,inviteCodeis never populated:LoginFormis rendered without it in(public)/auth/page.tsx, there is no/invite/[code]route, and nothing sets it — the/invite/${inviteCode}success path is itself unreachable. Preserving it through the error path would mean building a speculative invite flow that doesn't exist here, so it's intentionally left alone.Verification
cd apps/portal && npx vitest run— 4/4 pass under jsdom. Separately verified a probe test importing via@/app/lib/...resolves correctly with the new alias (removed after verifying).Summary by cubic
Fixes the portal
vitestconfig by adding@/*alias resolution and switching the test environment tojsdom, so component tests import correctly and DOM APIs work. Follows up on CS-760 to match sibling app configs.Bug Fixes
@/*→./srcalias so@/...imports resolve in tests.jsdomfor JSX/TSX tests that need the DOM.Dependencies
jsdomandvitesttoapps/portaldevDependencies.Written for commit 4239b2d. Summary will update on new commits.