Skip to content

Commit

Permalink
Fix#16491 - fix lineage edge description update (#16538)
Browse files Browse the repository at this point in the history
* fix lineage edge description update

* fix tests
  • Loading branch information
karanh37 authored Jun 5, 2024
1 parent d3123c4 commit dff0aa8
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,35 @@ const applyPipelineFromModal = (fromNode, toNode, pipelineData) => {
verifyResponseStatusCode('@lineageApi', 200);
};

const editPipelineEdgeDescription = (
fromNode,
toNode,
pipelineData,
description
) => {
cy.get(
`[data-testid="pipeline-label-${fromNode.fqn}-${toNode.fqn}"]`
).click();
cy.get('.edge-info-drawer').should('be.visible');
cy.get('.edge-info-drawer [data-testid="Edge"] a').contains(
pipelineData.name
);

interceptURL('PUT', `/api/v1/lineage`, 'updateLineage');
cy.get('.edge-info-drawer [data-testid="edit-description"]').click();

cy.get('.toastui-editor-md-container > .toastui-editor > .ProseMirror')
.click()
.clear()
.type(description);

cy.get('[data-testid="save"]').click();
verifyResponseStatusCode('@updateLineage', 200);
cy.get(
'.edge-info-drawer [data-testid="asset-description-container"] [data-testid="viewer-container"]'
).should('contain', description);
};

const verifyPipelineDataInDrawer = (
fromNode,
toNode,
Expand Down Expand Up @@ -231,6 +260,29 @@ const addColumnLineage = (fromNode, toNode, exitEditMode = true) => {
);
};

const removeColumnLineage = (fromNode, toNode) => {
interceptURL('PUT', '/api/v1/lineage', 'lineageApi');
cy.get(
`[data-testid="column-edge-${btoa(fromNode.columns[0])}-${btoa(
toNode.columns[0]
)}"]`
).click({ force: true });
cy.get('[data-testid="delete-button"]').click({ force: true });
cy.get(
'[data-testid="delete-edge-confirmation-modal"] .ant-btn-primary'
).click();

verifyResponseStatusCode('@lineageApi', 200);

cy.get('[data-testid="edit-lineage"]').click();

cy.get(
`[data-testid="column-edge-${btoa(fromNode.columns[0])}-${btoa(
toNode.columns[0]
)}"]`
).should('not.exist');
};

describe('Lineage verification', { tags: 'DataAssets' }, () => {
beforeEach(() => {
cy.login();
Expand Down Expand Up @@ -323,6 +375,14 @@ describe('Lineage verification', { tags: 'DataAssets' }, () => {
PIPELINE_ITEMS[0],
true
);

editPipelineEdgeDescription(
sourceEntity,
targetEntity,
PIPELINE_ITEMS[0],
'Test Description'
);

cy.get('[data-testid="edit-lineage"]').click();
deleteNode(targetEntity);
});
Expand All @@ -336,6 +396,10 @@ describe('Lineage verification', { tags: 'DataAssets' }, () => {
activateColumnLayer();
// Add column lineage
addColumnLineage(sourceEntity, targetEntity);

cy.get('[data-testid="edit-lineage"]').click();
removeColumnLineage(sourceEntity, targetEntity);

cy.get('[data-testid="edit-lineage"]').click();
deleteNode(targetEntity);
cy.goToHomePage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Test EntityLineageUtils utility', () => {
sqlQuery: 'SELECT * FROM table',
columns: ['column1', 'column2'],
description: 'This is a test',
pipeline: 'Test Pipeline',
pipeline: undefined,
source: 'Test Source',
},
},
Expand All @@ -84,7 +84,7 @@ describe('Test EntityLineageUtils utility', () => {
sqlQuery: 'SELECT * FROM table',
columnsLineage: ['column1', 'column2'],
description: 'This is a test',
pipeline: 'Test Pipeline',
pipeline: undefined,
source: 'Test Source',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import { EntityReference } from '../generated/type/entityReference';
import { TagSource } from '../generated/type/tagLabel';
import { addLineage, deleteLineageEdge } from '../rest/miscAPI';
import { getPartialNameFromTableFQN } from './CommonUtils';
import { getEntityName } from './EntityUtils';
import { getEntityName, getEntityReferenceFromEntity } from './EntityUtils';
import Fqn from './Fqn';
import { jsonToCSV } from './StringsUtils';
import { showErrorToast } from './ToastUtils';
Expand Down Expand Up @@ -792,13 +792,14 @@ export const getColumnLineageData = (
data: Edge
) => {
const columnsLineage = columnsData?.reduce((col, curr) => {
if (curr.toColumn === data.data?.targetHandle) {
const sourceHandle = decodeLineageHandles(data.data?.sourceHandle);
const targetHandle = decodeLineageHandles(data.data?.targetHandle);

if (curr.toColumn === targetHandle) {
const newCol = {
...curr,
fromColumns:
curr.fromColumns?.filter(
(column) => column !== data.data?.sourceHandle
) ?? [],
curr.fromColumns?.filter((column) => column !== sourceHandle) ?? [],
};
if (newCol.fromColumns?.length) {
return [...col, newCol];
Expand Down Expand Up @@ -871,13 +872,19 @@ export const getLineageDetailsObject = (edge: Edge): LineageDetails => {
description = '',
pipeline,
source,
pipelineEntityType,
} = edge.data?.edge || {};

return {
sqlQuery,
columnsLineage: columns,
description,
pipeline,
pipeline: pipeline
? getEntityReferenceFromEntity(
pipeline,
pipelineEntityType ?? EntityType.PIPELINE
)
: undefined,
source,
};
};
Expand Down

0 comments on commit dff0aa8

Please sign in to comment.