Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ada-x64 committed Feb 28, 2024
1 parent a093f3c commit 6e2fe6b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 49 deletions.
73 changes: 28 additions & 45 deletions packages/perspective-jupyterlab/test/jupyter/widget.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,18 @@ describe_jupyter(
"w",
],
async ({ page }) => {
const viewer = await default_body(page);
const num_columns = await viewer.evaluate(async (viewer) => {
const tbl = viewer
.querySelector("perspective-viewer-datagrid")
.shadowRoot.querySelector("regular-table");
return tbl.querySelector("thead tr").childElementCount;
});
await default_body(page);

expect(num_columns).toEqual(3);
const num_columns = await page
.locator("regular-table thead tr")
.first()
.evaluate((tr) => tr.childElementCount);

const num_rows = await viewer.evaluate(async (viewer) => {
const tbl = viewer
.querySelector("perspective-viewer-datagrid")
.shadowRoot.querySelector("regular-table");
return tbl.querySelectorAll("tbody tr").length;
});
expect(num_columns).toEqual(3);

expect(num_rows).toEqual(5);
await expect(
page.locator("regular-table tbody tr")
).toHaveCount(5);
}
);

Expand All @@ -71,24 +65,17 @@ describe_jupyter(
"table.update(arrow_data)",
],
async ({ page }) => {
const viewer = await default_body(page);
const num_columns = await viewer.evaluate(async (viewer) => {
const tbl = viewer
.querySelector("perspective-viewer-datagrid")
.shadowRoot.querySelector("regular-table");
return tbl.querySelector("thead tr").childElementCount;
});
await default_body(page);
const num_columns = await page
.locator("regular-table thead tr")
.first()
.evaluate((tr) => tr.childElementCount);

expect(num_columns).toEqual(3);

const num_rows = await viewer.evaluate(async (viewer) => {
const tbl = viewer
.querySelector("perspective-viewer-datagrid")
.shadowRoot.querySelector("regular-table");
return tbl.querySelectorAll("tbody tr").length;
});

expect(num_rows).toEqual(10);
await expect(
page.locator("regular-table tbody tr")
).toHaveCount(10);
}
);
test_jupyter(
Expand All @@ -101,25 +88,18 @@ describe_jupyter(
"w",
],
async ({ page }) => {
const viewer = await default_body(page);
const num_columns = await viewer.evaluate(async (viewer) => {
const tbl = viewer
.querySelector("perspective-viewer-datagrid")
.shadowRoot.querySelector("regular-table");
await default_body(page);

return tbl.querySelector("thead tr").childElementCount;
});
const num_columns = await page
.locator("regular-table thead tr")
.first()
.evaluate((tr) => tr.childElementCount);

expect(num_columns).toEqual(3);

const num_rows = await viewer.evaluate(async (viewer) => {
const tbl = viewer
.querySelector("perspective-viewer-datagrid")
.shadowRoot.querySelector("regular-table");
return tbl.querySelectorAll("tbody tr").length;
});

expect(num_rows).toEqual(5);
await expect(
page.locator("regular-table tbody tr")
).toHaveCount(5);
}
);

Expand Down Expand Up @@ -228,6 +208,7 @@ describe_jupyter(
// Check default config
expect(config).toEqual({
version: utils.API_VERSION,
column_config: {},
aggregates: {},
columns: [
"ui8",
Expand Down Expand Up @@ -281,6 +262,7 @@ w.theme = "Pro Dark"`
// and check it
expect(config).toEqual({
version: utils.API_VERSION,
column_config: {},
aggregates: {},
columns: ["ui8"],
expressions: {},
Expand Down Expand Up @@ -315,6 +297,7 @@ w.theme = "Pro Dark"`
// Check default config
expect(config).toEqual({
version: utils.API_VERSION,
column_config: {},
aggregates: {},
columns: [
"ui8",
Expand Down
22 changes: 18 additions & 4 deletions rust/perspective-viewer/test/js/migrate_viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import { test, expect, DEFAULT_CONFIG } from "@finos/perspective-test";
import {
test,
expect,
DEFAULT_CONFIG,
compareSVGContentsToSnapshot,
} from "@finos/perspective-test";
import {
compareContentsToSnapshot,
API_VERSION,
Expand Down Expand Up @@ -384,7 +389,6 @@ const TESTS: [string, any, PerspectiveViewerConfig][] = [
},
{
...MIGRATE_BASE_CONFIG,
version: "2.7.1",
plugin: "Datagrid",
plugin_config: {
columns: {},
Expand Down Expand Up @@ -525,8 +529,18 @@ test.describe("Migrate Viewer", () => {

expect(saved).toEqual(expected);

const contents = await get_contents(page);
await compareContentsToSnapshot(contents, [
let selector;
if (saved.plugin === "Datagrid") {
selector = "perspective-viewer-datagrid";
} else if (saved.plugin === "Map Scatter") {
selector = "perspective-viewer-openlayers-scatter";
} else {
const plugin = saved.plugin
?.replace(/[-\/\s]/gi, "")
.toLowerCase();
selector = `perspective-viewer-d3fc-${plugin}`;
}
await compareSVGContentsToSnapshot(page, selector, [
`migrate-restore-${name}.txt`,
]);
});
Expand Down
Binary file modified tools/perspective-test/results.tar.gz
Binary file not shown.

0 comments on commit 6e2fe6b

Please sign in to comment.