-
-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Copy With Headers to grid cell popup. (#1208)
* Add "Copy with headers" to grid cell popup. This is what you want when you're going to paste into e.g. an email. Tested just by manually trying copy and paste into an editor and an email, and then again using the new variant to confirm the headers show up. #1208
- Loading branch information
Showing
6 changed files
with
89 additions
and
13 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
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,59 @@ | ||
/** | ||
* Test for copying Grist data with headers. | ||
*/ | ||
|
||
import {assert, driver, Key} from 'mocha-webdriver'; | ||
import * as gu from 'test/nbrowser/gristUtils'; | ||
import {setupTestSuite} from 'test/nbrowser/testUtils'; | ||
import {createDummyTextArea, removeDummyTextArea} from 'test/nbrowser/CopyPaste'; | ||
|
||
describe("CopyWithHeaders", function() { | ||
this.timeout(90000); | ||
const cleanup = setupTestSuite(); | ||
const clipboard = gu.getLockableClipboard(); | ||
afterEach(() => gu.checkForErrors()); | ||
gu.bigScreen(); | ||
|
||
after(async function() { | ||
await driver.executeScript(removeDummyTextArea); | ||
}); | ||
|
||
it('should copy headers', async function() { | ||
const session = await gu.session().teamSite.login(); | ||
await session.tempDoc(cleanup, 'Hello.grist'); | ||
await driver.executeScript(createDummyTextArea); | ||
|
||
await clipboard.lockAndPerform(async (cb) => { | ||
// Select all | ||
await gu.sendKeys(Key.chord(Key.CONTROL, 'a')); | ||
await gu.rightClick(gu.getCell({rowNum: 1, col: 'A'})); | ||
await driver.findContent('.grist-floating-menu li', 'Copy with headers').click(); | ||
|
||
await pasteAndCheck(cb, ["A", "B", "C", "D", "E"], 5); | ||
}); | ||
|
||
await clipboard.lockAndPerform(async (cb) => { | ||
// Select a single cell. | ||
await gu.getCell({rowNum: 2, col: 'D'}).click(); | ||
await gu.rightClick(gu.getCell({rowNum: 2, col: 'D'})); | ||
await driver.findContent('.grist-floating-menu li', 'Copy with headers').click(); | ||
|
||
await pasteAndCheck(cb, ["D"], 2); | ||
}); | ||
}); | ||
}); | ||
|
||
async function pasteAndCheck(cb: gu.IClipboard, headers: string[], rows: number) { | ||
// Paste into the dummy textarea. | ||
await driver.find('#dummyText').click(); | ||
await gu.waitAppFocus(false); | ||
await cb.paste(); | ||
|
||
const textarea = await driver.find('#dummyText'); | ||
const text = await textarea.getAttribute('value'); | ||
const lines = text.split('\n'); | ||
const regex = new RegExp(`^${headers.join('\\s+')}$`); | ||
assert.match(lines[0], regex); | ||
assert.equal(lines.length, rows); | ||
await textarea.clear(); | ||
} |