mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-19 12:50:20 +00:00
Minor: improve custom properties e2e test (#18861)
This commit is contained in:
parent
cbe32412b0
commit
811feea515
@ -447,79 +447,87 @@ export const createCustomPropertyForEntity = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const item of propertyList) {
|
for (const item of propertyList) {
|
||||||
|
const customPropertyName = `pwCustomProperty${uuid()}`;
|
||||||
|
const payload = {
|
||||||
|
name: customPropertyName,
|
||||||
|
description: customPropertyName,
|
||||||
|
propertyType: {
|
||||||
|
id: item.id ?? '',
|
||||||
|
type: 'type',
|
||||||
|
},
|
||||||
|
...(item.name === 'enum'
|
||||||
|
? {
|
||||||
|
customPropertyConfig: {
|
||||||
|
config: {
|
||||||
|
multiSelect: true,
|
||||||
|
values: ['small', 'medium', 'large'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...(['entityReference', 'entityReferenceList'].includes(item.name)
|
||||||
|
? {
|
||||||
|
customPropertyConfig: {
|
||||||
|
config: ['user', 'team'],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
|
||||||
|
...(item.name === 'time-cp'
|
||||||
|
? {
|
||||||
|
customPropertyConfig: {
|
||||||
|
config: 'HH:mm:ss',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
|
||||||
|
...(item.name === 'date-cp'
|
||||||
|
? {
|
||||||
|
customPropertyConfig: {
|
||||||
|
config: 'yyyy-MM-dd',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
|
||||||
|
...(item.name === 'dateTime-cp'
|
||||||
|
? {
|
||||||
|
customPropertyConfig: {
|
||||||
|
config: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...(item.name === 'table-cp'
|
||||||
|
? {
|
||||||
|
customPropertyConfig: {
|
||||||
|
config: {
|
||||||
|
columns: ['pw-column1', 'pw-column2'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
};
|
||||||
const customPropertyResponse = await apiContext.put(
|
const customPropertyResponse = await apiContext.put(
|
||||||
`/api/v1/metadata/types/${entitySchema.id}`,
|
`/api/v1/metadata/types/${entitySchema.id}`,
|
||||||
{
|
{
|
||||||
data: {
|
data: payload,
|
||||||
name: `pwCustomProperty${uuid()}`,
|
|
||||||
description: `pwCustomProperty${uuid()}`,
|
|
||||||
propertyType: {
|
|
||||||
id: item.id ?? '',
|
|
||||||
type: 'type',
|
|
||||||
},
|
|
||||||
...(item.name === 'enum'
|
|
||||||
? {
|
|
||||||
customPropertyConfig: {
|
|
||||||
config: {
|
|
||||||
multiSelect: true,
|
|
||||||
values: ['small', 'medium', 'large'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
...(['entityReference', 'entityReferenceList'].includes(item.name)
|
|
||||||
? {
|
|
||||||
customPropertyConfig: {
|
|
||||||
config: ['user', 'team'],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
|
|
||||||
...(item.name === 'time-cp'
|
|
||||||
? {
|
|
||||||
customPropertyConfig: {
|
|
||||||
config: 'HH:mm:ss',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
|
|
||||||
...(item.name === 'date-cp'
|
|
||||||
? {
|
|
||||||
customPropertyConfig: {
|
|
||||||
config: 'yyyy-MM-dd',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
|
|
||||||
...(item.name === 'dateTime-cp'
|
|
||||||
? {
|
|
||||||
customPropertyConfig: {
|
|
||||||
config: 'yyyy-MM-dd HH:mm:ss',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
...(item.name === 'table-cp'
|
|
||||||
? {
|
|
||||||
customPropertyConfig: {
|
|
||||||
config: {
|
|
||||||
columns: ['pw-column1', 'pw-column2'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const customProperty = await customPropertyResponse.json();
|
const customProperty = await customPropertyResponse.json();
|
||||||
|
|
||||||
// Process the custom properties
|
// Process the custom properties
|
||||||
customProperties = customProperty.customProperties.reduce(
|
const newProperties = customProperty.customProperties.reduce(
|
||||||
(
|
(
|
||||||
prev: Record<string, string>,
|
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 {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
@ -531,6 +539,8 @@ export const createCustomPropertyForEntity = async (
|
|||||||
},
|
},
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
customProperties = { ...customProperties, ...newProperties };
|
||||||
}
|
}
|
||||||
|
|
||||||
return { customProperties, cleanupUser };
|
return { customProperties, cleanupUser };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user