import { readFileSync } from 'node:fs'; import { describe, expect, it } from 'vitest'; const app = readFileSync(new URL('../../src/app/App.tsx', import.meta.url), 'utf8'); const datahub = readFileSync(new URL('../../src/features/project-import/DataHub.tsx', import.meta.url), 'utf8'); const layout = readFileSync(new URL('../../src/styles/layout.css', import.meta.url), 'utf8'); describe('Datahub topbar context', () => { it('labels the overview Data Hub and an opened detail Client', () => { expect(app).toContain("'data-hub': 'Data Hub'"); expect(app).toContain("activeArea === 'data-hub' && dataHubClientView ? 'Client' : AREA_TOPBAR_TITLE[activeArea]"); expect(app).toContain('onDetailViewChanged={handleDataHubDetailViewChanged}'); expect(datahub).toContain("onDetailViewChanged?.(form !== null, form?.mode === 'edit' ? form.name.trim() || form.project?.name : undefined)"); expect(datahub).toContain('useEffect(() => () => onDetailViewChanged?.(false), [onDetailViewChanged])'); }); it('labels the graph area consistently as Pathfinder', () => { expect(app).toContain("graph: 'Pathfinder'"); expect(app).toContain("['graph', 'Pathfinder']"); expect(app).not.toContain("graph: 'MITRE Attack Paths'"); expect(app).not.toContain("['graph', 'Graph']"); }); it('shows the active client as unboxed right-aligned text in every area header', () => { expect(app).toContain("const headerClientName = (activeArea === 'data-hub' && dataHubClientView ? dataHubDetailClientName : activeProjectName)?.trim();"); expect(app).toContain('const handleDataHubDetailViewChanged = useCallback((isDetailView: boolean, clientName?: string) =>'); expect(app.match(/className="app-header-client-name"/g)).toHaveLength(1); expect(app).toContain('const headerContext =