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
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const { mockToolsChannel, mockWorkflowToolsChannel } = vi.hoisted(() => {
|
|
const mockToolsChannel = {
|
|
publish: vi.fn(),
|
|
subscribe: vi.fn(() => vi.fn()),
|
|
dispose: vi.fn(),
|
|
}
|
|
const mockWorkflowToolsChannel = {
|
|
publish: vi.fn(),
|
|
subscribe: vi.fn(() => vi.fn()),
|
|
dispose: vi.fn(),
|
|
}
|
|
return { mockToolsChannel, mockWorkflowToolsChannel }
|
|
})
|
|
|
|
vi.mock('@/lib/events/pubsub', () => ({
|
|
createPubSubChannel: vi.fn((config: { label: string }) => {
|
|
if (config.label === 'mcp-tools') return mockToolsChannel
|
|
if (config.label === 'mcp-workflow-tools') return mockWorkflowToolsChannel
|
|
return null
|
|
}),
|
|
}))
|
|
|
|
import { mcpPubSub } from '@/lib/mcp/pubsub'
|
|
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
describe('RedisMcpPubSub', () => {
|
|
it('delegates publishToolsChanged to the tools channel', () => {
|
|
const event = {
|
|
serverId: 'srv-1',
|
|
serverName: 'Test',
|
|
workspaceId: 'ws-1',
|
|
timestamp: Date.now(),
|
|
}
|
|
|
|
mcpPubSub.publishToolsChanged(event)
|
|
|
|
expect(mockToolsChannel.publish).toHaveBeenCalledWith(event)
|
|
})
|
|
|
|
it('delegates publishWorkflowToolsChanged to the workflow tools channel', () => {
|
|
const event = {
|
|
workflowId: 'wf-1',
|
|
workspaceId: 'ws-1',
|
|
timestamp: Date.now(),
|
|
}
|
|
|
|
mcpPubSub.publishWorkflowToolsChanged(event)
|
|
|
|
expect(mockWorkflowToolsChannel.publish).toHaveBeenCalledWith(event)
|
|
})
|
|
|
|
it('delegates onToolsChanged to the tools channel subscribe', () => {
|
|
const handler = vi.fn()
|
|
const mockUnsub = vi.fn()
|
|
mockToolsChannel.subscribe.mockReturnValueOnce(mockUnsub)
|
|
|
|
const unsub = mcpPubSub.onToolsChanged(handler)
|
|
|
|
expect(mockToolsChannel.subscribe).toHaveBeenCalledWith(handler)
|
|
expect(unsub).toBe(mockUnsub)
|
|
})
|
|
|
|
it('delegates onWorkflowToolsChanged to the workflow tools channel subscribe', () => {
|
|
const handler = vi.fn()
|
|
const mockUnsub = vi.fn()
|
|
mockWorkflowToolsChannel.subscribe.mockReturnValueOnce(mockUnsub)
|
|
|
|
const unsub = mcpPubSub.onWorkflowToolsChanged(handler)
|
|
|
|
expect(mockWorkflowToolsChannel.subscribe).toHaveBeenCalledWith(handler)
|
|
expect(unsub).toBe(mockUnsub)
|
|
})
|
|
|
|
describe('dispose', () => {
|
|
it('calls dispose on both channels', () => {
|
|
mcpPubSub.dispose()
|
|
|
|
expect(mockToolsChannel.dispose).toHaveBeenCalledTimes(1)
|
|
expect(mockWorkflowToolsChannel.dispose).toHaveBeenCalledTimes(1)
|
|
})
|
|
})
|
|
})
|