Skip to content

Commit 8f98389

Browse files
committed
improvement(tests): verify agent behavior at integration boundaries
1 parent 121fcc0 commit 8f98389

41 files changed

Lines changed: 693 additions & 1110 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/sim/app/api/v2/logs/[runId]/route.test.ts‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,33 +104,6 @@ describe('GET /api/v2/logs/[runId]', () => {
104104
})
105105
})
106106

107-
it('accepts snapshot omission without changing the run authorization identity', async () => {
108-
const request = new NextRequest(
109-
'http://localhost:3000/api/v2/logs/run-1?includeWorkflowState=false'
110-
)
111-
const response = await GET(request, { params: Promise.resolve({ runId: 'run-1' }) })
112-
113-
expect(response.status).toBe(200)
114-
expect(mocks.execute).toHaveBeenCalledWith({
115-
principal: auth.principal,
116-
input: { runId: 'run-1', includeWorkflowState: false },
117-
request,
118-
})
119-
})
120-
121-
it.each(['includeWorkflowState=invalid', 'unknownOption=true'])(
122-
'rejects invalid log options before the use case: %s',
123-
async (query) => {
124-
const response = await GET(
125-
new NextRequest(`http://localhost:3000/api/v2/logs/run-1?${query}`),
126-
{ params: Promise.resolve({ runId: 'run-1' }) }
127-
)
128-
129-
expect(response.status).toBe(400)
130-
expect(mocks.execute).not.toHaveBeenCalled()
131-
}
132-
)
133-
134107
/**
135108
* Stored spans carry only `duration`; the contract publishes `durationMs`
136109
* beside it, and readers that trusted the documented name found it empty on

‎apps/sim/app/api/v2/tools/files/download/route.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** @vitest-environment node */
21
import { Readable } from 'node:stream'
32
import {
43
MockV2ApiKeyUnauthenticatedError,
@@ -64,7 +63,6 @@ function request(query: Record<string, string> = {}, method = 'GET') {
6463

6564
describe('authenticated direct tool file download', () => {
6665
beforeEach(() => {
67-
vi.clearAllMocks()
6866
v2RouteMocks.authenticate.mockResolvedValue(auth)
6967
v2RouteMocks.preauthRate.mockResolvedValue(V2_PREAUTH_RATE_LIMIT_ALLOWED)
7068
v2RouteMocks.operationRate.mockResolvedValue(V2_OPERATION_RATE_LIMIT_ALLOWED)

‎apps/sim/app/api/v2/workflows/[workflowId]/execute/route.test.ts‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -831,27 +831,6 @@ describe('POST /api/v2/workflows/[workflowId]/execute', () => {
831831
expect(mockExecuteWorkflowCore).not.toHaveBeenCalled()
832832
})
833833

834-
it('forwards an explicit deployed entry to async execution with its immutable version', async () => {
835-
mockLoadDeployedWorkflowState.mockResolvedValue({
836-
deploymentVersionId: 'version-1',
837-
blocks: {
838-
api: createBlock({ id: 'api', type: 'api_trigger' }),
839-
schedule: createBlock({ id: 'schedule', type: 'schedule' }),
840-
},
841-
})
842-
const res = await callExecute({
843-
async: true,
844-
run: { source: 'deployment', entry: { type: 'trigger', blockId: 'schedule' } },
845-
})
846-
expect(res.status).toBe(202)
847-
expect(mockEnqueue).toHaveBeenCalledWith(
848-
'workflow-execution',
849-
expect.objectContaining({ triggerBlockId: 'schedule', deploymentVersionId: 'version-1' }),
850-
expect.anything()
851-
)
852-
expect(mockExecuteWorkflowCore).not.toHaveBeenCalled()
853-
})
854-
855834
it('validates a stop target before executing and pins the validated state', async () => {
856835
const res = await callExecute({ stopAfterBlockId: 'start' })
857836
expect(res.status).toBe(200)

‎apps/sim/app/api/v2/workflows/[workflowId]/inspect/route.test.ts‎

Lines changed: 0 additions & 79 deletions
This file was deleted.

‎apps/sim/app/api/v2/workflows/[workflowId]/runs/preview/route.test.ts‎

Lines changed: 0 additions & 109 deletions
This file was deleted.

‎apps/sim/background/async-preprocessing-correlation.test.ts‎

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -222,60 +222,6 @@ describe('async preprocessing correlation threading', () => {
222222
)
223223
})
224224

225-
it('loads the admitted immutable deployment and its variables instead of the newer active draft', async () => {
226-
const deployed = {
227-
blocks: { schedule: { type: 'schedule' } },
228-
edges: [],
229-
loops: {},
230-
parallels: {},
231-
deploymentVersionId: 'admitted-version',
232-
variables: { source: 'deployed' },
233-
}
234-
workflowsPersistenceUtilsMockFns.mockLoadWorkflowDeploymentVersionState.mockResolvedValueOnce(
235-
deployed
236-
)
237-
mockPreprocessExecution.mockResolvedValueOnce({
238-
success: true,
239-
actorUserId: 'actor-1',
240-
workflowRecord: {
241-
id: 'workflow-1',
242-
userId: 'owner-1',
243-
workspaceId: 'workspace-1',
244-
variables: { source: 'draft' },
245-
},
246-
billingAttribution,
247-
executionTimeout: {},
248-
})
249-
mockExecuteWorkflowCore.mockResolvedValueOnce({
250-
success: true,
251-
status: 'success',
252-
output: {},
253-
metadata: { duration: 10, userId: 'actor-1' },
254-
})
255-
await executeWorkflowJob({
256-
principal,
257-
workflowId: 'workflow-1',
258-
userId: 'actor-1',
259-
workspaceId: 'workspace-1',
260-
billingAttribution,
261-
triggerType: 'api',
262-
triggerBlockId: 'schedule',
263-
deploymentVersionId: 'admitted-version',
264-
executionId: 'execution-1',
265-
})
266-
expect(
267-
workflowsPersistenceUtilsMockFns.mockLoadWorkflowDeploymentVersionState
268-
).toHaveBeenCalledWith('workflow-1', 'admitted-version', 'workspace-1')
269-
expect(mockLoadDeployedWorkflowState).not.toHaveBeenCalled()
270-
expect(mockExecutionSnapshot).toHaveBeenCalledWith(
271-
expect.objectContaining({ triggerBlockId: 'schedule', workflowStateOverride: deployed }),
272-
expect.anything(),
273-
undefined,
274-
{ source: 'deployed' },
275-
expect.any(Array)
276-
)
277-
})
278-
279225
it.each([
280226
{
281227
name: 'workspace API key',

‎apps/sim/blocks/blocks/slack.test.ts‎

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it } from 'vitest'
22
import { evaluateSubBlockCondition } from '@/lib/workflows/subblocks/visibility'
3-
import { SlackV2Block } from '@/blocks/blocks/slack'
3+
import { SlackBlock, SlackV2Block } from '@/blocks/blocks/slack'
44

55
function mapSlackV2Params(params: Record<string, unknown>): Record<string, unknown> {
66
const mapParams = SlackV2Block.tools.config?.params
@@ -112,55 +112,18 @@ describe('Slack block release', () => {
112112
})
113113
})
114114

115-
describe.each([SlackBlock, SlackV2Block])('$type Block Kit fallback text', (block) => {
116-
it.each(['send', 'ephemeral', 'update', 'schedule_message'])(
117-
'keeps optional fallback text visible for %s and preserves it through parameter mapping',
118-
(operation) => {
119-
const fieldId = operation === 'update' ? 'updateText' : 'text'
115+
describe.each([SlackBlock, SlackV2Block])('$type channel target visibility', (block) => {
116+
it('keeps both channel inputs visible for a channel-only operation after a DM action', () => {
117+
const operation = 'update'
118+
for (const fieldId of ['channel', 'manualChannel']) {
120119
const field = block.subBlocks.find((candidate) => candidate.id === fieldId)
121-
if (!field || !block.tools.config?.params) throw new Error('Slack message field is missing')
122-
const values = {
123-
operation,
124-
messageFormat: 'blocks',
125-
[fieldId]: 'Deployment is ready.\nReview the release notes.',
126-
blocks: '[{"type":"section","text":{"type":"mrkdwn","text":"*Ready*"}}]',
127-
scheduleAt: '2000000000',
128-
}
129-
130-
expect(evaluateSubBlockCondition(field.condition, values)).toBe(true)
131-
expect(typeof field.required).toBe('object')
132-
expect(evaluateSubBlockCondition(field.required as typeof field.condition, values)).toBe(
133-
false
134-
)
120+
if (!field) throw new Error(`Missing ${fieldId}`)
135121
expect(
136-
evaluateSubBlockCondition(field.required as typeof field.condition, {
137-
...values,
138-
messageFormat: 'text',
139-
})
122+
evaluateSubBlockCondition(field.condition, { operation, destinationType: 'dm' }),
123+
fieldId
140124
).toBe(true)
141-
expect(block.tools.config.params(values)).toMatchObject({
142-
text: values[fieldId],
143-
blocks: values.blocks,
144-
})
145-
expect(block.tools.config.params({ ...values, [fieldId]: undefined }).text).toBeUndefined()
146125
}
147-
)
148-
})
149-
150-
describe.each([SlackBlock, SlackV2Block])('$type channel target visibility', (block) => {
151-
it.each(['update', 'react', 'archive_conversation', 'get_channel_history', 'ephemeral'])(
152-
'keeps both channel inputs visible for %s after a DM action',
153-
(operation) => {
154-
for (const fieldId of ['channel', 'manualChannel']) {
155-
const field = block.subBlocks.find((candidate) => candidate.id === fieldId)
156-
if (!field) throw new Error(`Missing ${fieldId}`)
157-
expect(
158-
evaluateSubBlockCondition(field.condition, { operation, destinationType: 'dm' }),
159-
fieldId
160-
).toBe(true)
161-
}
162-
}
163-
)
126+
})
164127

165128
it.each(['send', 'read', 'schedule_message'])(
166129
'preserves the channel/DM switch for %s in both modes',

0 commit comments

Comments
 (0)