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
126 lines
3.5 KiB
TypeScript
126 lines
3.5 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import type { WorkflowSearchMatch } from '@/lib/workflows/search-replace/types'
|
|
import {
|
|
buildWorkflowSearchMcpToolReplacementOptions,
|
|
flattenWorkflowSearchReplacementOptions,
|
|
workflowSearchReplaceKeys,
|
|
} from '@/hooks/queries/workflow-search-replace'
|
|
|
|
function createMcpToolMatch(serverId?: string): WorkflowSearchMatch {
|
|
return {
|
|
id: serverId ? `match-${serverId}` : 'match-all',
|
|
blockId: 'mcp-1',
|
|
blockName: 'MCP',
|
|
blockType: 'mcp',
|
|
subBlockId: 'tool',
|
|
canonicalSubBlockId: 'tool',
|
|
subBlockType: 'mcp-tool-selector',
|
|
valuePath: [],
|
|
target: { kind: 'subblock' },
|
|
kind: 'mcp-tool',
|
|
rawValue: serverId ? `${serverId}-search` : 'search',
|
|
searchText: 'Search',
|
|
editable: true,
|
|
navigable: true,
|
|
protected: false,
|
|
resource: {
|
|
kind: 'mcp-tool',
|
|
key: serverId ? `${serverId}-search` : 'search',
|
|
selectorContext: serverId ? { mcpServerId: serverId } : undefined,
|
|
resourceGroupKey: serverId ? `mcp-tool:${serverId}` : 'mcp-tool:any',
|
|
},
|
|
}
|
|
}
|
|
|
|
describe('buildWorkflowSearchMcpToolReplacementOptions', () => {
|
|
const tools = [
|
|
{
|
|
id: 'a-search',
|
|
name: 'search',
|
|
serverId: 'server-a',
|
|
serverName: 'Server A',
|
|
inputSchema: {},
|
|
},
|
|
{
|
|
id: 'b-search',
|
|
name: 'search',
|
|
serverId: 'server-b',
|
|
serverName: 'Server B',
|
|
inputSchema: {},
|
|
},
|
|
]
|
|
|
|
it('filters MCP tool replacement options to the matched server context', () => {
|
|
const options = buildWorkflowSearchMcpToolReplacementOptions(
|
|
[createMcpToolMatch('server-a')],
|
|
tools
|
|
)
|
|
|
|
expect(options).toEqual([
|
|
{
|
|
kind: 'mcp-tool',
|
|
value: 'mcp-server-a-search',
|
|
label: 'Server A: search',
|
|
resourceGroupKey: 'mcp-tool:server-a',
|
|
},
|
|
])
|
|
})
|
|
|
|
it('keeps all MCP tool replacement options when no server context exists', () => {
|
|
const options = buildWorkflowSearchMcpToolReplacementOptions([createMcpToolMatch()], tools)
|
|
|
|
expect(options.map((option) => option.value)).toEqual([
|
|
'mcp-server-a-search',
|
|
'mcp-server-b-search',
|
|
])
|
|
})
|
|
})
|
|
|
|
describe('workflowSearchReplaceKeys', () => {
|
|
it('builds stable hierarchical keys for credential candidates', () => {
|
|
expect(
|
|
workflowSearchReplaceKeys.oauthReplacementOptions('gmail', 'workspace-1', 'workflow-1')
|
|
).toEqual([
|
|
'workflow-search-replace',
|
|
'replacement-options',
|
|
'oauth',
|
|
'gmail',
|
|
'workspace-1',
|
|
'workflow-1',
|
|
])
|
|
})
|
|
|
|
it('builds scoped selector replacement option keys', () => {
|
|
expect(
|
|
workflowSearchReplaceKeys.selectorReplacementOptions(
|
|
'gmail.labels',
|
|
'{"oauthCredential":"credential-1","workspaceId":"workspace-1"}'
|
|
)
|
|
).toEqual([
|
|
'workflow-search-replace',
|
|
'replacement-options',
|
|
'selector',
|
|
'gmail.labels',
|
|
'{"oauthCredential":"credential-1","workspaceId":"workspace-1"}',
|
|
])
|
|
})
|
|
})
|
|
|
|
describe('flattenWorkflowSearchReplacementOptions', () => {
|
|
it('flattens loaded option groups while ignoring pending groups', () => {
|
|
expect(
|
|
flattenWorkflowSearchReplacementOptions([
|
|
{ data: [{ kind: 'environment', value: '{{A}}', label: '{{A}}' }] },
|
|
{},
|
|
{ data: [{ kind: 'knowledge-base', value: 'kb-1', label: 'KB 1' }] },
|
|
])
|
|
).toEqual([
|
|
{ kind: 'environment', value: '{{A}}', label: '{{A}}' },
|
|
{ kind: 'knowledge-base', value: 'kb-1', label: 'KB 1' },
|
|
])
|
|
})
|
|
})
|