Skip to content

Commit

Permalink
fix: update demo and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yvonneyx committed Aug 22, 2024
1 parent 391ce2f commit 6b5f306
Show file tree
Hide file tree
Showing 15 changed files with 11,033 additions and 4,421 deletions.
508 changes: 254 additions & 254 deletions packages/g6/__tests__/dataset/relations.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions packages/g6/__tests__/demos/plugin-edge-filter-lens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ export const pluginEdgeFilterLens: TestCase = async (context) => {
...context,
data,
node: {
style: { size: 22 },
style: { size: 16 },
palette: {
field: (datum) => Math.floor((datum.style?.y as number) / 50),
field: (datum) => Math.floor(Number(datum.style?.y) / 60),
},
},
edge: {
style: {
label: false,
labelText: (d) => d.value?.toString(),
labelText: (d) => d.data!.value?.toString(),
stroke: '#ccc',
},
},
plugins: [
{
key: 'edge-filter-lens',
type: 'edge-filter-lens',
// trigger: 'drag',
},
],
autoFit: 'view',
Expand Down
1,172 changes: 586 additions & 586 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,174 changes: 587 additions & 587 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/move-lens-click-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,194 changes: 597 additions & 597 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/move-lens-click-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,194 changes: 597 additions & 597 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/move-lens-drag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,210 changes: 2,210 additions & 0 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/node-type-either.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,196 changes: 2,196 additions & 0 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/node-type-source.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,196 changes: 2,196 additions & 0 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/node-type-target.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,194 changes: 597 additions & 597 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/scale-larger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,194 changes: 597 additions & 597 deletions packages/g6/__tests__/snapshots/plugins/edge-filter-lens/scale-smaller.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions packages/g6/__tests__/unit/plugins/edge-filter-lens.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { pluginEdgeFilterLens } from '@@/demos';
import type { Canvas } from '@antv/g';
import { CommonEvent, Graph } from '@antv/g6';
import { createDemoGraph, dispatchCanvasEvent } from '../../utils';

describe('edge-filter-lens', () => {
let graph: Graph;
let canvas: Canvas;

beforeAll(async () => {
graph = await createDemoGraph(pluginEdgeFilterLens, { animation: false });
canvas = graph.getCanvas().getLayer();
});

afterAll(() => {
Expand Down Expand Up @@ -63,4 +60,18 @@ describe('edge-filter-lens', () => {

await expect(graph).toMatchSnapshot(__filename, 'scale-smaller');
});

it('show edge when only its source/target node in lens', async () => {
graph.updatePlugin({ key: 'edge-filter-lens', trigger: 'click', nodeType: 'source' });
dispatchCanvasEvent(graph, CommonEvent.CLICK, { canvas: { x: 200, y: 200 } });
await expect(graph).toMatchSnapshot(__filename, 'node-type-source');

graph.updatePlugin({ key: 'edge-filter-lens', trigger: 'click', nodeType: 'target' });
dispatchCanvasEvent(graph, CommonEvent.CLICK, { canvas: { x: 200, y: 200 } });
await expect(graph).toMatchSnapshot(__filename, 'node-type-target');

graph.updatePlugin({ key: 'edge-filter-lens', trigger: 'click', nodeType: 'either' });
dispatchCanvasEvent(graph, CommonEvent.CLICK, { canvas: { x: 200, y: 200 } });
await expect(graph).toMatchSnapshot(__filename, 'node-type-either');
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Graph } from '@antv/g6';

fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/relations.json')
fetch('https://assets.antv.antgroup.com/g6/relations.json')
.then((res) => res.json())
.then((data) => {
const graph = new Graph({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"zh": "边过滤镜",
"en": "Edge Filter Lens"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*9o1lRbfc3YMAAAAAAAAAAAAADmJ7AQ/original"
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*62FuSY-LFEIAAAAAAAAAAAAADmJ7AQ/original"
}
]
}

0 comments on commit 6b5f306

Please sign in to comment.