test: add cypress tests for entity ref and entity ref list custom properties (#16324)

This commit is contained in:
Sachin Chaurasiya 2024-05-17 17:22:42 +05:30 committed by GitHub
parent cfe86267ee
commit 92cea45c00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 47 additions and 7 deletions

View File

@ -40,7 +40,8 @@ export enum CustomPropertyTypeByName {
ENUM = 'enum', ENUM = 'enum',
SQL_QUERY = 'sqlQuery', SQL_QUERY = 'sqlQuery',
TIMESTAMP = 'timestamp', TIMESTAMP = 'timestamp',
// TIME_INTERVAL = 'timeInterval', ENTITY_REFERENCE = 'entityReference',
ENTITY_REFERENCE_LIST = 'entityReferenceList',
} }
export interface CustomProperty { export interface CustomProperty {
@ -108,11 +109,17 @@ export const getPropertyValues = (type: string) => {
value: '1710831125922', value: '1710831125922',
newValue: '1710831125923', newValue: '1710831125923',
}; };
// case 'timeInterval': case 'entityReference':
// return { return {
// value: '1710831125922,1710831125923', value: 'Aaron Johnson',
// newValue: '1710831125923,1710831125924', newValue: 'Aaron Singh',
// }; };
case 'entityReferenceList':
return {
value: 'Aaron Johnson,Organization',
newValue: 'Aaron Warren',
};
default: default:
return { return {
@ -245,6 +252,20 @@ export const setValueForProperty = (
break; break;
case 'entityReference':
case 'entityReferenceList': {
const refValues = value.split(',');
refValues.forEach((val) => {
cy.get('#entityReference').clear().type(`${val}`);
cy.get(`[data-testid="${val}"]`).click();
});
cy.get('[data-testid="inline-save-btn"]').click();
break;
}
default: default:
break; break;
} }
@ -259,6 +280,10 @@ export const setValueForProperty = (
cy.get('[data-testid="time-interval-value"]').should('contain', endValue); cy.get('[data-testid="time-interval-value"]').should('contain', endValue);
} else if (propertyType === 'sqlQuery') { } else if (propertyType === 'sqlQuery') {
cy.get('.CodeMirror-scroll').should('contain', value); cy.get('.CodeMirror-scroll').should('contain', value);
} else if (
['entityReference', 'entityReferenceList'].includes(propertyType)
) {
// do nothing
} else { } else {
cy.get(`[data-row-key="${propertyName}"]`).should( cy.get(`[data-row-key="${propertyName}"]`).should(
'contain', 'contain',
@ -287,6 +312,10 @@ export const validateValueForProperty = (
cy.get('[data-testid="time-interval-value"]').should('contain', endValue); cy.get('[data-testid="time-interval-value"]').should('contain', endValue);
} else if (propertyType === 'sqlQuery') { } else if (propertyType === 'sqlQuery') {
cy.get('.CodeMirror-scroll').should('contain', value); cy.get('.CodeMirror-scroll').should('contain', value);
} else if (
['entityReference', 'entityReferenceList'].includes(propertyType)
) {
// do nothing
} else { } else {
cy.get(`[data-row-key="${propertyName}"]`).should( cy.get(`[data-row-key="${propertyName}"]`).should(
'contain', 'contain',
@ -574,6 +603,15 @@ export const createCustomPropertyForEntity = (prop: string) => {
}, },
} }
: {}), : {}),
...(['entityReference', 'entityReferenceList'].includes(
item.name
)
? {
customPropertyConfig: {
config: ['user', 'team'],
},
}
: {}),
}, },
}) })
.then(({ body }) => { .then(({ body }) => {

View File

@ -144,7 +144,9 @@ const DataAssetAsyncSelectList: FC<DataAssetAsyncSelectListProps> = ({
type="circle" type="circle"
width="24" width="24"
/> />
<span className="m-l-xs">{getEntityName(option)}</span> <span className="m-l-xs" data-testid={getEntityName(option)}>
{getEntityName(option)}
</span>
</Space> </Space>
); );
} else { } else {