sonika-shah 1b029d2bf2
Add new ‘enumWithDescriptions’ Custom Property to allow adding Enum Keys with Description (#17777)
* Add new ‘metaEnum’ Custom Property to allow adding Enum Keys with Description

* replace JsonNodeFactory method with JsonUtils

* rename property from metaEnum to enumWithDescriptions, and other method optimizations

* ui: add support for creating enumWithDescription property

* minor locale changes

* ui: add edit support for created enumWithDescription property

* Refactor enum description field layout in AddCustomProperty and EditCustomPropertyModal

* add support for adding values to enumWithDescription custom property type

* Refactor custom property input IDs in AddCustomProperty and EditCustomPropertyModal components

* Refactor custom property table rendering logic and UI components

* Refactor custom property table rendering logic and UI components

* Refactor custom property table rendering logic and UI components

* add basic card layout

* Refactor CustomPropertyTable component to improve UI and functionality

* update playwright test part 1

* Refactor PropertyValue component to conditionally render right panel styles

* fix: entity reference property update

* Refactor CustomPropertyTable component to conditionally render right panel styles

* fix: flaky test

* Refactor CustomPropertyTable test to use updated test IDs and remove unnecessary code

* fix flaky test

* improve the playwright test

* add more test

---------

Co-authored-by: Sachin Chaurasiya <sachinchaurasiyachotey87@gmail.com>
Co-authored-by: Sriharsha Chintalapani <harshach@users.noreply.github.com>
2024-09-29 00:45:46 +05:30

224 lines
6.8 KiB
TypeScript

/*
* Copyright 2024 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 test from '@playwright/test';
import { CUSTOM_PROPERTIES_ENTITIES } from '../../constant/customProperty';
import { redirectToHomePage, uuid } from '../../utils/common';
import {
addCustomPropertiesForEntity,
deleteCreatedProperty,
editCreatedProperty,
} from '../../utils/customProperty';
import { settingClick } from '../../utils/sidebar';
// use the admin user to login
test.use({ storageState: 'playwright/.auth/admin.json' });
test.describe('Custom properties with custom property config', () => {
test.beforeEach('Visit Home Page', async ({ page }) => {
await redirectToHomePage(page);
});
test.describe('Add update and delete Enum custom properties', () => {
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
test(`Add Enum custom property for ${entity.name}`, async ({ page }) => {
test.slow(true);
await settingClick(page, entity.entityApiType, true);
await addCustomPropertiesForEntity({
page,
propertyName,
customPropertyData: entity,
customType: 'Enum',
enumConfig: entity.enumConfig,
});
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',
() => {
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
test(`Add Entity Reference custom property for ${entity.name}`, async ({
page,
}) => {
test.slow(true);
await settingClick(page, entity.entityApiType, true);
await addCustomPropertiesForEntity({
page,
propertyName,
customPropertyData: entity,
customType: 'Entity Reference',
entityReferenceConfig: entity.entityReferenceConfig,
});
await editCreatedProperty(page, propertyName, 'Entity Reference');
await deleteCreatedProperty(page, propertyName);
});
});
}
);
test.describe(
'Add update and delete Entity Reference List custom properties',
() => {
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
test(`Add Entity Reference list custom property for ${entity.name}`, async ({
page,
}) => {
test.slow(true);
await settingClick(page, entity.entityApiType, true);
await addCustomPropertiesForEntity({
page,
propertyName,
customPropertyData: entity,
customType: 'Entity Reference List',
entityReferenceConfig: entity.entityReferenceConfig,
});
await editCreatedProperty(
page,
propertyName,
'Entity Reference List'
);
await deleteCreatedProperty(page, propertyName);
});
});
}
);
test.describe('Add update and delete Date custom properties', () => {
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
test(`Add Date custom property for ${entity.name}`, async ({ page }) => {
test.slow(true);
await settingClick(page, entity.entityApiType, true);
await addCustomPropertiesForEntity({
page,
propertyName,
customPropertyData: entity,
customType: 'Date',
formatConfig: entity.dateFormatConfig,
});
await editCreatedProperty(page, propertyName);
await deleteCreatedProperty(page, propertyName);
});
});
});
test.describe('Add update and delete Time custom properties', () => {
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
test(`Add Time custom property for ${entity.name}`, async ({ page }) => {
test.slow(true);
await settingClick(page, entity.entityApiType, true);
await addCustomPropertiesForEntity({
page,
propertyName,
customPropertyData: entity,
customType: 'Time',
formatConfig: entity.timeFormatConfig,
});
await editCreatedProperty(page, propertyName);
await deleteCreatedProperty(page, propertyName);
});
});
});
test.describe('Add update and delete DateTime custom properties', () => {
Object.values(CUSTOM_PROPERTIES_ENTITIES).forEach(async (entity) => {
const propertyName = `pwcustomproperty${entity.name}test${uuid()}`;
test(`Add DateTime custom property for ${entity.name}`, async ({
page,
}) => {
test.slow(true);
await settingClick(page, entity.entityApiType, true);
await addCustomPropertiesForEntity({
page,
propertyName,
customPropertyData: entity,
customType: 'Date Time',
formatConfig: entity.dateTimeFormatConfig,
});
await editCreatedProperty(page, propertyName);
await deleteCreatedProperty(page, propertyName);
});
});
});
});