forked from finos/perspective
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
perspective-viewer-hypergrid
tests for selectable
- Loading branch information
Showing
3 changed files
with
118 additions
and
3 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
35 changes: 35 additions & 0 deletions
35
packages/perspective-viewer-hypergrid/test/html/selectable.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,35 @@ | ||
<!-- | ||
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 id="viewer" columns='["Row ID","Order ID","Order Date","Sales"]' selectable> | ||
|
||
</perspective-viewer> | ||
<script> | ||
const data = [ | ||
{name: "Homer", number: 100}, | ||
{name: "Marge", number: 200} | ||
]; | ||
|
||
document.getElementById("viewer").load(data, {index: "name"}); | ||
</script> | ||
|
||
</body> | ||
</html> |
80 changes: 80 additions & 0 deletions
80
packages/perspective-viewer-hypergrid/test/js/selection.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,80 @@ | ||
/****************************************************************************** | ||
* | ||
* 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"); | ||
|
||
utils.with_server({}, () => { | ||
describe.page( | ||
"selectable.html", | ||
() => { | ||
describe("no pivots", () => { | ||
describe("selecting a row", () => { | ||
test.capture("highlights the row with no pivots", async page => { | ||
await page.$("perspective-viewer"); | ||
await page.focus("perspective-viewer"); | ||
await page.mouse.click(80, 60); | ||
await page.mouse.move(80, 40); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
|
||
test.capture("keeps selection when row moves with no pivots", async page => { | ||
const viewer = await page.$("perspective-viewer"); | ||
await page.evaluate(element => { | ||
element.setAttribute("sort", '[["number", "asc"]]'); | ||
}, viewer); | ||
|
||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
|
||
await page.focus("perspective-viewer"); | ||
await page.mouse.click(80, 60); | ||
|
||
await page.evaluate(element => { | ||
element.update([{name: "Homer", number: 300}]); | ||
}, viewer); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
}); | ||
}); | ||
describe("row pivots", () => { | ||
describe("selecting a row", () => { | ||
test.capture("highlights the row with row pivots", async page => { | ||
const viewer = await page.$("perspective-viewer"); | ||
await page.evaluate(element => { | ||
element.setAttribute("row-pivots", '["name"]'); | ||
}, viewer); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
|
||
await page.focus("perspective-viewer"); | ||
await page.mouse.click(80, 60); | ||
await page.mouse.move(80, 40); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
|
||
test.capture("keeps selection when row moves with row pivots", async page => { | ||
const viewer = await page.$("perspective-viewer"); | ||
await page.evaluate(element => { | ||
element.setAttribute("sort", '[["number", "asc"]]'); | ||
element.setAttribute("row-pivots", '["name"]'); | ||
}, viewer); | ||
|
||
await page.focus("perspective-viewer"); | ||
await page.mouse.click(80, 60); | ||
|
||
await page.evaluate(element => { | ||
element.update([{name: "Homer", number: 300}]); | ||
}, viewer); | ||
await page.waitForSelector("perspective-viewer:not([updating])"); | ||
}); | ||
}); | ||
}); | ||
}, | ||
{reload_page: false, root: path.join(__dirname, "..", "..")} | ||
); | ||
}); |