[ACS-11204] Fix: Duplicated site name is displayed instead of id when there are two libraries with the same name (#11682)

This commit is contained in:
Mykyta Maliarchuk
2026-02-24 10:25:24 +01:00
committed by GitHub
parent de34579038
commit 7a3650e6a7
2 changed files with 25 additions and 1 deletions
@@ -285,5 +285,26 @@ describe('NodeTooltipUtils', () => {
const result = NodeTooltipUtils.getLibraryTitle(library, allEntries);
expect(result).toBe('Library Title');
});
it('should append id as suffix when name is present and equals title', () => {
const library = { id: 'lib1', name: 'Duplicate Title', title: 'Duplicate Title' };
const allEntries = [{ id: 'lib2', title: 'Duplicate Title' }];
const result = NodeTooltipUtils.getLibraryTitle(library, allEntries);
expect(result).toBe('Duplicate Title (lib1)');
});
it('should append id as suffix when name is missing', () => {
const library = { id: 'lib1', title: 'Duplicate Title' };
const allEntries = [{ id: 'lib2', title: 'Duplicate Title' }];
const result = NodeTooltipUtils.getLibraryTitle(library, allEntries);
expect(result).toBe('Duplicate Title (lib1)');
});
it('should fallback to id when both name and title are missing', () => {
const library = { id: 'lib1' };
const allEntries = [];
const result = NodeTooltipUtils.getLibraryTitle(library, allEntries);
expect(result).toBe('lib1');
});
});
});
@@ -120,7 +120,10 @@ export class NodeTooltipUtils {
}
// If duplicate, append the ID or name in parentheses
const suffix = libraryName || libraryId;
let suffix = libraryId;
if (libraryName && libraryName !== libraryTitle) {
suffix = libraryName;
}
return isDuplicate && suffix ? `${libraryTitle} (${suffix})` : libraryTitle;
}