Skip to content

improvement(codebase): centralize test mocks, extract @sim/utils, remove dead code#4228

Merged
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/codebase-quality-audit
Apr 18, 2026
Merged

improvement(codebase): centralize test mocks, extract @sim/utils, remove dead code#4228
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/codebase-quality-audit

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Created @sim/utils package — extracted id, helpers, errors, formatting from apps/sim to eliminate UUID generation inconsistency between app and packages/db
  • Added 16 new centralized mocks to @sim/testing (auth, hybrid-auth, schema, env, request, audit, encryption, input-validation, redis-config, workflows-api-utils, knowledge-api-utils, logging-session, workflows-persistence-utils, workflows-orchestration, auth-oauth-utils, copilot-http, execution-preprocessing)
  • Migrated 33 test files from inline vi.hoisted() boilerplate to centralized mocks (−558 LoC from migration alone)
  • Removed dead code: api.mock.ts, uuid.mock.ts, deprecated mockAuth() / mockHybridAuth() helpers, obsolete doc warnings
  • Replaced inline new Promise(setTimeout) with sleep() from @sim/utils/helpers
  • Replaced console.* calls in source files with @sim/logger
  • Updated .claude and .cursor testing rules with the centralized-mocks lookup table

Type of Change

  • Improvement / refactor

Testing

  • `bun run lint` — clean
  • `bun run type-check` — clean
  • `bunx vitest run` — 5260/5260 tests passing (6 pre-existing env-config failures unchanged)
  • `bun run build` — sim compiles clean; `collect page data` blocked by pre-existing `NEXT_PUBLIC_APP_URL` local env issue (not a code regression)

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 18, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 18, 2026 9:30pm

Request Review

@gitguardian
Copy link
Copy Markdown

gitguardian bot commented Apr 18, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 18, 2026

PR Summary

Medium Risk
Broad refactor across API routes and many tests to switch shared utilities and mocking strategy; risk is mainly from widespread import rewrites and potential subtle behavior differences in new @sim/utils ID/error helpers.

Overview
Introduces a new @sim/utils package and updates runtime code to use it for ID generation (generateId/generateShortId) and common helpers (sleep, toError), replacing previous app-local utility imports.

Refactors the test suite to prefer centralized module mocks from @sim/testing (e.g., auth, hybrid auth, schema/env/request/redis, copilot HTTP, workflows helpers), removing repeated local vi.hoisted() boilerplate and updating testing guidelines/docs to reflect the new patterns.

Reviewed by Cursor Bugbot for commit 6a0db71. Configure here.

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/codebase-quality-audit branch from 858b89b to 3bcf71b Compare April 18, 2026 21:20
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3bcf71b. Configure here.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6a0db71. Configure here.

@waleedlatif1 waleedlatif1 merged commit b5674d9 into staging Apr 18, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/codebase-quality-audit branch April 18, 2026 21:39
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