Minor: improve custom properties e2e test (#18861)

This commit is contained in:
Sachin Chaurasiya 2024-12-02 09:22:22 +05:30 committed by GitHub
parent cbe32412b0
commit 811feea515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -447,12 +447,10 @@ export const createCustomPropertyForEntity = async (
};
for (const item of propertyList) {
const customPropertyResponse = await apiContext.put(
`/api/v1/metadata/types/${entitySchema.id}`,
{
data: {
name: `pwCustomProperty${uuid()}`,
description: `pwCustomProperty${uuid()}`,
const customPropertyName = `pwCustomProperty${uuid()}`;
const payload = {
name: customPropertyName,
description: customPropertyName,
propertyType: {
id: item.id ?? '',
type: 'type',
@ -507,19 +505,29 @@ export const createCustomPropertyForEntity = async (
},
}
: {}),
},
};
const customPropertyResponse = await apiContext.put(
`/api/v1/metadata/types/${entitySchema.id}`,
{
data: payload,
}
);
const customProperty = await customPropertyResponse.json();
// Process the custom properties
customProperties = customProperty.customProperties.reduce(
const newProperties = customProperty.customProperties.reduce(
(
prev: Record<string, string>,
curr: Record<string, Record<string, string>>
curr: Record<string, Record<string, string> | string>
) => {
const propertyTypeName = curr.propertyType.name;
// only process the custom properties which are created via payload
if (curr.name !== customPropertyName) {
return prev;
}
const propertyTypeName = (curr.propertyType as Record<string, string>)
.name;
return {
...prev,
@ -531,6 +539,8 @@ export const createCustomPropertyForEntity = async (
},
{}
);
customProperties = { ...customProperties, ...newProperties };
}
return { customProperties, cleanupUser };