Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
antv committed Sep 4, 2024
1 parent 704ffd4 commit 60f14e1
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 2 deletions.
48 changes: 48 additions & 0 deletions packages/g6/__tests__/snapshots/elements/combo/combo-zIndex.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 54 additions & 2 deletions packages/g6/__tests__/unit/elements/combo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Graph } from '@/src';
import type { Graph } from '@/src';
import { elementCombo } from '@@/demos';
import { createDemoGraph } from '@@/utils';
import { createDemoGraph, createGraph } from '@@/utils';

describe('combo', () => {
let graph: Graph;
Expand Down Expand Up @@ -97,3 +97,55 @@ describe('combo', () => {
await expect(graph).toMatchSnapshot(__filename, 'circle-marker-custom');
});
});

describe('combo drag zIndex', () => {
it('drag combo will bring related edges forward', async () => {
const graph = createGraph({
data: {
nodes: [
{ id: 'node-1', combo: 'combo-2', style: { x: 120, y: 100 } },
{ id: 'node-2', combo: 'combo-1', style: { x: 300, y: 200 } },
{ id: 'node-3', combo: 'combo-1', style: { x: 200, y: 300 } },
],
edges: [
{ id: 'edge-1', source: 'node-1', target: 'node-2' },
{ id: 'edge-2', source: 'node-2', target: 'node-3' },
],
combos: [
{
id: 'combo-1',
type: 'rect',
combo: 'combo-2',
},
{
id: 'combo-2',
},
],
},
edge: {
style: {
stroke: 'red',
},
},
combo: {
style: {
lineWidth: 1,
fillOpacity: 1,
stroke: 'black',
},
},
});

await graph.render();

await expect(graph).toMatchSnapshot(__filename, 'combo-zIndex');

await graph.frontElement('combo-1');

await expect(graph).toMatchSnapshot(__filename, 'combo-zIndex');

await graph.frontElement('combo-2');

await expect(graph).toMatchSnapshot(__filename, 'combo-zIndex');
});
});

0 comments on commit 60f14e1

Please sign in to comment.