Skip to content

Commit

Permalink
test: add test case, update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
antv committed Nov 11, 2024
1 parent 624dc79 commit 52c7f4c
Show file tree
Hide file tree
Showing 48 changed files with 398 additions and 334 deletions.
52 changes: 52 additions & 0 deletions packages/g6/__tests__/bugs/model-add-edge-in-combo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { createGraph } from '@@/utils';

describe('add edge in combo', () => {
it('add edge in combo without zIndex', async () => {
const graph = createGraph({
data: {
nodes: [
{ id: 'node-1', combo: 'combo-1', style: { x: 100, y: 100 } },
{ id: 'node-2', combo: 'combo-1', style: { x: 200, y: 200 } },
],
combos: [{ id: 'combo-1' }],
},
});

await graph.draw();

graph.addEdgeData([{ id: 'edge', source: 'node-1', target: 'node-2' }]);
await graph.draw();

expect(graph.getEdgeData('edge').style?.zIndex).toBe(undefined);
// @ts-expect-error skip the type check
expect(graph.context.element?.getElement('edge')?.style.zIndex).toBe(1);
});

it('add edge in combo with zIndex', async () => {
const graph = createGraph({
data: {
nodes: [
{ id: 'node-1', combo: 'combo-1', style: { x: 100, y: 100 } },
{ id: 'node-2', combo: 'combo-1', style: { x: 200, y: 200 } },
{ id: 'node-3', style: { x: 300, y: 300, zIndex: 5 } },
],
combos: [{ id: 'combo-1' }],
},
});

await graph.draw();

expect(graph.getComboData('combo-1').style?.zIndex).toBe(undefined);

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

expect(graph.getComboData('combo-1').style?.zIndex).toBe(5 + 1);

graph.addEdgeData([{ id: 'edge', source: 'node-1', target: 'node-2' }]);
await graph.draw();

expect(graph.getEdgeData('edge').style?.zIndex).toBe(undefined);
// @ts-expect-error skip the type check
expect(graph.context.element?.getElement('edge')?.style.zIndex).toBe(5 + 1 + 1);
});
});
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 52c7f4c

Please sign in to comment.