mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-19 14:24:01 +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);
|
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 (
|
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;
|
||||||
|
|||||||
@ -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>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -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 && (
|
||||||
|
|||||||
@ -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');
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user