diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js index 4a00ad70d3dd..5a17aa148c7e 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js @@ -877,50 +877,52 @@ export const addCustomPropertiesForEntity = ( // Navigating to home page cy.clickOnLogo(); - // Checking the added property in Entity + if (entityObj) { + // Checking the added property in Entity - visitEntityDetailsPage({ - term: entityObj.term, - serviceName: entityObj.serviceName, - entity: entityObj.entity, - }); + visitEntityDetailsPage({ + term: entityObj.term, + serviceName: entityObj.serviceName, + entity: entityObj.entity, + }); - cy.get('[data-testid="custom_properties"]').click(); - cy.get('tbody').should('contain', propertyName); + cy.get('[data-testid="custom_properties"]').click(); + cy.get('tbody').should('contain', propertyName); - // Adding value for the custom property + // Adding value for the custom property - // Navigating through the created custom property for adding value - cy.get(`[data-row-key="${propertyName}"]`) - .find('[data-testid="edit-icon"]') - .as('editbutton'); - cy.wait(1000); + // Navigating through the created custom property for adding value + cy.get(`[data-row-key="${propertyName}"]`) + .find('[data-testid="edit-icon"]') + .as('editbutton'); + cy.wait(1000); - cy.get('@editbutton').click(); + cy.get('@editbutton').click(); - interceptURL( - 'PATCH', - `/api/v1/${customPropertyData.entityApiType}/*`, - 'patchEntity' - ); - // Checking for value text box or markdown box - cy.get('body').then(($body) => { - if ($body.find('[data-testid="value-input"]').length > 0) { - cy.get('[data-testid="value-input"]').type(value); - cy.get('[data-testid="inline-save-btn"]').click(); - } else if ( - $body.find( - '.toastui-editor-md-container > .toastui-editor > .ProseMirror' - ) - ) { - cy.get( - '.toastui-editor-md-container > .toastui-editor > .ProseMirror' - ).type(value); - cy.get('[data-testid="save"]').click(); - } - }); - verifyResponseStatusCode('@patchEntity', 200); - cy.get(`[data-row-key="${propertyName}"]`).should('contain', value); + interceptURL( + 'PATCH', + `/api/v1/${customPropertyData.entityApiType}/*`, + 'patchEntity' + ); + // Checking for value text box or markdown box + cy.get('body').then(($body) => { + if ($body.find('[data-testid="value-input"]').length > 0) { + cy.get('[data-testid="value-input"]').type(value); + cy.get('[data-testid="inline-save-btn"]').click(); + } else if ( + $body.find( + '.toastui-editor-md-container > .toastui-editor > .ProseMirror' + ) + ) { + cy.get( + '.toastui-editor-md-container > .toastui-editor > .ProseMirror' + ).type(value); + cy.get('[data-testid="save"]').click(); + } + }); + verifyResponseStatusCode('@patchEntity', 200); + cy.get(`[data-row-key="${propertyName}"]`).should('contain', value); + } }; export const editCreatedProperty = (propertyName) => { diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Customproperties.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Customproperties.spec.js index f173b5fc6af8..667353606b93 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Customproperties.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Customproperties.spec.js @@ -254,4 +254,72 @@ describe('Custom Properties should work properly', () => { }); }); }); + + describe('Create custom properties for glossary', () => { + const glossaryTerm = { + name: 'glossaryTerm', + description: 'This is Glossary Term custom property', + integerValue: '45', + stringValue: 'This is string propery', + markdownValue: 'This is markdown value', + entityApiType: 'glossaryTerm', + }; + const propertyName = `addcyentity${glossaryTerm.name}test${uuid()}`; + + it('test custom properties in advanced search modal', () => { + cy.get(`[data-menu-id*="customAttributes.${glossaryTerm.name}"]`) + .scrollIntoView() + .should('be.visible') + .click(); + + addCustomPropertiesForEntity( + propertyName, + glossaryTerm, + 'Integer', + '45', + null + ); + + // Navigating to explore page + cy.get('[data-testid="app-bar-item-explore"]').click(); + interceptURL( + 'GET', + `/api/v1/metadata/types/name/glossaryTerm*`, + 'getEntity' + ); + cy.get('[data-testid="glossaries-tab"]').click(); + + cy.get('[data-testid="advance-search-button"]').click(); + verifyResponseStatusCode('@getEntity', 200); + + // Click on field dropdown + cy.get('.rule--field > .ant-select > .ant-select-selector').eq(0).click(); + + // Select custom property fields + cy.get(`[title="Custom Properties"]`).eq(0).click(); + + // Click on field dropdown + cy.get('.rule--field > .ant-select > .ant-select-selector').eq(0).click(); + + // Verify field exists + cy.get(`[title="${propertyName}"]`).should('be.visible'); + }); + + it(`Delete created property for glossary term entity`, () => { + interceptURL( + 'GET', + `/api/v1/metadata/types/name/${glossaryTerm.name}*`, + 'getEntity' + ); + + // Selecting the entity + cy.get(`[data-menu-id*="customAttributes.${glossaryTerm.name}"]`) + .scrollIntoView() + .should('be.visible') + .click(); + + verifyResponseStatusCode('@getEntity', 200); + deleteCreatedProperty(propertyName); + }); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/AdvancedSearch.constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/AdvancedSearch.constants.ts index 87d178257549..f9ac603ca4ea 100644 --- a/openmetadata-ui/src/main/resources/ui/src/constants/AdvancedSearch.constants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/constants/AdvancedSearch.constants.ts @@ -364,7 +364,7 @@ const getCommonQueryBuilderFields = ( }, }, extension: { - label: t('label.custom-attribute-plural'), + label: t('label.custom-property-plural'), type: '!group', mainWidgetProps, subfields: {}, diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/GlobalSettingsUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/GlobalSettingsUtils.tsx index 6b6aa42c0298..345809ef734b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/GlobalSettingsUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/GlobalSettingsUtils.tsx @@ -282,7 +282,7 @@ export const getGlobalSettingsMenuWithPermission = ( ], }, { - category: i18next.t('label.custom-attribute-plural'), + category: i18next.t('label.custom-property-plural'), key: 'customAttributes', items: [ { diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.test.ts b/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.test.ts new file mode 100644 index 000000000000..a6a9c41579a4 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.test.ts @@ -0,0 +1,48 @@ +/* + * Copyright 2023 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { EntityType } from '../enums/entity.enum'; +import { SearchIndex } from '../enums/search.enum'; +import { getEntityTypeFromSearchIndex } from './SearchUtils'; + +describe('getEntityTypeFromSearchIndex', () => { + it.each([ + [SearchIndex.TABLE, EntityType.TABLE], + [SearchIndex.PIPELINE, EntityType.PIPELINE], + [SearchIndex.DASHBOARD, EntityType.DASHBOARD], + [SearchIndex.MLMODEL, EntityType.MLMODEL], + [SearchIndex.TOPIC, EntityType.TOPIC], + [SearchIndex.CONTAINER, EntityType.CONTAINER], + [SearchIndex.STORED_PROCEDURE, EntityType.STORED_PROCEDURE], + [SearchIndex.DASHBOARD_DATA_MODEL, EntityType.DASHBOARD_DATA_MODEL], + [SearchIndex.SEARCH_INDEX, EntityType.SEARCH_INDEX], + [SearchIndex.DATABASE_SCHEMA, EntityType.DATABASE_SCHEMA], + [SearchIndex.DATABASE_SERVICE, EntityType.DATABASE_SERVICE], + [SearchIndex.MESSAGING_SERVICE, EntityType.MESSAGING_SERVICE], + [SearchIndex.DASHBOARD_SERVICE, EntityType.DASHBOARD_SERVICE], + [SearchIndex.PIPELINE_SERVICE, EntityType.PIPELINE_SERVICE], + [SearchIndex.ML_MODEL_SERVICE, EntityType.MLMODEL_SERVICE], + [SearchIndex.STORAGE_SERVICE, EntityType.STORAGE_SERVICE], + [SearchIndex.SEARCH_SERVICE, EntityType.SEARCH_SERVICE], + [SearchIndex.GLOSSARY, EntityType.GLOSSARY_TERM], + [SearchIndex.TAG, EntityType.TAG], + [SearchIndex.DATABASE, EntityType.DATABASE], + [SearchIndex.DOMAIN, EntityType.DOMAIN], + [SearchIndex.DATA_PRODUCT, EntityType.DATA_PRODUCT], + ])('returns %p for %p', (searchIndex, expectedEntityType) => { + expect(getEntityTypeFromSearchIndex(searchIndex)).toBe(expectedEntityType); + }); + + it('returns null for an unknown search index', () => { + expect(getEntityTypeFromSearchIndex('DUMMY_INDEX')).toBeNull(); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.tsx index d6ebe11dff37..fbe02f51239e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/SearchUtils.tsx @@ -257,7 +257,7 @@ export const getEntityTypeFromSearchIndex = (searchIndex: string) => { [SearchIndex.ML_MODEL_SERVICE]: EntityType.MLMODEL_SERVICE, [SearchIndex.STORAGE_SERVICE]: EntityType.STORAGE_SERVICE, [SearchIndex.SEARCH_SERVICE]: EntityType.SEARCH_SERVICE, - [SearchIndex.GLOSSARY]: EntityType.GLOSSARY, + [SearchIndex.GLOSSARY]: EntityType.GLOSSARY_TERM, [SearchIndex.TAG]: EntityType.TAG, [SearchIndex.DATABASE]: EntityType.DATABASE, [SearchIndex.DOMAIN]: EntityType.DOMAIN,