diff --git a/frontend/src/App.tool-center.test.ts b/frontend/src/App.tool-center.test.ts index 4bfe799..d46f4e8 100644 --- a/frontend/src/App.tool-center.test.ts +++ b/frontend/src/App.tool-center.test.ts @@ -112,8 +112,9 @@ describe('tool center menu entries', () => { expect(appSource).toContain('ghostRef.current.style.left = `${startGuideLeft + (newWidth - startWidth)}px`;'); }); - it('mounts heavyweight modals only while they are open', () => { - expect(appSource).toContain('{isModalOpen && ('); + it('keeps connection modal warm-mounted while leaving the other heavyweight modals conditional', () => { + expect(appSource).toContain('const [isConnectionModalMounted, setIsConnectionModalMounted] = useState(false);'); + expect(appSource).toContain('{isConnectionModalMounted && ('); expect(appSource).toContain('{isToolsModalOpen && ('); expect(appSource).toContain('{isSettingsModalOpen && ('); expect(appSource).toContain('{isThemeModalOpen && ('); diff --git a/frontend/src/components/MonacoEditor.typography.test.tsx b/frontend/src/components/MonacoEditor.typography.test.tsx new file mode 100644 index 0000000..dc8a475 --- /dev/null +++ b/frontend/src/components/MonacoEditor.typography.test.tsx @@ -0,0 +1,90 @@ +import React from 'react'; +import { renderToStaticMarkup } from 'react-dom/server'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +import MonacoEditor from './MonacoEditor'; + +const storeState = vi.hoisted(() => ({ + fontSize: 14, + appearance: { + enabled: true, + opacity: 1, + blur: 0, + uiVersion: 'v2' as 'legacy' | 'v2', + customUIFontFamily: null as string | null, + customMonoFontFamily: null as string | null, + showDataTableVerticalBorders: false, + dataTableDensity: 'comfortable' as const, + dataTableFontSize: null as number | null, + dataTableFontSizeFollowGlobal: true, + sidebarTreeFontSize: null as number | null, + sidebarTreeFontSizeFollowGlobal: true, + }, +})); + +vi.mock('../store', () => ({ + useStore: (selector: (state: typeof storeState) => any) => selector(storeState), +})); + +vi.mock('@monaco-editor/react', () => ({ + loader: { config: vi.fn() }, + default: ({ options }: { options?: Record }) => ( +
+ ), +})); + +describe('MonacoEditor typography', () => { + beforeEach(() => { + storeState.fontSize = 14; + storeState.appearance = { + enabled: true, + opacity: 1, + blur: 0, + uiVersion: 'v2', + customUIFontFamily: null, + customMonoFontFamily: null, + showDataTableVerticalBorders: false, + dataTableDensity: 'comfortable', + dataTableFontSize: null, + dataTableFontSizeFollowGlobal: true, + sidebarTreeFontSize: null, + sidebarTreeFontSizeFollowGlobal: true, + }; + }); + + it('injects v2 code-editor typography when font settings are not explicitly provided', () => { + const markup = renderToStaticMarkup( + , + ); + + expect(markup).toContain('JetBrains Mono'); + expect(markup).toContain('ui-monospace'); + expect(markup).toContain('"fontSize":13'); + expect(markup).toContain('"lineHeight":21'); + }); + + it('uses data-table font size for data-oriented editors in v2', () => { + storeState.fontSize = 16; + storeState.appearance.dataTableFontSizeFollowGlobal = false; + storeState.appearance.dataTableFontSize = 15; + + const markup = renderToStaticMarkup( + , + ); + + expect(markup).toContain('"fontSize":15'); + expect(markup).toContain('"lineHeight":24'); + }); + + it('keeps legacy editors on their explicit font settings', () => { + storeState.appearance.uiVersion = 'legacy'; + + const markup = renderToStaticMarkup( + , + ); + + expect(markup).toContain('"fontFamily":"Consolas"'); + expect(markup).toContain('"fontSize":18'); + expect(markup).not.toContain('JetBrains Mono'); + }); +});