mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-02 11:49:23 +00:00
fix(terms): fix removing terms from schema field & add cypress tests to cover these flows (#4091)
This commit is contained in:
parent
f5a51f0a74
commit
306fe0b5ff
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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>
|
||||
</>
|
||||
|
||||
@ -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 && (
|
||||
|
||||
@ -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');
|
||||
});
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user