2023-11-27 18:48:37 +03:00
|
|
|
import { expect, test } from '@playwright/test'
|
2024-01-03 12:12:38 +03:00
|
|
|
import assert from 'assert'
|
2023-11-27 18:48:37 +03:00
|
|
|
import * as actions from './actions'
|
|
|
|
import * as customExpect from './customExpect'
|
|
|
|
import * as locate from './locate'
|
|
|
|
|
2024-01-03 12:12:38 +03:00
|
|
|
test('Different ways of opening Component Browser', async ({ page }) => {
|
2023-11-27 18:48:37 +03:00
|
|
|
await actions.goToGraph(page)
|
2024-01-03 12:12:38 +03:00
|
|
|
const nodeCount = await locate.graphNode(page).count()
|
|
|
|
|
|
|
|
async function expectAndCancelBrowser(expectedInput: string) {
|
|
|
|
await customExpect.toExist(locate.componentBrowser(page))
|
|
|
|
await customExpect.toExist(locate.componentBrowserEntry(page))
|
|
|
|
await expect(locate.componentBrowserInput(page).locator('input')).toHaveValue(expectedInput)
|
|
|
|
await page.keyboard.press('Escape')
|
|
|
|
await expect(locate.componentBrowser(page)).not.toBeVisible()
|
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodeCount)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Without source node
|
|
|
|
|
|
|
|
// (+) button
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
|
|
await expectAndCancelBrowser('')
|
|
|
|
// Enter key
|
2023-11-27 18:48:37 +03:00
|
|
|
await locate.graphEditor(page).press('Enter')
|
2024-01-03 12:12:38 +03:00
|
|
|
await expectAndCancelBrowser('')
|
|
|
|
|
|
|
|
// With source node
|
|
|
|
|
|
|
|
// (+) button
|
|
|
|
await locate.graphNodeByBinding(page, 'benches').click()
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
|
|
await expectAndCancelBrowser('benches.')
|
|
|
|
// Enter key
|
|
|
|
await locate.graphNodeByBinding(page, 'benches').click()
|
|
|
|
await locate.graphEditor(page).press('Enter')
|
|
|
|
await expectAndCancelBrowser('benches.')
|
|
|
|
// Dragging out an edge
|
|
|
|
// `click` method of locator could be simpler, but `position` option doesn't work.
|
|
|
|
const outputPortArea = await locate
|
|
|
|
.graphNodeByBinding(page, 'benches')
|
|
|
|
.locator('.outputPortHoverArea')
|
|
|
|
.boundingBox()
|
|
|
|
assert(outputPortArea)
|
|
|
|
const outputPortX = outputPortArea.x + outputPortArea.width / 2.0
|
|
|
|
const outputPortY = outputPortArea.y + outputPortArea.height - 2.0
|
|
|
|
await page.mouse.click(outputPortX, outputPortY)
|
|
|
|
await page.mouse.click(40, 300)
|
|
|
|
await expectAndCancelBrowser('benches.')
|
|
|
|
// Double-clicking port
|
|
|
|
await page.mouse.click(outputPortX, outputPortY)
|
|
|
|
// TODO[ao] the above click is already treated as double (due to previous event)
|
|
|
|
// But perhaps we should have more reliable method of simulating double clicks.
|
|
|
|
// await outputPortArea.dispatchEvent('pointerdown')
|
|
|
|
await expectAndCancelBrowser('benches.')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Accepting suggestion', async ({ page }) => {
|
|
|
|
// Clicking enry
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
await locate.addNewNodeButton(page).click()
|
2023-12-12 17:27:40 +03:00
|
|
|
let nodeCount = await locate.graphNode(page).count()
|
2023-12-20 17:54:55 +03:00
|
|
|
await locate.componentBrowserEntry(page).nth(1).click()
|
2023-12-12 17:27:40 +03:00
|
|
|
await expect(locate.componentBrowser(page)).not.toBeVisible()
|
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodeCount + 1)
|
2024-01-03 12:12:38 +03:00
|
|
|
await expect(locate.graphNode(page).last().locator('.WidgetToken')).toHaveText([
|
|
|
|
'Data',
|
|
|
|
'.',
|
|
|
|
'read_text',
|
|
|
|
])
|
2023-12-12 17:27:40 +03:00
|
|
|
|
2024-01-03 12:12:38 +03:00
|
|
|
// Clicking at highlighted entry
|
2023-12-12 17:27:40 +03:00
|
|
|
nodeCount = await locate.graphNode(page).count()
|
2024-01-03 12:12:38 +03:00
|
|
|
await locate.addNewNodeButton(page).click()
|
2023-12-12 17:27:40 +03:00
|
|
|
await locate.componentBrowserSelectedEntry(page).first().click()
|
2023-11-27 18:48:37 +03:00
|
|
|
await expect(locate.componentBrowser(page)).not.toBeVisible()
|
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodeCount + 1)
|
2024-01-03 12:12:38 +03:00
|
|
|
await expect(locate.graphNode(page).last().locator('.WidgetToken')).toHaveText([
|
|
|
|
'Data',
|
|
|
|
'.',
|
|
|
|
'read',
|
|
|
|
])
|
|
|
|
|
|
|
|
// Accepting with Enter
|
|
|
|
nodeCount = await locate.graphNode(page).count()
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
|
|
await page.keyboard.press('Enter')
|
|
|
|
await expect(locate.componentBrowser(page)).not.toBeVisible()
|
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodeCount + 1)
|
|
|
|
await expect(locate.graphNode(page).last().locator('.WidgetToken')).toHaveText([
|
|
|
|
'Data',
|
|
|
|
'.',
|
|
|
|
'read',
|
|
|
|
])
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Accepting any written input', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
|
|
const nodeCount = await locate.graphNode(page).count()
|
|
|
|
await locate.componentBrowserInput(page).locator('input').fill('re')
|
|
|
|
await page.keyboard.press('Control+Enter')
|
|
|
|
await expect(locate.componentBrowser(page)).not.toBeVisible()
|
|
|
|
await expect(locate.graphNode(page)).toHaveCount(nodeCount + 1)
|
|
|
|
await expect(locate.graphNode(page).last().locator('.WidgetToken')).toHaveText('re')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Filling input with suggestions', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
|
|
|
|
|
|
// Entering module
|
|
|
|
await locate.componentBrowserEntryByLabel(page, 'Standard.Base.Data').click()
|
|
|
|
await customExpect.toExist(locate.componentBrowser(page))
|
|
|
|
await expect(locate.componentBrowserInput(page).locator('input')).toHaveValue(
|
|
|
|
'Standard.Base.Data.',
|
|
|
|
)
|
|
|
|
|
|
|
|
// Applying suggestion
|
|
|
|
page.keyboard.press('Tab')
|
|
|
|
await customExpect.toExist(locate.componentBrowser(page))
|
|
|
|
await expect(locate.componentBrowserInput(page).locator('input')).toHaveValue(
|
|
|
|
'Standard.Base.Data.read ',
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Filtering list', async ({ page }) => {
|
|
|
|
await actions.goToGraph(page)
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
|
|
await locate.componentBrowserInput(page).locator('input').fill('re_te')
|
|
|
|
const segments = locate.componentBrowserEntry(page).locator('.component-label-segment')
|
|
|
|
await expect(segments).toHaveText(['Data.', 're', 'ad', '_te', 'xt'])
|
|
|
|
const highlighted = locate.componentBrowserEntry(page).locator('.component-label-segment.match')
|
|
|
|
await expect(highlighted).toHaveText(['re', '_te'])
|
2023-11-27 18:48:37 +03:00
|
|
|
})
|