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);
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 (
<TagTermGroup
uneditableTags={options.showTags ? tags : null}
editableTags={options.showTags ? relevantEditableFieldInfo?.globalTags : null}
uneditableGlossaryTerms={options.showTerms ? record.glossaryTerms : null}
editableGlossaryTerms={options.showTerms ? relevantEditableFieldInfo?.glossaryTerms : null}
canRemove
buttonProps={{ size: 'small' }}
canAddTag={tagHoveredIndex === `${record.fieldPath}-${rowIndex}` && options.showTags}
canAddTerm={tagHoveredIndex === `${record.fieldPath}-${rowIndex}` && options.showTerms}
onOpenModal={() => setTagHoveredIndex(undefined)}
entityUrn={urn}
entityType={EntityType.Dataset}
entitySubresource={record.fieldPath}
refetch={refetch}
/>
<div data-testid={`schema-field-${record.fieldPath}-${options.showTags ? 'tags' : 'terms'}`}>
<TagTermGroup
uneditableTags={options.showTags ? tags : null}
editableTags={options.showTags ? relevantEditableFieldInfo?.globalTags : null}
uneditableGlossaryTerms={options.showTerms ? record.glossaryTerms : null}
editableGlossaryTerms={options.showTerms ? relevantEditableFieldInfo?.glossaryTerms : null}
canRemove
buttonProps={{ size: 'small' }}
canAddTag={tagHoveredIndex === `${record.fieldPath}-${rowIndex}` && options.showTags}
canAddTerm={tagHoveredIndex === `${record.fieldPath}-${rowIndex}` && options.showTerms}
onOpenModal={() => setTagHoveredIndex(undefined)}
entityUrn={urn}
entityType={EntityType.Dataset}
entitySubresource={record.fieldPath}
refetch={refetch}
/>
</div>
);
};
return tagAndTermRender;

View File

@ -236,7 +236,11 @@ export default function AddTagTermModal({
<Button onClick={onClose} type="text">
Cancel
</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
</Button>
</>

View File

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

View File

@ -37,4 +37,49 @@ describe('mutations', () => {
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');
});
})