Skip to content

Commit 86b4c56

Browse files
authored
Merge pull request #3126 from perspective-dev/fix-conflation-test-timeout
Fix view conflation test timeout
2 parents eddeb4c + d25e183 commit 86b4c56

File tree

5 files changed

+56
-10
lines changed

5 files changed

+56
-10
lines changed

rust/perspective-viewer/src/rust/model/intersection_observer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ impl IntersectionObserverHandle {
3838
) -> Self {
3939
clone!(session, renderer, presentation);
4040
let _callback = Closure::new(move |xs: js_sys::Array| {
41+
// https://stackoverflow.com/questions/53862160/intersectionobserver-multiple-entries
4142
let intersect = xs
42-
.get(0)
43+
.pop()
4344
.unchecked_into::<IntersectionObserverEntry>()
4445
.is_intersecting();
4546

@@ -49,6 +50,7 @@ impl IntersectionObserverHandle {
4950
session,
5051
renderer,
5152
};
53+
5254
ApiFuture::spawn(state.set_pause(intersect));
5355
});
5456

rust/perspective-viewer/src/rust/renderer/registry.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,14 @@ pub impl LocalKey<Rc<RefCell<Vec<PluginRecord>>>> {
102102
.unwrap_or_else(|| "Custom".to_owned()),
103103
priority: plugin_inst.priority().unwrap_or_default(),
104104
};
105+
105106
let mut plugins = plugin.borrow_mut();
107+
if let Some(first) = plugins.first()
108+
&& first.tag_name.as_str() == "perspective-viewer-plugin"
109+
{
110+
plugins.clear();
111+
}
112+
106113
plugins.push(record);
107114
plugins.sort_by(|a, b| Ord::cmp(&b.priority, &a.priority));
108115
});
@@ -121,7 +128,7 @@ fn register_default() {
121128
name: "Debug".to_owned(),
122129
category: "Custom".to_owned(),
123130
tag_name: "perspective-viewer-plugin".to_owned(),
124-
priority: 0,
131+
priority: -1,
125132
})
126133
}
127134
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<script type="module" src="/node_modules/@perspective-dev/viewer/dist/cdn/perspective-viewer.js"></script>
5+
<script type="module" src="/node_modules/@perspective-dev/test/load-viewer.js"></script>
6+
<link rel="stylesheet" href="../css/demo.css" />
7+
<link rel="stylesheet" href="/node_modules/@perspective-dev/viewer/dist/css/pro.css" />
8+
<link rel="stylesheet" href="/node_modules/@fontsource/roboto-mono/400.css" />
9+
</head>
10+
<body></body>
11+
</html>

rust/perspective-viewer/test/js/viewnotfound.spec.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import { test, expect } from "@perspective-dev/test";
1414

1515
test("View conflation is silenced", async ({ page }) => {
16-
await page.goto("/rust/perspective-viewer/test/html/superstore.html");
16+
await page.goto(
17+
"/rust/perspective-viewer/test/html/superstore_lazy_viewer.html",
18+
);
19+
1720
await page.evaluate(async () => {
1821
while (!window["__TEST_PERSPECTIVE_READY__"]) {
1922
await new Promise((x) => setTimeout(x, 10));
@@ -53,30 +56,31 @@ test("View conflation is silenced", async ({ page }) => {
5356

5457
customElements.define("pause-plugin", PausePlugin);
5558
const Viewer = customElements.get("perspective-viewer");
56-
await Viewer.registerPlugin("pause-plugin");
59+
Viewer.registerPlugin("pause-plugin");
5760

5861
// use a new viewer because only new viewers get loaded with the registered plugin
5962
const viewer = document.createElement("perspective-viewer");
6063
document.body.append(viewer);
61-
const table = worker.table("a,b,c\n1,2,3", { name: "A" });
64+
worker.table("a,b,c\n1,2,3", { name: "A" });
6265

63-
await viewer.load(table);
64-
await viewer.restore({ plugin: "pause-plugin" });
66+
await viewer.load(worker);
67+
await viewer.restore({ table: "A", plugin: "pause-plugin" });
6568
is_paused = true;
6669

6770
// Change in 4.1.0 - empty restore now does not render
68-
const restore_task = viewer.restore({ plugin: "pause-plugin" });
71+
const restore_task = viewer.restore({
72+
plugin: "pause-plugin",
73+
});
74+
6975
while (!resolve) {
7076
await new Promise((x) => setTimeout(x, 0));
7177
}
7278

73-
const load_task = viewer.load(table);
7479
await new Promise((x) => setTimeout(x, 0));
7580
resolve();
7681
resolve = undefined;
7782
is_paused = false;
7883
await restore_task;
79-
await load_task;
8084
});
8185

8286
expect(vnf).toBeFalsy();

tools/test/load-viewer.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2+
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3+
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4+
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5+
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6+
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7+
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
8+
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9+
// ┃ This file is part of the Perspective library, distributed under the terms ┃
10+
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12+
13+
import "/node_modules/@perspective-dev/viewer/dist/cdn/perspective-viewer.js";
14+
import perspective from "/node_modules/@perspective-dev/client/dist/cdn/perspective.js";
15+
16+
async function load() {
17+
const worker = await perspective.worker();
18+
window.__TEST_WORKER__ = worker;
19+
}
20+
21+
await load();
22+
window.__TEST_PERSPECTIVE_READY__ = true;

0 commit comments

Comments
 (0)