Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lineage): fixing lineage layout bugs + adding additional test case #2337

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions datahub-web-react/src/Mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,26 @@ export const dataset6 = {
urn: 'urn:li:dataset:6',
};

export const dataset7 = {
...dataset3,
name: 'Seventh Test Dataset',
urn: 'urn:li:dataset:7',
};

export const dataset3WithLineage = {
...dataset3,
upstreamLineage: {
upstreams: [
{
created: {
time: 0,
},
lastModified: {
time: 0,
},
type: DatasetLineageType.Transformed,
dataset: dataset7,
},
{
created: {
time: 0,
Expand Down Expand Up @@ -326,6 +342,16 @@ export const dataset5WithLineage = {
},
downstreamLineage: {
downstreams: [
{
created: {
time: 0,
},
lastModified: {
time: 0,
},
type: DatasetLineageType.Transformed,
dataset: dataset7,
},
{
created: {
time: 0,
Expand Down Expand Up @@ -382,6 +408,38 @@ export const dataset6WithLineage = {
},
};

export const dataset7WithLineage = {
...dataset7,
upstreamLineage: {
upstreams: [
{
created: {
time: 0,
},
lastModified: {
time: 0,
},
type: DatasetLineageType.Transformed,
dataset: dataset5,
},
],
},
downstreamLineage: {
downstreams: [
{
created: {
time: 0,
},
lastModified: {
time: 0,
},
type: DatasetLineageType.Transformed,
dataset: dataset3,
},
],
},
};

const sampleTag = {
urn: 'urn:li:tag:abc-sample-tag',
name: 'abc-sample-tag',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import React from 'react';
import { Tree, hierarchy } from '@vx/hierarchy';
import { render } from '@testing-library/react';

import { dataset3WithLineage, dataset4WithLineage, dataset5WithLineage, dataset6WithLineage } from '../../../Mocks';
import {
dataset3WithLineage,
dataset4WithLineage,
dataset5WithLineage,
dataset6WithLineage,
dataset7WithLineage,
} from '../../../Mocks';
import constructTree from '../utils/constructTree';
import extendAsyncEntities from '../utils/extendAsyncEntities';
import adjustVXTreeLayout from '../utils/adjustVXTreeLayout';
Expand Down Expand Up @@ -35,6 +41,47 @@ describe('adjustVXTreeLayout', () => {
expect(adjustedTree.nodesToRender[1].x).not.toEqual(adjustedTree.nodesToRender[3].x);
expect(adjustedTree.nodesToRender[0].x).not.toEqual(adjustedTree.nodesToRender[3].x);

expect(adjustedTree.nodesToRender.length).toEqual(5);

return <div />;
}}
</Tree>,
);
});

it('handles multiple instances of lineage jumping over layers while upstream', () => {
const fetchedEntities = [
{ entity: dataset4WithLineage, direction: Direction.Upstream, fullyFetched: true },
{ entity: dataset5WithLineage, direction: Direction.Upstream, fullyFetched: true },
{ entity: dataset6WithLineage, direction: Direction.Upstream, fullyFetched: true },
{ entity: dataset7WithLineage, direction: Direction.Upstream, fullyFetched: true },
];
const mockFetchedEntities = fetchedEntities.reduce(
(acc, entry) => extendAsyncEntities(acc, entry.entity, entry.fullyFetched),
{} as FetchedEntities,
);

const upstreamData = hierarchy(constructTree(dataset3WithLineage, mockFetchedEntities, Direction.Upstream));

render(
<Tree<NodeData> root={upstreamData} size={[1000, 1000]}>
{(tree) => {
const adjustedTree = adjustVXTreeLayout({ tree, direction: Direction.Upstream });

expect(adjustedTree.nodesToRender[5].x).toEqual(adjustedTree.nodesToRender[6].x);
expect(adjustedTree.nodesToRender[5].y).toEqual(adjustedTree.nodesToRender[6].y);
expect(adjustedTree.nodesToRender[5].data.name).toEqual(adjustedTree.nodesToRender[6].data.name);

expect(adjustedTree.nodesToRender[5].x).toEqual(adjustedTree.nodesToRender[3].x);
expect(adjustedTree.nodesToRender[5].y).toEqual(adjustedTree.nodesToRender[3].y);
expect(adjustedTree.nodesToRender[5].data.name).toEqual(adjustedTree.nodesToRender[3].data.name);

expect(adjustedTree.nodesToRender.length).toEqual(7);

adjustedTree.nodesToRender.forEach((node) => {
expect(node.y).toBeLessThanOrEqual(0);
});

return <div />;
}}
</Tree>,
Expand Down
Loading