Skip to content

fix(ui): hoist Vitest mock state - #684

Merged
JSONbored merged 2 commits into
mainfrom
codex/fix-unhoisted-vitest-mock-state-in-ui-tests
Jun 14, 2026
Merged

fix(ui): hoist Vitest mock state#684
JSONbored merged 2 commits into
mainfrom
codex/fix-unhoisted-vitest-mock-state-in-ui-tests

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Prevent Vitest mock-hoisting / temporal-dead-zone failures where vi.mock factories close over top-level const mocks (apiFetch, useSession) and could throw ReferenceError during test initialization.

Description

  • Initialize the shared mock state with vi.hoisted in the two affected tests by replacing const apiFetch = vi.fn() and const useSession = vi.fn() with const { apiFetch } = vi.hoisted(() => ({ apiFetch: vi.fn() })) and const { useSession } = vi.hoisted(() => ({ useSession: vi.fn() })) in apps/gittensory-ui/src/components/site/app-panels/ai-review-settings.test.tsx and apps/gittensory-ui/src/components/site/app-panels/maintainer-panel.test.tsx respectively.

Testing

  • Ran git diff --check which passed, attempted npm run ui:test but it could not complete because the vitest executable is missing from the current dependency install, attempted npm run ui:typecheck but it failed due to missing vite/client type definitions, and npm ci could not repair dependencies because the registry returned 403 for esbuild, so a full local test run could not be completed.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 14, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 987d7ab Commit Preview URL

Branch Preview URL
Jun 14 2026, 02:15 PM

@ghost

ghost commented Jun 14, 2026

Copy link
Copy Markdown

Note

Gittensory Gate skipped

PR closed before full evaluation. No late first comment was created.

Signal Result Evidence Action
Gate result ⚠️ Skipped #684 is no longer open. No action.

💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

@ghost ghost added the gittensory:reviewed label Jun 14, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@ghost

ghost commented Jun 14, 2026

Copy link
Copy Markdown

gittensory · advisory review

Reviewed 2 changed file(s) — two independent AI reviewers.

Suggested action:Safe to merge — both reviewers found no blocking issues.

Reviewer A · gpt-oss-120b — recommends ✅ merge
The PR updates two UI test files to use vi.hoisted for mocking, ensuring the mocks are applied before module imports. The changes are limited to test setup and do not affect production code.

Suggestions

  • Add a brief comment explaining why vi.hoisted is used for future maintainers.
  • Run the full test suite to confirm no other tests are impacted by the changed mock behavior.

Worth double-checking

  • If other tests rely on the same modules being mocked differently, they could be unintentionally affected.

Reviewer B · nemotron-3-120b-a12b — recommends ✅ merge
The PR hoists Vitest mock state in two UI test files using vi.hoisted() to improve test isolation. This is a standard Vitest best practice to prevent state leakage between tests by ensuring mocks are reset properly. The change is isolated to test files and does not affect production code, public/private boundaries, or introduce any user-facing changes.

No blocking issues spotted.

Before = production · After = this PR's preview deploy.

Route Viewport Before After
/ desktop before desktop after desktop
mobile before mobile after mobile

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

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant