-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copying nodes: - Multiple nodes supported. - Node comments and user-specified colors included. - Google Sheets data can be pasted to produce a `Table` node, handled the same way as Excel data. # Important Notes - Fix E2E tests on OS X. - Add E2E and unit tests for clipboard. - Use the lexer to test text escaping; fix text escaping issues and inconsistencies.
- Loading branch information
Showing
14 changed files
with
394 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import os from 'os' | ||
|
||
export const CONTROL_KEY = os.platform() === 'darwin' ? 'Meta' : 'Control' | ||
export const DELETE_KEY = os.platform() === 'darwin' ? 'Backspace' : 'Delete' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import test from 'playwright/test' | ||
import * as actions from './actions' | ||
import { expect } from './customExpect' | ||
import { CONTROL_KEY } from './keyboard' | ||
import * as locate from './locate' | ||
|
||
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(page.locator('.GraphNodeComment')).toExist() | ||
const originalNodeComments = await page.locator('.GraphNodeComment').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).toBeSelected() | ||
|
||
// Node and comment have been copied. | ||
await expect(locate.graphNode(page)).toHaveCount(originalNodes + 1) | ||
await expect(page.locator('.GraphNodeComment')).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(page.locator('.GraphNodeComment')).toExist() | ||
const originalNodeComments = await page.locator('.GraphNodeComment').count() | ||
|
||
// Select some nodes. | ||
const node1 = locate.graphNodeByBinding(page, 'final') | ||
await node1.click() | ||
const node2 = locate.graphNodeByBinding(page, 'data') | ||
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).toBeSelected() | ||
await expect(node2).toBeSelected() | ||
|
||
// Nodes and comment have been copied. | ||
await expect(locate.graphNode(page)).toHaveCount(originalNodes + 2) | ||
await expect(page.locator('.GraphNodeComment')).toHaveCount(originalNodeComments + 1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** Returns an all the keys of a type. The argument provided is required to be an object containing all the keys of the | ||
* type (including optional fields), but the associated values are ignored and may be of any type. */ | ||
export function allKeys<T>(keys: { [P in keyof T]-?: any }): ReadonlySet<string> { | ||
return Object.freeze(new Set(Object.keys(keys))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.