mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 03:21:44 +03:00
0b6b1f0954
Context menu, copy button, multi-component actions https://github.com/user-attachments/assets/14243102-3848-43fc-82bb-a48648536985 - The 'More' menu can now be opened under the mouse, through the context menu action (right click/control-click on Mac/menu button on keyboard). - Add copy-components button to menu. - The menu can now be opened while multiple components are selected; if the clicked component was among the selected components, the selection will be preserved. Some menu actions--currently *copy* and *delete*, apply to all selected components. These actions will change their displayed labels when multiple components are selected. If a single-component action is executed, the component it was applied to will become the sole selection. Fixes #11633, #11634
80 lines
3.1 KiB
TypeScript
80 lines
3.1 KiB
TypeScript
import { test } from '@playwright/test'
|
|
import * as actions from './actions'
|
|
import { expect } from './customExpect'
|
|
import { CONTROL_KEY, DELETE_KEY } from './keyboard'
|
|
import * as locate from './locate'
|
|
|
|
test('Deleting selected node with backspace key', async ({ page }) => {
|
|
await actions.goToGraph(page)
|
|
|
|
const nodesCount = await locate.graphNode(page).count()
|
|
const deletedNode = locate.graphNodeByBinding(page, 'final')
|
|
await deletedNode.click()
|
|
await page.keyboard.press('Backspace')
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount - 1)
|
|
})
|
|
|
|
test('Deleting selected node with delete key', async ({ page }) => {
|
|
await actions.goToGraph(page)
|
|
|
|
const nodesCount = await locate.graphNode(page).count()
|
|
const deletedNode = locate.graphNodeByBinding(page, 'final')
|
|
await deletedNode.click()
|
|
await page.keyboard.press('Delete')
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount - 1)
|
|
})
|
|
|
|
test('Deleting node with context menu', async ({ page }) => {
|
|
await actions.goToGraph(page)
|
|
const nodesCount = await locate.graphNode(page).count()
|
|
const deletedNode = locate.graphNodeByBinding(page, 'final')
|
|
await deletedNode.click({ button: 'right' })
|
|
await expect(locate.selectedNodes(page)).toHaveCount(1)
|
|
await page.getByRole('button', { name: 'Delete Component' }).click()
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount - 1)
|
|
})
|
|
|
|
test('Deleting multiple nodes with context menu', async ({ page }) => {
|
|
await actions.goToGraph(page)
|
|
const nodesCount = await locate.graphNode(page).count()
|
|
const deletedNode1 = locate.graphNodeByBinding(page, 'final')
|
|
await deletedNode1.click()
|
|
const deletedNode2 = locate.graphNodeByBinding(page, 'sum')
|
|
await deletedNode2.click({ modifiers: ['Shift'] })
|
|
await deletedNode2.click({ button: 'right' })
|
|
await page
|
|
.locator('.ComponentContextMenu')
|
|
.getByRole('button', { name: 'Delete Selected Components' })
|
|
.click()
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount - 2)
|
|
})
|
|
|
|
test('Graph can be empty', async ({ page }) => {
|
|
await actions.goToGraph(page)
|
|
|
|
await locate.graphEditor(page).press(`${CONTROL_KEY}+A`)
|
|
await locate.graphEditor(page).press(`${DELETE_KEY}`)
|
|
|
|
await expect(locate.graphNode(page)).toHaveCount(0)
|
|
|
|
await locate.addNewNodeButton(page).click()
|
|
await expect(locate.componentBrowserInput(page)).toBeVisible()
|
|
await page.keyboard.insertText('foo')
|
|
await page.keyboard.press(`${CONTROL_KEY}+Enter`)
|
|
await expect(locate.graphNode(page)).toHaveCount(1)
|
|
await expect(locate.graphNode(page).locator('.WidgetToken')).toHaveText(['foo'])
|
|
})
|
|
|
|
test('Removing connected nodes', async ({ page }) => {
|
|
await actions.goToGraph(page)
|
|
const nodesCount = await locate.graphNode(page).count()
|
|
await page.keyboard.down('Shift')
|
|
await locate.graphNodeByBinding(page, 'five').click()
|
|
await expect(locate.selectedNodes(page)).toHaveCount(1)
|
|
await locate.graphNodeByBinding(page, 'sum').click()
|
|
await expect(locate.selectedNodes(page)).toHaveCount(2)
|
|
await page.keyboard.up('Shift')
|
|
await page.keyboard.press('Delete')
|
|
await expect(locate.graphNode(page)).toHaveCount(nodesCount - 2)
|
|
})
|