2024-05-17 16:32:09 +03:00
|
|
|
import { expect, test, type Page } from '@playwright/test'
|
2024-01-31 16:42:36 +03:00
|
|
|
import * as actions from './actions'
|
2024-02-06 19:15:00 +03:00
|
|
|
import { edgesFromNodeWithBinding, edgesToNodeWithBinding } from './locate'
|
2024-01-31 16:42:36 +03:00
|
|
|
|
2024-02-02 12:22:18 +03:00
|
|
|
// For each outgoing edge we expect two elements: an element for io and an element for the rendered edge itself.
|
|
|
|
const EDGE_PARTS = 2
|
2024-02-06 19:15:00 +03:00
|
|
|
// For a split edge we expect an extra element for the split rendering.
|
|
|
|
const SPLIT_EDGE_PARTS = EDGE_PARTS + 1
|
2024-02-02 12:22:18 +03:00
|
|
|
|
2024-01-31 16:42:36 +03:00
|
|
|
test('Existence of edges between nodes', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
|
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'aggregated')).toHaveCount(0)
|
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'filtered')).toHaveCount(0)
|
2024-04-24 14:40:42 +03:00
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'data')).toHaveCount(4 * EDGE_PARTS)
|
2024-01-31 16:42:36 +03:00
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'list')).toHaveCount(0)
|
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'final')).toHaveCount(0)
|
2024-03-25 19:05:20 +03:00
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'selected')).toHaveCount(0)
|
2024-02-02 12:22:18 +03:00
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'prod')).toHaveCount(EDGE_PARTS)
|
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'sum')).toHaveCount(EDGE_PARTS)
|
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'ten')).toHaveCount(EDGE_PARTS)
|
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'five')).toHaveCount(EDGE_PARTS)
|
2024-01-31 16:42:36 +03:00
|
|
|
|
2024-03-25 19:05:20 +03:00
|
|
|
await expect(await edgesToNodeWithBinding(page, 'selected')).toHaveCount(EDGE_PARTS)
|
2024-02-02 12:22:18 +03:00
|
|
|
await expect(await edgesToNodeWithBinding(page, 'aggregated')).toHaveCount(EDGE_PARTS)
|
|
|
|
await expect(await edgesToNodeWithBinding(page, 'filtered')).toHaveCount(EDGE_PARTS)
|
2024-01-31 16:42:36 +03:00
|
|
|
await expect(await edgesToNodeWithBinding(page, 'data')).toHaveCount(0)
|
|
|
|
await expect(await edgesToNodeWithBinding(page, 'list')).toHaveCount(0)
|
2024-02-02 12:22:18 +03:00
|
|
|
await expect(await edgesToNodeWithBinding(page, 'final')).toHaveCount(EDGE_PARTS)
|
|
|
|
await expect(await edgesToNodeWithBinding(page, 'prod')).toHaveCount(EDGE_PARTS)
|
|
|
|
await expect(await edgesToNodeWithBinding(page, 'sum')).toHaveCount(2 * EDGE_PARTS)
|
2024-01-31 16:42:36 +03:00
|
|
|
await expect(await edgesToNodeWithBinding(page, 'ten')).toHaveCount(0)
|
|
|
|
await expect(await edgesToNodeWithBinding(page, 'five')).toHaveCount(0)
|
|
|
|
})
|
|
|
|
|
2024-02-06 19:15:00 +03:00
|
|
|
/**
|
|
|
|
* Prepare the graph for the tests. We drag the `ten` node to the right for better access to its outgoing edge.
|
|
|
|
*/
|
|
|
|
async function initGraph(page: Page) {
|
2024-01-31 16:42:36 +03:00
|
|
|
await actions.goToGraph(page)
|
2024-02-06 19:15:00 +03:00
|
|
|
await actions.dragNodeByBinding(page, 'ten', 400, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scenario: We hover over the edge to the left of the `ten` node. We expect the edge to be rendered with a dimmed part
|
|
|
|
* and a non-dimmed part.
|
|
|
|
*/
|
|
|
|
test('Hover behaviour of edges', async ({ page }) => {
|
|
|
|
await initGraph(page)
|
2024-01-31 16:42:36 +03:00
|
|
|
|
2024-02-02 12:22:18 +03:00
|
|
|
const edgeElements = await edgesFromNodeWithBinding(page, 'ten')
|
|
|
|
await expect(edgeElements).toHaveCount(EDGE_PARTS)
|
2024-01-31 16:42:36 +03:00
|
|
|
|
2024-02-02 12:22:18 +03:00
|
|
|
const targetEdge = edgeElements.first()
|
|
|
|
await expect(targetEdge).toHaveClass('edge io')
|
2024-02-06 19:15:00 +03:00
|
|
|
|
|
|
|
// Hover over edge to the left of node with binding `ten`.
|
2024-01-31 16:42:36 +03:00
|
|
|
await targetEdge.hover({
|
2024-02-06 19:15:00 +03:00
|
|
|
position: { x: 250, y: 35.0 },
|
|
|
|
force: true,
|
2024-01-31 16:42:36 +03:00
|
|
|
})
|
2024-02-06 19:15:00 +03:00
|
|
|
|
2024-01-31 16:42:36 +03:00
|
|
|
// Expect an extra edge for the split rendering.
|
2024-02-02 12:22:18 +03:00
|
|
|
const hoveredEdgeElements = await edgesFromNodeWithBinding(page, 'ten')
|
2024-02-06 19:15:00 +03:00
|
|
|
await expect(hoveredEdgeElements).toHaveCount(SPLIT_EDGE_PARTS)
|
2024-01-31 16:42:36 +03:00
|
|
|
|
|
|
|
// Expect the top edge part to be dimmed
|
2024-02-19 18:12:15 +03:00
|
|
|
const topEdge = page.locator('svg.behindNodes g:nth-child(2) path:nth-child(1)')
|
2024-01-31 16:42:36 +03:00
|
|
|
await expect(topEdge).toHaveClass('edge visible dimmed')
|
|
|
|
// Expect the bottom edge part not to be dimmed
|
2024-02-19 18:12:15 +03:00
|
|
|
const bottomEdge = page.locator('svg.behindNodes g:nth-child(2) path:nth-child(3)')
|
2024-01-31 16:42:36 +03:00
|
|
|
await expect(bottomEdge).toHaveClass('edge visible')
|
|
|
|
})
|