mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
The guided walk finds its elements in the rendered tree
Template refs are filled after a render returns, and later still when the walk starts inside one of Vue's own post-render updates, where the walk would have failed with its listeners already in place. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
10a26e15ce
commit
4a6f185d07
3 files changed
+35
-15
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createApp, h, onMounted } from 'vue';
|
||||
import { startGuide } from './omnibarGuide.js';
|
||||
|
||||
const settle = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
@@ -109,3 +110,27 @@ test('starting another walk ends the one in progress', async (t) => {
|
||||
assert.equal(document.querySelectorAll('.gev-guide').length, 1);
|
||||
assert.equal($('.gev-guide-text').textContent, 'Second');
|
||||
});
|
||||
|
||||
test('a walk started while Vue mounts something else still starts and ends', async (t) => {
|
||||
const { target, field } = fixture(t);
|
||||
let stop = null;
|
||||
const app = createApp({
|
||||
setup() {
|
||||
onMounted(() => {
|
||||
stop = startGuide([
|
||||
{ targets: () => [target], text: () => 'Press it' },
|
||||
]);
|
||||
});
|
||||
return () => h('span');
|
||||
},
|
||||
});
|
||||
app.mount(document.body.appendChild(document.createElement('div')));
|
||||
t.after(() => app.unmount());
|
||||
await settle();
|
||||
assert.equal(typeof stop, 'function');
|
||||
assert.equal(document.activeElement, $('.gev-guide-callout'));
|
||||
assert.ok($('.gev-guide').classList.contains('visible'));
|
||||
stop();
|
||||
assert.equal($('.gev-guide'), null);
|
||||
assert.equal(document.activeElement, field);
|
||||
});
|
||||
Reference in new issue
Block a user