Merge pull request #27404 from stephenglass/fix-search-ui-formatting
fix(search): fix collator text formatting for entities without description
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-search-backend-module-catalog': patch
|
||||
---
|
||||
|
||||
Fix search collator text formatting for catalog entities without description
|
||||
+29
@@ -147,5 +147,34 @@ describe('DefaultCatalogCollatorEntityTransformer', () => {
|
||||
owner: '',
|
||||
});
|
||||
});
|
||||
|
||||
it('sets text correctly when description is not provided', async () => {
|
||||
const userEntityWithoutDescription = {
|
||||
...userEntity,
|
||||
metadata: {
|
||||
...userEntity.metadata,
|
||||
description: undefined,
|
||||
},
|
||||
spec: {
|
||||
profile: {
|
||||
...userEntity.spec.profile,
|
||||
email: undefined,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const document = defaultCatalogCollatorEntityTransformer(
|
||||
userEntityWithoutDescription,
|
||||
);
|
||||
|
||||
expect(document).toMatchObject({
|
||||
title: userEntity.metadata.name,
|
||||
text: userEntity.spec.profile.displayName,
|
||||
namespace: 'default',
|
||||
componentType: 'other',
|
||||
lifecycle: '',
|
||||
owner: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+3
-1
@@ -19,7 +19,9 @@ import { CatalogCollatorEntityTransformer } from './CatalogCollatorEntityTransfo
|
||||
|
||||
const getDocumentText = (entity: Entity): string => {
|
||||
const documentTexts: string[] = [];
|
||||
documentTexts.push(entity.metadata.description || '');
|
||||
if (entity.metadata.description) {
|
||||
documentTexts.push(entity.metadata.description);
|
||||
}
|
||||
|
||||
if (isUserEntity(entity) || isGroupEntity(entity)) {
|
||||
if (entity.spec?.profile?.displayName) {
|
||||
|
||||
Reference in New Issue
Block a user