-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
194 additions
and
7 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
38 changes: 38 additions & 0 deletions
38
packages/perspective-viewer-hypergrid/test/html/editable.html
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,38 @@ | ||
<!-- | ||
Copyright (c) 2017, the Perspective Authors. | ||
This file is part of the Perspective library, distributed under the terms of | ||
the Apache License 2.0. The full license can be found in the LICENSE file. | ||
--> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon"> | ||
<script src="perspective-viewer.js"></script> | ||
<script src="perspective-viewer-hypergrid.js"></script> | ||
|
||
<link rel='stylesheet' href="demo.css"> | ||
|
||
</head> | ||
<body> | ||
|
||
<perspective-viewer columns='["Row ID","Order ID","Order Date","Sales"]' editable> | ||
|
||
</perspective-viewer> | ||
|
||
<script> | ||
|
||
var xhr = new XMLHttpRequest(); | ||
xhr.open('GET', 'superstore.csv', true); | ||
xhr.onload = function () { | ||
document.getElementsByTagName('perspective-viewer')[0].load(xhr.response); | ||
} | ||
xhr.send(null); | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
114 changes: 114 additions & 0 deletions
114
packages/perspective-viewer-hypergrid/test/js/editing.spec.js
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,114 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2017, the Perspective Authors. | ||
* | ||
* This file is part of the Perspective library, distributed under the terms of | ||
* the Apache License 2.0. The full license can be found in the LICENSE file. | ||
* | ||
*/ | ||
|
||
const utils = require("@finos/perspective-test"); | ||
const path = require("path"); | ||
|
||
const {dblclick} = require("./utils.js"); | ||
|
||
utils.with_server({}, () => { | ||
describe.page( | ||
"superstore.html", | ||
() => { | ||
describe("editing UI opens", () => { | ||
test.capture("should not edit an immutable viewer", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.shadow_click("perspective-viewer", "#config_button"); | ||
await page.waitForSelector("perspective-viewer[settings]"); | ||
await dblclick(page); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
}); | ||
}, | ||
{reload_page: true, root: path.join(__dirname, "..", "..")} | ||
); | ||
|
||
describe.page( | ||
"editable.html", | ||
() => { | ||
describe("editing UI opens", () => { | ||
test.capture("should open an editor on a string column", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.shadow_click("perspective-viewer", "#config_button"); | ||
await page.waitForSelector("perspective-viewer[settings]"); | ||
await dblclick(page); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
|
||
test.capture("should open an editor on an integer column", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.shadow_click("perspective-viewer", "#config_button"); | ||
await page.waitForSelector("perspective-viewer[settings]"); | ||
await dblclick(page, 50); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
|
||
test.capture("should open an editor on a datetime column", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.shadow_click("perspective-viewer", "#config_button"); | ||
await page.waitForSelector("perspective-viewer[settings]"); | ||
await dblclick(page, 400); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
}); | ||
|
||
describe("editing UI saves", () => { | ||
test.capture("should save edits to a string column", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.shadow_click("perspective-viewer", "#config_button"); | ||
await page.waitForSelector("perspective-viewer[settings]"); | ||
await dblclick(page); | ||
await page.keyboard.sendCharacter("a"); | ||
await page.keyboard.sendCharacter("b"); | ||
await page.keyboard.sendCharacter("c"); | ||
await page.keyboard.sendCharacter("d"); | ||
await page.keyboard.press("Enter"); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
|
||
test.capture("should save edits to an integer column", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.shadow_click("perspective-viewer", "#config_button"); | ||
await page.waitForSelector("perspective-viewer[settings]"); | ||
await dblclick(page, 50); | ||
await page.keyboard.sendCharacter("1"); | ||
await page.keyboard.sendCharacter("2"); | ||
await page.keyboard.press("Enter"); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
|
||
test.capture("should save edits of negative numbers to an integer column", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.shadow_click("perspective-viewer", "#config_button"); | ||
await page.waitForSelector("perspective-viewer[settings]"); | ||
await dblclick(page, 50); | ||
await page.keyboard.sendCharacter("-"); | ||
await page.keyboard.sendCharacter("1"); | ||
await page.keyboard.sendCharacter("2"); | ||
await page.keyboard.press("Enter"); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
|
||
test.capture("should fail to save edits of invalid integers", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.shadow_click("perspective-viewer", "#config_button"); | ||
await page.waitForSelector("perspective-viewer[settings]"); | ||
await dblclick(page, 50); | ||
await page.keyboard.sendCharacter("1"); | ||
await page.keyboard.sendCharacter("2"); | ||
await page.keyboard.sendCharacter("A"); | ||
await page.keyboard.press("Enter"); | ||
await page.waitFor(100); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
}); | ||
}, | ||
{reload_page: true, root: path.join(__dirname, "..", "..")} | ||
); | ||
}); |
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