mirror of
https://github.com/enso-org/enso.git
synced 2024-12-30 07:01:38 +03:00
736134e491
Fixes #11604 Most issues were caused by a problem with Project List flooding the network with its requests - this was fixed on develop. But one assertion was flaky - it assumed we will see the "real" run result on `write` node, but sometimes it is immediately overwritten by dry run. But the most important part of this PR is adding traces to Electron packages - it's should be much easier now to debug E2E test failures. Also renamed the previously misnamed "E2E tests" to "[GUI] integration tests".
91 lines
3.4 KiB
TypeScript
91 lines
3.4 KiB
TypeScript
import test from 'playwright/test'
|
|
import * as actions from './actions'
|
|
import { expect } from './customExpect'
|
|
import { CONTROL_KEY } from './keyboard'
|
|
import * as locate from './locate'
|
|
import { edgesFromNodeWithBinding, edgesToNodeWithBinding } from './locate'
|
|
|
|
/**
|
|
* Every edge consists of multiple parts.
|
|
* See edgeRendering.spec.ts for explanation.
|
|
*/
|
|
const EDGE_PARTS = 2
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.addInitScript(() => {
|
|
class MockClipboard {
|
|
private contents: ClipboardItem[] = []
|
|
async read(): Promise<ClipboardItem[]> {
|
|
return [...this.contents]
|
|
}
|
|
async write(contents: ClipboardItem[]) {
|
|
this.contents = [...contents]
|
|
}
|
|
}
|
|
Object.assign(window.navigator, {
|
|
mockClipboard: new MockClipboard(),
|
|
})
|
|
})
|
|
})
|
|
|
|
test('Copy node with comment', async ({ page }) => {
|
|
await actions.goToGraph(page)
|
|
|
|
// Check state before operation.
|
|
const originalNodes = await locate.graphNode(page).count()
|
|
await expect(locate.nodeComment(page)).toExist()
|
|
const originalNodeComments = await locate.nodeComment(page).count()
|
|
|
|
// Select a node.
|
|
const nodeToCopy = locate.graphNodeByBinding(page, 'final')
|
|
await nodeToCopy.click()
|
|
await expect(nodeToCopy).toBeSelected()
|
|
// Copy and paste it.
|
|
await page.keyboard.press(`${CONTROL_KEY}+C`)
|
|
await page.keyboard.press(`${CONTROL_KEY}+V`)
|
|
await expect(nodeToCopy).not.toBeSelected()
|
|
await expect(locate.selectedNodes(page)).toHaveCount(1)
|
|
|
|
// Node and comment have been copied.
|
|
await expect(locate.graphNode(page)).toHaveCount(originalNodes + 1)
|
|
await expect(locate.nodeComment(page)).toHaveCount(originalNodeComments + 1)
|
|
})
|
|
|
|
test('Copy multiple nodes', async ({ page }) => {
|
|
await actions.goToGraph(page)
|
|
|
|
// Check state before operation.
|
|
const originalNodes = await locate.graphNode(page).count()
|
|
await expect(locate.nodeComment(page)).toExist()
|
|
const originalNodeComments = await locate.nodeComment(page).count()
|
|
|
|
// Select some nodes.
|
|
const node1 = locate.graphNodeByBinding(page, 'final')
|
|
await node1.click()
|
|
const node2 = locate.graphNodeByBinding(page, 'prod')
|
|
await node2.click({ modifiers: ['Shift'] })
|
|
await expect(node1).toBeSelected()
|
|
await expect(node2).toBeSelected()
|
|
// Copy and paste.
|
|
await page.keyboard.press(`${CONTROL_KEY}+C`)
|
|
await page.keyboard.press(`${CONTROL_KEY}+V`)
|
|
await expect(node1).not.toBeSelected()
|
|
await expect(node2).not.toBeSelected()
|
|
await expect(locate.selectedNodes(page)).toHaveCount(2)
|
|
|
|
// Nodes and comment have been copied.
|
|
await expect(locate.graphNode(page)).toHaveCount(originalNodes + 2)
|
|
// `final` node has a comment.
|
|
await expect(locate.nodeComment(page)).toHaveCount(originalNodeComments + 1)
|
|
// Check that two copied nodes are isolated, i.e. connected to each other, not original nodes.
|
|
await expect(locate.graphNodeByBinding(page, 'prod1')).toBeVisible()
|
|
await expect(locate.graphNodeByBinding(page, 'final1')).toBeVisible()
|
|
await expect(await edgesFromNodeWithBinding(page, 'sum')).toHaveCount(2 * EDGE_PARTS)
|
|
await expect(await edgesFromNodeWithBinding(page, 'prod')).toHaveCount(1 * EDGE_PARTS)
|
|
|
|
await expect(await edgesToNodeWithBinding(page, 'prod')).toHaveCount(1 * EDGE_PARTS)
|
|
await expect(await edgesToNodeWithBinding(page, 'final')).toHaveCount(1 * EDGE_PARTS)
|
|
await expect(await edgesToNodeWithBinding(page, 'prod1')).toHaveCount(1 * EDGE_PARTS)
|
|
await expect(await edgesToNodeWithBinding(page, 'final1')).toHaveCount(1 * EDGE_PARTS)
|
|
})
|