Skip to content

test(desktop): remove flaky git-status.test.ts that leaks mocks across files#3624

Merged
Kitenite merged 2 commits into
mainfrom
ci-pipeline-flaky-tests-and-typecheck-fixes
Apr 21, 2026
Merged

test(desktop): remove flaky git-status.test.ts that leaks mocks across files#3624
Kitenite merged 2 commits into
mainfrom
ci-pipeline-flaky-tests-and-typecheck-fixes

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Apr 21, 2026

Summary

Fixes the 10 unrelated test failures that have been red-ing CI on main for the last several pushes.

The root cause was apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.test.ts. It used mock.module() to stub node:fs, @superset/local-db, ../utils/git, ../utils/github, and drizzle-orm. In the Bun test runner these module mocks persist for the remainder of the process — there's no mock.restore() path for module mocks — so every later test file that imported those paths saw the stubs instead of the real exports. On Linux CI the discovery order placed this file first, producing:

  • listExternalWorktrees detects external worktree../utils/git mock returned []
  • All 7 resolveCwd > … cases — node:fs.existsSync forced to true, breaking pathExistsCached
  • mergePullRequest > (unnamed) — mocked ../utils/github was missing getRepoContext, so spyOn failed
  • Unhandled error … Export named 'worktrees' not found … — narrower @superset/local-db mock dropped most exports

I tried surgically backfilling the missing exports first, but any shape given to those mocks broke a different downstream test. Since the procedure-level coverage here was thin (branch vs. worktree branching in getGitHubStatus/getWorktreeInfo) and not worth the cross-file fallout, this PR drops the file.

Test plan

  • bun test in apps/desktop1762 pass, 0 fail (was 1751 pass / 10 fail / 1 error on CI)
  • bun run typecheck across all 25 packages → clean
  • bun run lint → clean
  • CI green on this PR

Summary by CodeRabbit

  • Tests

    • Removed obsolete Git status test suite.
  • Data

    • Project lists now include an optional cloud project identifier for projects.
  • Navigation

    • Updated Configure button and cloud/settings redirects to use the consolidated project settings route (/settings/projects/:projectId) when applicable.

Summary by cubic

Removed a flaky Git status test that leaked Bun module mocks across files and fixed v2 settings migration fallout (routing and types). This restores consistent tests and fixes project settings navigation.

  • Bug Fixes
    • Deleted git-status.test.ts that used Bun mock.module() to stub node:fs, @superset/local-db, ../utils/git, ../utils/github, and drizzle-orm, with mocks persisting across files.
    • Fixed v2 settings migration issues: switched navigation to /settings/projects/$projectId and exposed neonProjectId in workspaces.getAllGrouped for the new sidebar.
    • Result: apps/desktop tests pass locally (1762 pass, 0 fail); repo typecheck and lint are clean.

Written for commit 910309b. Summary will update on new commits.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

Removed a Git status test file, added a nullable neonProjectId to grouped project results, and updated several settings/navigation redirect paths to use /settings/projects/$projectId (plural) or adjusted project settings route where applicable.

Changes

Cohort / File(s) Summary
Deleted test file
apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.test.ts
Removed comprehensive Bun test suite for createGitStatusProcedures() covering getGitHubStatus and getWorktreeInfo, including extensive mocks and assertions.
Query: grouped projects
apps/desktop/src/lib/trpc/routers/workspaces/procedures/query.ts
Extended grouped project shape to include `neonProjectId: string
UI routing / redirects
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/TopBar/components/WorkspaceRunButton/WorkspaceRunButton.tsx, apps/desktop/src/renderer/routes/_authenticated/settings/project/$projectId/cloud/page.tsx, apps/desktop/src/renderer/routes/_authenticated/settings/project/$projectId/cloud/secrets/page.tsx
Adjusted "Configure" / redirect targets to use /settings/projects/$projectId when projectId present or when CLOUD_ACCESS disabled; one run-button route changed from /settings/project/$projectId/general to /settings/projects/$projectId, others mirror similar redirect target updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code with nimble feet,

Deleted a test — the change is neat,
A little ID tucked in the list,
Routes adjusted with a gentle twist,
Tiny hops, the garden's sweet.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The pull request provides a comprehensive description covering the root cause of CI failures, the solution (removing the test file), and detailed test results. However, the required template sections are not properly filled out. Reorganize the description to match the template structure: add a concise Description section, use GitHub keywords in Related Issues, explicitly mark Type of Change as 'Refactor' or 'Bug fix', and document Testing details in the template format.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: removing a flaky test file that causes mock pollution across test files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci-pipeline-flaky-tests-and-typecheck-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 1 file

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 21, 2026

Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance.

…ss files

The test used `mock.module()` to stub `node:fs`, `@superset/local-db`,
`../utils/git`, `../utils/github`, and `drizzle-orm`. In the Bun test
runner these module mocks persist for the remainder of the process, so
every subsequent test file that imported those paths saw the stubs
instead of the real exports. On Linux CI the iteration order placed
`git-status.test.ts` before the affected files, producing 10 unrelated
failures: `listExternalWorktrees` (mocked to return `[]`), all seven
`resolveCwd` cases (`existsSync` forced to `true`, breaking
`pathExistsCached`), `mergePullRequest` (missing `getRepoContext` on
the mocked `utils/github` module), and the "worktrees not found"
syntax error from the narrower `@superset/local-db` override.

The procedure-level coverage here was thin (mostly branch/worktree
branching in getGitHubStatus/getWorktreeInfo) and not worth the
cross-file fallout, so drop the file.
…ration

Three navigate/Navigate callers pointed at the removed
`/settings/project/$projectId/general` route; switch them to the
consolidated `/settings/projects/$projectId` page that replaced it.

Also expose `neonProjectId` on the project object returned by
`workspaces.getAllGrouped`, since `ProjectsSettingsSidebar` now uses it
to hide v1 rows whose v2 counterpart has already loaded.
@Kitenite Kitenite force-pushed the ci-pipeline-flaky-tests-and-typecheck-fixes branch from 14d86c6 to 910309b Compare April 21, 2026 21:59
@Kitenite Kitenite merged commit 9e8b08c into main Apr 21, 2026
6 checks passed
@Kitenite Kitenite deleted the ci-pipeline-flaky-tests-and-typecheck-fixes branch April 21, 2026 22:15
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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.

1 participant