-
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.
Fix cancellable methods in
perspective-viewer
Signed-off-by: Andrew Stein <steinlink@gmail.com>
- Loading branch information
Showing
13 changed files
with
193 additions
and
39 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
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,45 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script type="module" src="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"></script> | ||
<script type="module"> | ||
await customElements.whenDefined("perspective-viewer-plugin"); | ||
const BASE = customElements.get("perspective-viewer-plugin"); | ||
|
||
class TestPluginImplementsResize extends BASE { | ||
get name() { | ||
return "Resizing Plugin"; | ||
} | ||
|
||
async draw(view) { | ||
this._view = view; | ||
console.log(await this._view.num_rows()); | ||
return await super.draw(view); | ||
} | ||
|
||
async update(view) { | ||
this._view = view; | ||
console.log(await this._view.num_rows()); | ||
return await super.update(view); | ||
} | ||
|
||
async resize(view) { | ||
console.log(await this._view.num_rows()); | ||
await this._view.to_csv(); | ||
} | ||
} | ||
|
||
customElements.define("resize-plugin", TestPluginImplementsResize); | ||
await customElements.whenDefined("perspective-viewer").then((viewer) => { | ||
viewer.registerPlugin("resize-plugin"); | ||
}); | ||
</script> | ||
|
||
<script type="module" src="/node_modules/@finos/perspective-test/load-viewer-csv.js"></script> | ||
<link rel="stylesheet" href="../css/demo.css" /> | ||
<link rel="stylesheet" href="/node_modules/@finos/perspective-viewer/dist/css/pro.css" /> | ||
</head> | ||
<body> | ||
<perspective-viewer></perspective-viewer> | ||
</body> | ||
</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,57 @@ | ||
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ | ||
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ | ||
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ | ||
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃ | ||
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃ | ||
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ | ||
// ┃ Copyright (c) 2017, the Perspective Authors. ┃ | ||
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ | ||
// ┃ This file is part of the Perspective library, distributed under the terms ┃ | ||
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃ | ||
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ | ||
|
||
import { test } from "@finos/perspective-test"; | ||
import { compareContentsToSnapshot } from "@finos/perspective-test"; | ||
|
||
async function get_contents(page) { | ||
return await page.evaluate(async () => { | ||
const viewer = document | ||
.querySelector("perspective-viewer") | ||
.shadowRoot.querySelector("#app_panel"); | ||
return viewer ? viewer.innerHTML : "MISSING"; | ||
}); | ||
} | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("/rust/perspective-viewer/test/html/plugin-resize.html"); | ||
await page.evaluate(async () => { | ||
while (!window["__TEST_PERSPECTIVE_READY__"]) { | ||
await new Promise((x) => setTimeout(x, 10)); | ||
} | ||
}); | ||
}); | ||
|
||
test.describe("Cancellable methods", () => { | ||
test("Cancellable view methods do not error", async ({ page }) => { | ||
await page.evaluate(async () => { | ||
const viewer = document.querySelector("perspective-viewer"); | ||
await viewer.restore({ | ||
group_by: ["State"], | ||
columns: ["Sales"], | ||
settings: true, | ||
filter: [ | ||
["State", "not in", ["California", "Texas", "New York"]], | ||
], | ||
}); | ||
|
||
const view = await viewer.getView(); | ||
await view.delete(); | ||
await viewer.resize(true); | ||
}); | ||
|
||
const contents = await get_contents(page); | ||
await compareContentsToSnapshot(contents, [ | ||
"regressions-not_in-filter-works-correctly.txt", | ||
]); | ||
}); | ||
}); |
Binary file not shown.