Skip to content

improvement(tests): converge env-flags mocks onto a complete shared mock#5871

Merged
waleedlatif1 merged 4 commits into
stagingfrom
test/env-flags-convergence2
Jul 23, 2026
Merged

improvement(tests): converge env-flags mocks onto a complete shared mock#5871
waleedlatif1 merged 4 commits into
stagingfrom
test/env-flags-convergence2

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Type of Change

  • Improvement

Testing

Full apps/sim suite green locally (13732/13733; sole failure is the known local ripgrep dependency, green in CI). All 66 migrated files re-verified together (1729/1729). tsc clean in apps/sim and packages/testing; biome clean.

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)

A bare vi.mock('drizzle-orm') automock colliding with factory mocks of the
same module in a shared worker corrupts vitest's mock registry (upstream
vitest-dev/vitest#10290 / #10145, reproduced in isolation). The global
factory mock already covers this suite.
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 23, 2026 12:28am

Request Review

@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to test mocks and setup; no runtime application paths are modified.

Overview
Test infrastructure only — production env-flags behavior is unchanged; this standardizes how suites stub deployment flags under Vitest’s shared worker.

Suites no longer define local vi.mock('@/lib/core/config/env-flags', …) factories (often incomplete, which leaked missing exports like isHosted across files). They import setEnvFlags, resetEnvFlagsMock, and sometimes envFlagsMockFns from @sim/testing, set flags in beforeEach / beforeAll, and reset in afterAll. Coverage spans API routes, billing, copilot, blocks, EE, rate limits, MCP, tables, and React component tests.

The shared mock is documented as a full stand-in for the real module (all flags plus helpers such as getCostMultiplier and getPreviewBlocksFromEnv), installed globally via vitest setup.

Also drops the only bare vi.mock('drizzle-orm') automock in knowledge search utils tests, which could corrupt Vitest’s mock registry when mixed with factory mocks in the same worker.

Reviewed by Cursor Bugbot for commit 718c7fe. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR consolidates environment-flag mocks into one complete shared test module. The main changes are:

  • Adds stateful controls and live accessors for all environment flags.
  • Registers the shared mock globally in Vitest setup.
  • Migrates file-local factories to shared flag controls.
  • Removes the conflicting bare drizzle-orm automock.
  • Runs affected provider utility tests sequentially.

Confidence Score: 5/5

This looks safe to merge.

  • The shared mock covers the real module's flag and function exports.
  • The latest changes serialize tests that mutate shared flag state.
  • No blocking issue remains in the reviewed changes.

Important Files Changed

Filename Overview
packages/testing/src/mocks/env-flags.mock.ts Adds the complete stateful environment-flags mock and its mutation and reset helpers.
apps/sim/vitest.setup.ts Registers the shared environment-flags mock for the full Vitest suite.
apps/sim/providers/utils.test.ts Migrates provider tests to shared flag controls and serializes state-mutating cases.

Reviews (3): Last reviewed commit: "fix(tests): run providers/utils cases se..." | Re-trigger Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/providers/utils.test.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 718c7fe. Configure here.

@waleedlatif1
waleedlatif1 merged commit 9d8e14c into staging Jul 23, 2026
15 checks passed
@waleedlatif1
waleedlatif1 deleted the test/env-flags-convergence2 branch July 23, 2026 00:31
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