d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
115 lines
3.2 KiB
TypeScript
115 lines
3.2 KiB
TypeScript
import {
|
|
workflowsPersistenceUtilsMock,
|
|
workflowsPersistenceUtilsMockFns,
|
|
workflowsUtilsMock,
|
|
workflowsUtilsMockFns,
|
|
} from '@sim/testing'
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const {
|
|
ensureWorkflowAccessMock,
|
|
getEffectiveBlockOutputPathsMock,
|
|
hasTriggerCapabilityMock,
|
|
getBlockMock,
|
|
} = vi.hoisted(() => ({
|
|
ensureWorkflowAccessMock: vi.fn(),
|
|
getEffectiveBlockOutputPathsMock: vi.fn(),
|
|
hasTriggerCapabilityMock: vi.fn(),
|
|
getBlockMock: vi.fn(),
|
|
}))
|
|
|
|
const loadWorkflowFromNormalizedTablesMock =
|
|
workflowsPersistenceUtilsMockFns.mockLoadWorkflowFromNormalizedTables
|
|
const getWorkflowByIdMock = workflowsUtilsMockFns.mockGetWorkflowById
|
|
|
|
vi.mock('../access', () => ({
|
|
ensureWorkflowAccess: ensureWorkflowAccessMock,
|
|
ensureWorkspaceAccess: vi.fn(),
|
|
getDefaultWorkspaceId: vi.fn(),
|
|
}))
|
|
|
|
vi.mock('@/lib/workflows/persistence/utils', () => workflowsPersistenceUtilsMock)
|
|
|
|
vi.mock('@/lib/workflows/blocks/block-outputs', () => ({
|
|
getEffectiveBlockOutputPaths: getEffectiveBlockOutputPathsMock,
|
|
}))
|
|
|
|
vi.mock('@/lib/workflows/triggers/trigger-utils', () => ({
|
|
hasTriggerCapability: hasTriggerCapabilityMock,
|
|
}))
|
|
|
|
vi.mock('@/blocks/registry', () => ({
|
|
getBlock: getBlockMock,
|
|
}))
|
|
|
|
vi.mock('@/lib/workflows/utils', () => workflowsUtilsMock)
|
|
|
|
import { executeGetBlockOutputs } from './queries'
|
|
|
|
describe('executeGetBlockOutputs', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
ensureWorkflowAccessMock.mockResolvedValue({
|
|
workflow: { id: 'wf-1', userId: 'user-1', workspaceId: 'ws-1' },
|
|
})
|
|
getWorkflowByIdMock.mockResolvedValue({ variables: {} })
|
|
getBlockMock.mockReturnValue({ category: 'core' })
|
|
hasTriggerCapabilityMock.mockReturnValue(false)
|
|
getEffectiveBlockOutputPathsMock.mockReturnValue(['content'])
|
|
})
|
|
|
|
it('returns display outputs and block-relative outputs for chat deployment', async () => {
|
|
loadWorkflowFromNormalizedTablesMock.mockResolvedValue({
|
|
blocks: {
|
|
'agent-1': {
|
|
type: 'agent',
|
|
name: 'Support Agent',
|
|
subBlocks: {},
|
|
},
|
|
'loop-1': {
|
|
type: 'loop',
|
|
name: 'Items Loop',
|
|
},
|
|
},
|
|
loops: {
|
|
'loop-1': {
|
|
loopType: 'forEach',
|
|
},
|
|
},
|
|
parallels: {},
|
|
})
|
|
|
|
const result = await executeGetBlockOutputs({ blockIds: ['agent-1', 'loop-1'] }, {
|
|
workflowId: 'wf-1',
|
|
userId: 'user-1',
|
|
} as any)
|
|
|
|
expect(result.success).toBe(true)
|
|
expect(result.output).toEqual({
|
|
blocks: [
|
|
{
|
|
blockId: 'agent-1',
|
|
blockName: 'Support Agent',
|
|
blockType: 'agent',
|
|
outputs: ['supportagent.content'],
|
|
relativeOutputs: ['content'],
|
|
triggerMode: undefined,
|
|
},
|
|
{
|
|
blockId: 'loop-1',
|
|
blockName: 'Items Loop',
|
|
blockType: 'loop',
|
|
outputs: [],
|
|
relativeOutputs: [],
|
|
insideSubflowOutputs: ['itemsloop.index', 'itemsloop.currentItem', 'itemsloop.items'],
|
|
outsideSubflowOutputs: ['itemsloop.results'],
|
|
relativeInsideSubflowOutputs: ['index', 'currentItem', 'items'],
|
|
relativeOutsideSubflowOutputs: ['results'],
|
|
triggerMode: undefined,
|
|
},
|
|
],
|
|
variables: [],
|
|
})
|
|
})
|
|
})
|