fix(terms): fix removing terms from schema field & add cypress tests to cover these flows (#4091)

This commit is contained in:
Gabe Lyons 2022-02-08 12:27:09 -08:00 committed by GitHub
parent f5a51f0a74
commit 306fe0b5ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 19 deletions

View File

@ -66,7 +66,7 @@ public class LabelUtils {
} }
removeTermIfExists(editableFieldInfo.getGlossaryTerms(), labelUrn); removeTermIfExists(editableFieldInfo.getGlossaryTerms(), labelUrn);
persistAspect(targetUrn, GLOSSARY_TERM_ASPECT_NAME, editableSchemaMetadata, actor, entityService); persistAspect(targetUrn, EDITABLE_SCHEMA_METADATA, editableSchemaMetadata, actor, entityService);
} }
} }

View File

@ -19,21 +19,23 @@ export default function useTagsAndTermsRenderer(
); );
return ( return (
<TagTermGroup <div data-testid={`schema-field-${record.fieldPath}-${options.showTags ? 'tags' : 'terms'}`}>
uneditableTags={options.showTags ? tags : null} <TagTermGroup
editableTags={options.showTags ? relevantEditableFieldInfo?.globalTags : null} uneditableTags={options.showTags ? tags : null}
uneditableGlossaryTerms={options.showTerms ? record.glossaryTerms : null} editableTags={options.showTags ? relevantEditableFieldInfo?.globalTags : null}
editableGlossaryTerms={options.showTerms ? relevantEditableFieldInfo?.glossaryTerms : null} uneditableGlossaryTerms={options.showTerms ? record.glossaryTerms : null}
canRemove editableGlossaryTerms={options.showTerms ? relevantEditableFieldInfo?.glossaryTerms : null}
buttonProps={{ size: 'small' }} canRemove
canAddTag={tagHoveredIndex === `${record.fieldPath}-${rowIndex}` && options.showTags} buttonProps={{ size: 'small' }}
canAddTerm={tagHoveredIndex === `${record.fieldPath}-${rowIndex}` && options.showTerms} canAddTag={tagHoveredIndex === `${record.fieldPath}-${rowIndex}` && options.showTags}
onOpenModal={() => setTagHoveredIndex(undefined)} canAddTerm={tagHoveredIndex === `${record.fieldPath}-${rowIndex}` && options.showTerms}
entityUrn={urn} onOpenModal={() => setTagHoveredIndex(undefined)}
entityType={EntityType.Dataset} entityUrn={urn}
entitySubresource={record.fieldPath} entityType={EntityType.Dataset}
refetch={refetch} entitySubresource={record.fieldPath}
/> refetch={refetch}
/>
</div>
); );
}; };
return tagAndTermRender; return tagAndTermRender;

View File

@ -236,7 +236,11 @@ export default function AddTagTermModal({
<Button onClick={onClose} type="text"> <Button onClick={onClose} type="text">
Cancel Cancel
</Button> </Button>
<Button onClick={onOk} disabled={selectedValue.length === 0 || disableAdd}> <Button
data-testid="add-tag-term-from-modal-btn"
onClick={onOk}
disabled={selectedValue.length === 0 || disableAdd}
>
Add Add
</Button> </Button>
</> </>

View File

@ -229,7 +229,7 @@ export default function TagTermGroup({
{...buttonProps} {...buttonProps}
> >
<PlusOutlined /> <PlusOutlined />
Add Tag <span>Add Tag</span>
</NoElementButton> </NoElementButton>
)} )}
{canAddTerm && {canAddTerm &&
@ -243,7 +243,7 @@ export default function TagTermGroup({
{...buttonProps} {...buttonProps}
> >
<PlusOutlined /> <PlusOutlined />
Add Term <span>Add Term</span>
</NoElementButton> </NoElementButton>
)} )}
{showAddModal && !!entityUrn && !!entityType && ( {showAddModal && !!entityUrn && !!entityType && (

View File

@ -37,4 +37,49 @@ describe('mutations', () => {
cy.deleteUrn('urn:li:tag:CypressTestAddTag') cy.deleteUrn('urn:li:tag:CypressTestAddTag')
}); });
it('can add and remove terms from a dataset', () => {
cy.login();
cy.visit('/dataset/urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)');
cy.contains('cypress_logging_events');
cy.contains('Add Term').click();
cy.focused().type('CypressTerm');
cy.get('.ant-select-item-option-content').within(() => cy.contains('CypressNode.CypressTerm').click({force: true}));
cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({force: true});
cy.get('[data-testid="add-tag-term-from-modal-btn"]').should('not.exist');
cy.contains('CypressTerm');
cy.get('a[href="/glossary/urn:li:glossaryTerm:CypressNode.CypressTerm"]').within(() => cy.get('span[aria-label=close]').click());
cy.contains('Yes').click();
cy.contains('CypressTerm').should('not.exist');
});
it('can add and remove terms from a dataset field', () => {
cy.login();
// make space for the glossary term column
cy.viewport(1300, 800)
cy.visit('/dataset/urn:li:dataset:(urn:li:dataPlatform:hive,cypress_logging_events,PROD)');
cy.get('[data-testid="schema-field-event_name-terms"]').trigger('mouseover', {force: true});
cy.get('[data-testid="schema-field-event_name-terms"]').within(() => cy.contains('Add Term').click())
cy.focused().type('CypressTerm');
cy.get('.ant-select-item-option-content').within(() => cy.contains('CypressNode.CypressTerm').click({force: true}));
cy.get('[data-testid="add-tag-term-from-modal-btn"]').click({force: true});
cy.get('[data-testid="add-tag-term-from-modal-btn"]').should('not.exist');
cy.contains('CypressTerm');
cy.get('a[href="/glossary/urn:li:glossaryTerm:CypressNode.CypressTerm"]').within(() => cy.get('span[aria-label=close]').click());
cy.contains('Yes').click();
cy.contains('CypressTerm').should('not.exist');
});
}) })