2024-04-09 15:02:11 +03:00
|
|
|
import test from 'playwright/test'
|
2024-03-29 19:31:00 +03:00
|
|
|
import * as actions from './actions'
|
|
|
|
import { expect } from './customExpect'
|
2024-04-19 19:33:51 +03:00
|
|
|
import { CONTROL_KEY, DELETE_KEY } from './keyboard'
|
2024-03-29 19:31:00 +03:00
|
|
|
import * as locate from './locate'
|
|
|
|
|
|
|
|
test('Adding new node', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
|
|
|
|
const nodesCount = await locate.graphNode(page).count()
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
|
|
await expect(locate.componentBrowserInput(page)).toBeVisible()
|
|
|
|
await page.keyboard.insertText('foo')
|
2024-04-19 19:33:51 +03:00
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+Enter`)
|
2024-03-29 19:31:00 +03:00
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount + 1)
|
|
|
|
await expect(locate.graphNode(page).last().locator('.WidgetToken')).toHaveText(['foo'])
|
|
|
|
const newNodeBBox = await locate.graphNode(page).last().boundingBox()
|
|
|
|
|
2024-04-19 19:33:51 +03:00
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+Z`)
|
2024-03-29 19:31:00 +03:00
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount)
|
|
|
|
await expect(
|
|
|
|
locate.graphNode(page).locator('.WidgetToken').filter({ hasText: 'foo' }),
|
|
|
|
).toHaveCount(0)
|
|
|
|
|
2024-04-19 19:33:51 +03:00
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+Shift+Z`)
|
2024-03-29 19:31:00 +03:00
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount + 1)
|
|
|
|
await expect(locate.graphNode(page).last().locator('.WidgetToken')).toHaveText(['foo'])
|
|
|
|
const restoredBox = await locate.graphNode(page).last().boundingBox()
|
|
|
|
await expect(restoredBox).toEqual(newNodeBBox)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Removing node', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
|
|
|
|
const nodesCount = await locate.graphNode(page).count()
|
|
|
|
const deletedNode = locate.graphNodeByBinding(page, 'final')
|
|
|
|
const deletedNodeBBox = await deletedNode.boundingBox()
|
|
|
|
await deletedNode.click()
|
2024-04-19 19:33:51 +03:00
|
|
|
await page.keyboard.press(DELETE_KEY)
|
2024-03-29 19:31:00 +03:00
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount - 1)
|
|
|
|
|
2024-04-19 19:33:51 +03:00
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+Z`)
|
2024-03-29 19:31:00 +03:00
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount)
|
|
|
|
await expect(deletedNode.locator('.WidgetToken')).toHaveText(['Main', '.', 'func1', 'prod'])
|
|
|
|
await expect(deletedNode.locator('.GraphNodeComment')).toHaveText('This node can be entered')
|
|
|
|
const restoredBBox = await deletedNode.boundingBox()
|
|
|
|
await expect(restoredBBox).toEqual(deletedNodeBBox)
|
|
|
|
|
2024-04-19 19:33:51 +03:00
|
|
|
await page.keyboard.press(`${CONTROL_KEY}+Shift+Z`)
|
2024-03-29 19:31:00 +03:00
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount - 1)
|
|
|
|
await expect(deletedNode).not.toBeVisible()
|
|
|
|
})
|