From 0092b0bbf5b2bd87c534f5affc49a3cf1d374216 Mon Sep 17 00:00:00 2001 From: Cristian Date: Thu, 25 Jun 2026 19:34:55 +0200 Subject: [PATCH] Fix single connection rendering --- .../connectionsMenu/connectionList.tsx | 7 ++- test/widgets/connectionsList.test.tsx | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 test/widgets/connectionsList.test.tsx diff --git a/src/widgets/connectionsMenu/connectionList.tsx b/src/widgets/connectionsMenu/connectionList.tsx index a2150545..8af4928e 100644 --- a/src/widgets/connectionsMenu/connectionList.tsx +++ b/src/widgets/connectionsMenu/connectionList.tsx @@ -77,9 +77,10 @@ export function ConnectionsList(props: { count: inexact && totalCount > 0 ? 'some' : totalCount, }); entries.push({type: 'separator'}); - for (const entry of regularEntries) { - entries.push(entry); - } + } + + for (const entry of regularEntries) { + entries.push(entry); } if (probableEntries.length > 0) { diff --git a/test/widgets/connectionsList.test.tsx b/test/widgets/connectionsList.test.tsx new file mode 100644 index 00000000..6960a679 --- /dev/null +++ b/test/widgets/connectionsList.test.tsx @@ -0,0 +1,55 @@ +import * as React from 'react'; +import { describe, expect, it } from 'vitest'; +import { render } from 'vitest-browser-react'; + +import { type Translation, TranslationProvider } from '../../src/coreUtils/i18n'; +import { ConnectionsList } from '../../src/widgets/connectionsMenu/connectionList'; +import { + WorkspaceContext, + type WorkspaceContext as WorkspaceContextType, +} from '../../src/workspace/workspaceContext'; + +const link = {id: 'iri', label: []}; +const translation = { + formatLabel: () => 'relation', + text: (key: string) => key, +} as unknown as Translation; +const workspace = { + model: { + language: 'en', + locale: {formatIri: (value: string) => value}, + operations: [], + getLinkType: () => undefined, + getOperationFailReason: () => undefined, + events: { + on: () => undefined, + off: () => undefined, + }, + }, +} as unknown as WorkspaceContextType; + +describe('ConnectionsList', () => { + it('renders the only connection link', async () => { + await render( + + + undefined} + onMoveToFilter={undefined} + scrolledListRef={React.createRef()} + /> + + + ); + + expect(document.body.textContent).toContain('relation'); + }); +});