Skip to content

test(portal): fix vitest config (jsdom + @/ alias)#3458

Merged
tofikwest merged 3 commits into
mainfrom
fix/portal-vitest-test-config
Jul 20, 2026
Merged

test(portal): fix vitest config (jsdom + @/ alias)#3458
tofikwest merged 3 commits into
mainfrom
fix/portal-vitest-test-config

Conversation

@tofikwest

@tofikwest tofikwest commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What

Fixes two real gaps in the portal vitest config that was introduced in #3454 (CS-760), flagged by the cubic review on #3456.

  • Add resolve.alias for @/*./src. The config had no alias mapping, so any test importing via @/... fails at module resolution. Both apps/app and apps/framework-editor configs already do this.
  • Switch environment from nodejsdom. The include glob targets .jsx/.tsx component tests, which need DOM APIs (e.g. testing-library's render). Both sibling configs use jsdom; 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. Adds jsdom + vitest as 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 /auth redirect drops inviteCode." This is not a real bug. In the portal, inviteCode is never populated: LoginForm is 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 vitest config by adding @/* alias resolution and switching the test environment to jsdom, so component tests import correctly and DOM APIs work. Follows up on CS-760 to match sibling app configs.

  • Bug Fixes

    • Add @/*./src alias so @/... imports resolve in tests.
    • Use jsdom for JSX/TSX tests that need the DOM.
    • Mirror alias by hand; no Vite plugins to avoid Next/Vercel type clashes.
  • Dependencies

    • Add jsdom and vitest to apps/portal devDependencies.

Written for commit 4239b2d. Summary will update on new commits.

Review in cubic

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.
@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jul 20, 2026 9:57pm
comp-framework-editor Ready Ready Preview, Comment Jul 20, 2026 9:57pm
portal Ready Ready Preview, Comment Jul 20, 2026 9:57pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@tofikwest
tofikwest merged commit 2ca14a5 into main Jul 20, 2026
7 of 10 checks passed
@tofikwest
tofikwest deleted the fix/portal-vitest-test-config branch July 20, 2026 21:55
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.104.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants