From 27b503e8888b45bbd269b4b98d68fedc60dc296a Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Sat, 28 Sep 2024 22:08:23 +0530 Subject: [PATCH] add more test --- .../ui/playwright/constant/customProperty.ts | 208 ++++++++++++++++++ .../e2e/Pages/Customproperties-part2.spec.ts | 43 +++- .../ui/playwright/utils/customProperty.ts | 107 ++++++++- 3 files changed, 352 insertions(+), 6 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/constant/customProperty.ts b/openmetadata-ui/src/main/resources/ui/playwright/constant/customProperty.ts index 65240c22a2e1..ccfbfa985c8c 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/constant/customProperty.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/constant/customProperty.ts @@ -48,6 +48,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -66,6 +79,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -84,6 +110,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -102,6 +141,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -120,6 +172,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -138,6 +203,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -156,6 +234,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: true, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -174,6 +265,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -192,6 +296,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -210,6 +327,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -228,6 +358,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -245,6 +388,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -263,6 +419,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -280,6 +449,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -297,6 +479,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', @@ -314,6 +509,19 @@ export const CUSTOM_PROPERTIES_ENTITIES = { values: ['enum1', 'enum2', 'enum3'], multiSelect: false, }, + enumWithDescriptionConfig: { + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + multiSelect: false, + }, dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Customproperties-part2.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Customproperties-part2.spec.ts index 48be7ecd4be1..c75d77638af9 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Customproperties-part2.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Customproperties-part2.spec.ts @@ -45,13 +45,46 @@ test.describe('Custom properties with custom property config', () => { enumConfig: entity.enumConfig, }); - await editCreatedProperty(page, propertyName); + await editCreatedProperty(page, propertyName, 'Enum'); await deleteCreatedProperty(page, propertyName); }); }); }); + test.describe( + 'Add update and delete Enum With Descriptions custom properties', + () => { + Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => { + const propertyName = `pwcustomproperty${entity.name}test${uuid()}`; + + test(`Add Enum With Descriptions custom property for ${entity.name}`, async ({ + page, + }) => { + test.slow(true); + + await settingClick(page, entity.entityApiType, true); + + await addCustomPropertiesForEntity({ + page, + propertyName, + customPropertyData: entity, + customType: 'Enum With Descriptions', + enumWithDescriptionConfig: entity.enumWithDescriptionConfig, + }); + + await editCreatedProperty( + page, + propertyName, + 'Enum With Descriptions' + ); + + await deleteCreatedProperty(page, propertyName); + }); + }); + } + ); + test.describe( 'Add update and delete Entity Reference custom properties', () => { @@ -73,7 +106,7 @@ test.describe('Custom properties with custom property config', () => { entityReferenceConfig: entity.entityReferenceConfig, }); - await editCreatedProperty(page, propertyName); + await editCreatedProperty(page, propertyName, 'Entity Reference'); await deleteCreatedProperty(page, propertyName); }); @@ -102,7 +135,11 @@ test.describe('Custom properties with custom property config', () => { entityReferenceConfig: entity.entityReferenceConfig, }); - await editCreatedProperty(page, propertyName); + await editCreatedProperty( + page, + propertyName, + 'Entity Reference List' + ); await deleteCreatedProperty(page, propertyName); }); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts index 3fc973a10645..0202119b438e 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts @@ -44,6 +44,7 @@ export enum CustomPropertyTypeByName { TIME_CP = 'time-cp', DATE_CP = 'date-cp', DATE_TIME_CP = 'dateTime-cp', + ENUM_WITH_DESCRIPTION = 'enumWithDescriptions', } export interface CustomProperty { @@ -122,6 +123,15 @@ export const setValueForProperty = async (data: { break; + case 'enumWithDescriptions': + await page.click('#enumWithDescriptionValues'); + await page.fill('#enumWithDescriptionValues', value, { force: true }); + await page.press('#enumWithDescriptionValues', 'Enter'); + await clickOutside(page); + await container.locator('[data-testid="inline-save-btn"]').click(); + + break; + case 'sqlQuery': await page.locator("pre[role='presentation']").last().click(); await page.keyboard.type(value); @@ -241,6 +251,18 @@ export const validateValueForProperty = async (data: { ); } else if (propertyType === 'sqlQuery') { await expect(container.locator('.CodeMirror-scroll')).toContainText(value); + } else if (propertyType === 'enumWithDescriptions') { + await expect( + container.locator('[data-testid="enum-with-description-table"]') + ).toBeVisible(); + + await expect( + container + .locator('[data-testid="enum-with-description-table"]') + .getByText(value, { + exact: true, + }) + ).toBeVisible(); } else if ( ![ 'entityReference', @@ -294,6 +316,11 @@ export const getPropertyValues = ( value: 'small', newValue: 'medium', }; + case 'enumWithDescriptions': + return { + value: 'enumWithDescription1', + newValue: 'enumWithDescription2', + }; case 'sqlQuery': return { value: 'Select * from table', @@ -420,6 +447,25 @@ export const createCustomPropertyForEntity = async ( }, } : {}), + ...(item.name === 'enumWithDescriptions' + ? { + customPropertyConfig: { + config: { + multiSelect: true, + values: [ + { + key: 'enumWithDescription1', + description: 'This is enumWithDescription1', + }, + { + key: 'enumWithDescription2', + description: 'This is enumWithDescription2', + }, + ], + }, + }, + } + : {}), ...(['entityReference', 'entityReferenceList'].includes(item.name) ? { customPropertyConfig: { @@ -488,12 +534,17 @@ export const addCustomPropertiesForEntity = async ({ enumConfig, formatConfig, entityReferenceConfig, + enumWithDescriptionConfig, }: { page: Page; propertyName: string; customPropertyData: { description: string }; customType: string; enumConfig?: { values: string[]; multiSelect: boolean }; + enumWithDescriptionConfig?: { + values: { key: string; description: string }[]; + multiSelect: boolean; + }; formatConfig?: string; entityReferenceConfig?: string[]; }) => { @@ -573,6 +624,27 @@ export const addCustomPropertiesForEntity = async ({ await page.click('#root\\/multiSelect'); } } + // Enum With Description configuration + if (customType === 'Enum With Descriptions' && enumWithDescriptionConfig) { + for await (const [ + index, + val, + ] of enumWithDescriptionConfig.values.entries()) { + await page.locator('[data-testid="add-enum-description-config"]').click(); + await page.locator(`#key-${index}`).fill(val.key); + await page.locator(descriptionBox).nth(index).fill(val.description); + } + await clickOutside(page); + + if (enumWithDescriptionConfig.multiSelect) { + await page.click('#root\\/multiSelect'); + } + + await page + .locator(descriptionBox) + .nth(2) + .fill(customPropertyData.description); + } // Entity reference configuration if ( @@ -600,7 +672,9 @@ export const addCustomPropertiesForEntity = async ({ } // Description - await page.fill(descriptionBox, customPropertyData.description); + if (customType !== 'Enum With Descriptions') { + await page.fill(descriptionBox, customPropertyData.description); + } const createPropertyPromise = page.waitForResponse( '/api/v1/metadata/types/name/*?fields=customProperties' @@ -635,10 +709,22 @@ export const editCreatedProperty = async ( ).toContainText('["enum1","enum2","enum3"]'); } + if (type === 'Enum With Descriptions') { + await expect( + page + .getByRole('row', { + name: `${propertyName} enumWithDescriptions enumWithDescription1`, + }) + .getByTestId('enum-with-description-config') + ).toBeVisible(); + } + await editButton.click(); - await page.locator(descriptionBox).fill(''); - await page.locator(descriptionBox).fill('This is new description'); + if (type !== 'Enum With Descriptions') { + await page.locator(descriptionBox).fill(''); + await page.locator(descriptionBox).fill('This is new description'); + } if (type === 'Enum') { await page.click('#root\\/customPropertyConfig'); @@ -646,6 +732,10 @@ export const editCreatedProperty = async ( await page.press('#root\\/customPropertyConfig', 'Enter'); await clickOutside(page); } + if (type === 'Enum With Descriptions') { + await page.locator(descriptionBox).nth(0).fill(''); + await page.locator(descriptionBox).nth(0).fill('This is new description'); + } if (ENTITY_REFERENCE_PROPERTIES.includes(type ?? '')) { await page.click('#root\\/customPropertyConfig'); @@ -678,6 +768,17 @@ export const editCreatedProperty = async ( ) ).toContainText('["enum1","enum2","enum3","updatedValue"]'); } + + if (type === 'Enum With Descriptions') { + await expect( + page + .getByRole('row', { + name: `${propertyName} enumWithDescriptions enumWithDescription1`, + }) + .getByTestId('enum-with-description-config') + ).toBeVisible(); + } + if (ENTITY_REFERENCE_PROPERTIES.includes(type ?? '')) { await expect( page.locator(