char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
521a64cd0
char/aliceai-t5-moe
1import { McpServerForm } from '$lib/components/app/mcp' ; 2import { mcpStore } from '$lib/stores/mcp/index.svelte' ; 3import { settingsStore } from '$lib/stores/settings/index.svelte' ; 4import { beforeEach , describe , expect , it } from 'vitest' ; 5import { render } from 'vitest-browser-svelte' ; 6 7describe ( 'mcp server display name' , () => { 8beforeEach (() => { 9settingsStore . updateConfig ( 'mcpServers' , '[]' ); 10}); 11 12it ( 'custom display name wins over the url fallback' , () => { 13const server = mcpStore . addServer ({ 14displayName :'My Tools' , 15enabled :false , 16url :'https://mcp.example.com/a' 17}); 18 19expect ( mcpStore . getServerLabel ( server )). toBe ( 'My Tools' ); 20}); 21 22it ( 'without a custom name the url is the label' , () => { 23const server = mcpStore . addServer ({ enabled :false , url :'https://mcp.example.com/a' }); 24 25expect ( mcpStore . getServerLabel ( server )). toBe ( 'https://mcp.example.com/a' ); 26}); 27 28it ( 'identical labels get positional suffixes' , () => { 29const a = mcpStore . addServer ({ 30displayName :'GitHub' , 31enabled :false , 32url :'https://mcp.example.com/a' 33}); 34const b = mcpStore . addServer ({ 35displayName :'GitHub' , 36enabled :false , 37url :'https://mcp.example.com/b' 38}); 39 40expect ( mcpStore . getServerLabel ( a )). toBe ( 'GitHub (1)' ); 41expect ( mcpStore . getServerLabel ( b )). toBe ( 'GitHub (2)' ); 42}); 43 44it ( 'renaming one twin dissolves the suffixes' , () => { 45const a = mcpStore . addServer ({ 46displayName :'GitHub' , 47enabled :false , 48url :'https://mcp.example.com/a' 49}); 50const b = mcpStore . addServer ({ 51displayName :'GitHub' , 52enabled :false , 53url :'https://mcp.example.com/b' 54}); 55 56mcpStore . updateServer ( b . id , { displayName :'GitHub Work' }); 57expect ( mcpStore . getServerLabel ( a )). toBe ( 'GitHub' ); 58expect ( mcpStore . getServerLabel ( mcpStore . getServerById ( b . id ) ! )). toBe ( 'GitHub Work' ); 59}); 60 61it ( 'the form exposes an editable display name field' , async () => { 62let captured = '' ; 63 64const screen = await render ( McpServerForm , { 65headers :'' , 66name :'' , 67onHeadersChange :() => {}, 68onNameChange :( v :string ) => ( captured = v ), 69onUrlChange :() => {}, 70url :'https://mcp.example.com/a' 71}); 72const input = screen . getByLabelText ( 'Display name' ); 73 74await expect . element ( input ). toBeVisible (); 75await input . fill ( 'My Custom Server' ); 76expect ( captured ). toBe ( 'My Custom Server' ); 77}); 78});