2024-02-02 12:22:18 +03:00
|
|
|
import { expect, test, type Page } from '@playwright/test'
|
2024-01-31 16:42:36 +03:00
|
|
|
import * as actions from './actions'
|
|
|
|
import * as locate from './locate'
|
|
|
|
|
|
|
|
async function edgesFromNodeWithBinding(page: Page, binding: string) {
|
|
|
|
const node = locate.graphNodeByBinding(page, binding).first()
|
|
|
|
const nodeId = await node.getAttribute('data-node-id')
|
|
|
|
return page.locator(`[data-source-node-id="${nodeId}"]`)
|
|
|
|
}
|
|
|
|
async function edgesToNodeWithBinding(page: Page, binding: string) {
|
|
|
|
const node = locate.graphNodeByBinding(page, binding).first()
|
|
|
|
const nodeId = await node.getAttribute('data-node-id')
|
|
|
|
return page.locator(`[data-target-node-id="${nodeId}"]`)
|
|
|
|
}
|
|
|
|
|
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-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-02-02 12:22:18 +03:00
|
|
|
await expect(await edgesFromNodeWithBinding(page, 'data')).toHaveCount(2 * 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-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-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)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Hover behaviour of edges', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
|
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')
|
|
|
|
// It is not currently possible to interact with edges in the default node layout.
|
|
|
|
// See: https://github.com/enso-org/enso/issues/8938
|
|
|
|
/*
|
2024-01-31 16:42:36 +03:00
|
|
|
// Hover over edge to the right of node with binding `ten`.
|
|
|
|
await targetEdge.hover({
|
2024-02-02 12:22:18 +03:00
|
|
|
position: { x: 60, y: 45 }, // source node
|
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')
|
|
|
|
await expect(hoveredEdgeElements).toHaveCount(2 * EDGE_PARTS)
|
2024-01-31 16:42:36 +03:00
|
|
|
|
|
|
|
// Expect the top edge part to be dimmed
|
|
|
|
const topEdge = page.locator('path:nth-child(4)')
|
|
|
|
await expect(topEdge).toHaveClass('edge visible dimmed')
|
|
|
|
// Expect the bottom edge part not to be dimmed
|
|
|
|
const bottomEdge = page.locator('path:nth-child(6)')
|
|
|
|
await expect(bottomEdge).toHaveClass('edge visible')
|
2024-02-02 12:22:18 +03:00
|
|
|
*/
|
2024-01-31 16:42:36 +03:00
|
|
|
})
|