2024-02-05 17:20:24 +03:00
|
|
|
import { expect, type Page } from '@playwright/test'
|
|
|
|
import * as customExpect from './customExpect'
|
|
|
|
import * as locate from './locate'
|
2024-02-06 19:15:00 +03:00
|
|
|
import { graphNodeByBinding } from './locate'
|
2023-11-27 18:48:37 +03:00
|
|
|
|
|
|
|
// =================
|
|
|
|
// === goToGraph ===
|
|
|
|
// =================
|
|
|
|
|
|
|
|
/** Perform a successful login. */
|
|
|
|
export async function goToGraph(page: Page) {
|
|
|
|
await page.goto('/')
|
2024-02-05 17:20:24 +03:00
|
|
|
await expect(page.locator('.App')).toBeVisible()
|
|
|
|
// Wait until nodes are loaded.
|
|
|
|
await customExpect.toExist(locate.graphNode(page))
|
2023-11-27 18:48:37 +03:00
|
|
|
}
|
2024-02-06 19:15:00 +03:00
|
|
|
|
|
|
|
// =================
|
|
|
|
// === Drag Node ===
|
|
|
|
// =================
|
|
|
|
|
|
|
|
/// Move node defined by the given binding by the given x and y.
|
|
|
|
export async function dragNodeByBinding(page: Page, nodeBinding: string, x: number, y: number) {
|
|
|
|
const node = graphNodeByBinding(page, nodeBinding)
|
|
|
|
const grabHandle = await node.locator('.grab-handle')
|
|
|
|
await grabHandle.dragTo(grabHandle, {
|
|
|
|
targetPosition: { x, y },
|
|
|
|
force: true,
|
|
|
|
})
|
|
|
|
}
|