Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/sim/blocks/blocks/outlook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { describe, expect, it } from 'vitest'
import { tools as toolRegistry } from '@/tools/registry'
import { OutlookBlock } from './outlook'

/**
* Uses the real tool registry: these assertions are about tool registration and
* params, which the global `@/tools/registry` mock in vitest.setup.ts empties.
*/
vi.unmock('@/tools/registry')

const block = OutlookBlock

/** Every calendar operation exposed by the block's operation dropdown. */
Expand Down
11 changes: 11 additions & 0 deletions apps/sim/lib/workflows/search-replace/indexer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import {
} from '@/lib/workflows/search-replace/search-replace.fixtures'
import { WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS } from '@/lib/workflows/search-replace/subflow-fields'

/**
* Uses the real tool registry. Nothing here imports it directly — the dependency
* is transitive: the search-replace planner resolves tool input params through
* real subblock configs, so the global `@/tools/registry` mock in
* vitest.setup.ts empties the data these assertions read.
*
* Not a no-op, despite the lack of a direct import. Dropping this opt-out fails
* 8 tests across this file and its sibling suite.
*/
vi.unmock('@/tools/registry')
Comment thread
waleedlatif1 marked this conversation as resolved.

describe('indexWorkflowSearchMatches', () => {
it('finds plain text matches across nested subblock values', () => {
const workflow = createSearchReplaceWorkflowFixture()
Expand Down
11 changes: 11 additions & 0 deletions apps/sim/lib/workflows/search-replace/replacements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import {
} from '@/lib/workflows/search-replace/search-replace.fixtures'
import { WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS } from '@/lib/workflows/search-replace/subflow-fields'

/**
* Uses the real tool registry. Nothing here imports it directly — the dependency
* is transitive: the search-replace planner resolves tool input params through
* real subblock configs, so the global `@/tools/registry` mock in
* vitest.setup.ts empties the data these assertions read.
*
* Not a no-op, despite the lack of a direct import. Dropping this opt-out fails
* 8 tests across this file and its sibling suite.
*/
vi.unmock('@/tools/registry')

describe('buildWorkflowSearchReplacePlan', () => {
it('replaces selected text ranges across blocks without touching unselected matches', () => {
const workflow = createSearchReplaceWorkflowFixture()
Expand Down
6 changes: 6 additions & 0 deletions apps/sim/tools/azure_devops/azure-devops.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const baseParams = {
accessToken: 'pat-token',
}

/**
* Uses the real tool registry: these assertions are about tool registration and
* params, which the global `@/tools/registry` mock in vitest.setup.ts empties.
*/
vi.unmock('@/tools/registry')

const authHeader = `Basic ${Buffer.from(':pat-token').toString('base64')}`

const allTools = [
Expand Down
7 changes: 0 additions & 7 deletions apps/sim/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ export default defineConfig({
fileParallelism: true,
maxConcurrency: 10,
testTimeout: 10000,
deps: {
optimizer: {
web: {
enabled: true,
},
},
},
},
resolve: {
alias: [
Expand Down
16 changes: 16 additions & 0 deletions apps/sim/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ vi.mock('@/stores/execution/store', () => ({
useLastRunEdges: vi.fn().mockReturnValue(new Map()),
}))

/**
* The tool registry is 4,351 entries pulling ~5,907 modules, and almost nothing
* under test needs the real thing — but every test file that transitively
* reaches it paid to import the whole graph. Measured on the full suite:
* import 1,347s -> 633s, transform 130s -> 53s.
*
* `@/blocks/registry` is mocked the same way directly below, for the same reason.
*
* Tests that genuinely assert registration or tool params opt out with
* `vi.unmock('@/tools/registry')` at the top of the file — see
* blocks/blocks/outlook.test.ts for the pattern.
*/
vi.mock('@/tools/registry', () => ({ tools: {} }))

vi.mock('@/blocks/registry', () => ({
getBlock: vi.fn(() => ({
name: 'Mock Block',
Expand All @@ -107,6 +121,8 @@ vi.mock('@/blocks/registry', () => ({
})),
getAllBlocks: vi.fn(() => []),
getLatestBlock: vi.fn(() => undefined),
/** Mirrors the real module's accessor; without it consumers get "not a function". */
getBlockRegistry: vi.fn(() => ({})),
getBlockByToolName: vi.fn((toolName: string) =>
toolName.startsWith('gmail_')
? {
Expand Down
Loading