-
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.
Merge pull request #2502 from ada-x64/chores/docs-tests
Add Docs Tests
- Loading branch information
Showing
12 changed files
with
283 additions
and
203 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta name="viewport" | ||
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | ||
<script type="module" src="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"></script> | ||
<script type="module" | ||
src="/node_modules/@finos/perspective-viewer-datagrid/dist/cdn/perspective-viewer-datagrid.js"></script> | ||
<script type="module" | ||
src="/node_modules/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"></script> | ||
<link rel='stylesheet' href="/node_modules/@finos/perspective-viewer/dist/css/pro.css"> | ||
<style> | ||
perspective-viewer { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
} | ||
|
||
perspective-viewer[theme="Pro Light"] { | ||
--plugin--background: #f2f4f6 | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<perspective-viewer editable> | ||
</perspective-viewer> | ||
<script type="module"> | ||
import perspective from "/node_modules/@finos/perspective/dist/cdn/perspective.js"; | ||
const WORKER = perspective.worker(); | ||
async function on_load() { | ||
console.log("ON LOAD"); | ||
var el = document.getElementsByTagName('perspective-viewer')[0]; | ||
console.log("VIEWR ELEMENT:", el); | ||
const plugin = await el.getPlugin("Heatmap"); | ||
plugin.render_warning = false; | ||
const table = WORKER.table(this.response); | ||
await el.load(table); | ||
await el.toggleConfig(); | ||
window.__TEST_PERSPECTIVE_READY__ = true; | ||
} | ||
window.addEventListener('DOMContentLoaded', function () { | ||
console.log("DOM CONTENT LOADED"); | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open('GET', '/node_modules/superstore-arrow/superstore.lz4.arrow', true); | ||
xhr.responseType = "arraybuffer" | ||
xhr.onload = on_load.bind(xhr); | ||
xhr.send(null); | ||
}); | ||
</script> | ||
</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,103 @@ | ||
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ | ||
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ | ||
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ | ||
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃ | ||
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃ | ||
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ | ||
// ┃ 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, | ||
getSvgContentString, | ||
compareSVGContentsToSnapshot, | ||
PageView, | ||
} from "@finos/perspective-test"; | ||
import EXAMPLES from "../../src/components/ExampleGallery/features"; | ||
const { convert } = require("@finos/perspective-viewer/dist/cjs/migrate.js"); | ||
|
||
test.describe.configure({ mode: "parallel" }); | ||
|
||
test.describe("Examples", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto("docs/template.html"); | ||
await page.evaluate(async () => { | ||
while (!window["__TEST_PERSPECTIVE_READY__"]) { | ||
await new Promise((x) => setTimeout(x, 10)); | ||
} | ||
}); | ||
}); | ||
|
||
for (const idx in EXAMPLES.default) { | ||
const example = EXAMPLES.default[idx]; | ||
test(`${idx} - ${example.name}`, async ({ page }) => { | ||
const { config } = example; | ||
const new_config = await convert( | ||
Object.assign( | ||
{ | ||
plugin: "Datagrid", | ||
group_by: [], | ||
expressions: {}, | ||
split_by: [], | ||
sort: [], | ||
aggregates: {}, | ||
}, | ||
config | ||
) | ||
); | ||
await page.evaluate(async (config) => { | ||
const viewer = document.querySelector("perspective-viewer"); | ||
viewer?.addEventListener("perspective-config-update", (e) => { | ||
window.__CONFIG_UPDATED__ = true; | ||
console.log(e); | ||
}); | ||
await viewer.reset(); | ||
await viewer.restore(config); | ||
}, new_config); | ||
|
||
if (Object.keys(config).length !== 0) { | ||
await page.evaluate(async () => { | ||
while (!window["__CONFIG_UPDATED__"]) { | ||
await new Promise((x) => setTimeout(x, 10)); | ||
} | ||
}); | ||
} | ||
|
||
let selector = ""; | ||
if (new_config.plugin === "Datagrid") { | ||
selector = "perspective-viewer-datagrid"; | ||
} else if (new_config.plugin === "Map Scatter") { | ||
selector = "perspective-viewer-openlayers-scatter"; | ||
} else { | ||
const plugin = new_config.plugin | ||
.replace(/[-\/\s]/gi, "") | ||
.toLowerCase(); | ||
selector = `perspective-viewer-d3fc-${plugin}`; | ||
} | ||
|
||
await compareSVGContentsToSnapshot(page, selector, [ | ||
`${idx}-${example.name}.txt`, | ||
]); | ||
}); | ||
} | ||
}); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("docs/template.html"); | ||
await page.evaluate(async () => { | ||
while (!window["__TEST_PERSPECTIVE_READY__"]) { | ||
await new Promise((x) => setTimeout(x, 10)); | ||
} | ||
}); | ||
}); | ||
test("test svgs", async ({ page }) => { | ||
const viewer = new PageView(page); | ||
await viewer.restore({ plugin: "X/Y Scatter" }); | ||
const contents = await getSvgContentString( | ||
"perspective-viewer-d3fc-xyscatter" | ||
)(page); | ||
console.log(contents); | ||
}); |
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
Oops, something went wrong.