Fix Stories navigation, sharing, and voice entry

This commit is contained in:
Manjunath committed 2026-11-16 20:12:10 +05:30
1 parent 5418438339
commit 9e9ce1db22
43 files changed
+744 -137

No files matched your search

+52
View File
@@ -270,6 +270,7 @@ test('voice changes nothing behind Stories while it is open', async () => {
camera: { moveEnd: { addEventListener() {} } },
};
let calls = 0;
let storiesVisible = true;
const styleManager = {
async resetToGlobeView() {
calls += 1;
@@ -280,6 +281,7 @@ test('voice changes nothing behind Stories while it is open', async () => {
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
openStories: () => (storiesVisible ? 'already-open' : true),
});
const classes = new Set(['stories-mode']);
const priorDocument = globalThis.document;
@@ -291,7 +293,16 @@ test('voice changes nothing behind Stories while it is open', async () => {
const refused = await runner('zoom_to_globe');
assert.equal(refused.ok, false);
assert.equal(refused.refused, 'stories-open');
const alreadyOpen = await runner('open_stories');
assert.equal(alreadyOpen.ok, true);
assert.equal(alreadyOpen.applied, false);
assert.equal(calls, 0);
// The input guard still owns the globe while the director settles.
storiesVisible = false;
const reopened = await runner('open_stories');
assert.equal(reopened.ok, true);
assert.equal(reopened.applied, true);
assert.equal((await runner('zoom_to_globe')).refused, 'stories-open');
classes.clear();
await runner('zoom_to_globe');
assert.equal(calls, 1, 'works again once Stories has closed');
@@ -300,6 +311,47 @@ test('voice changes nothing behind Stories while it is open', async () => {
}
});
test('opening Stories only admits current requests and can stop its own session', async () => {
const { viewer, styleManager } = createVoiceNavigationHarness();
const first = new AbortController();
let loaded = Promise.resolve();
let admitted = 0;
let opened = 0;
const runner = createGevActionRunner({
viewer,
styleManager,
dataManager: { layers: new Map(), getAll: () => [] },
async openStories({ isCurrent }) {
admitted += 1;
await loaded;
if (!isCurrent()) return false;
opened += 1;
first.abort();
return true;
},
});
const applied = await runner('open_stories', {}, { signal: first.signal });
assert.equal(applied.ok, true);
assert.equal(applied.applied, true);
const stale = await runner('open_stories', {}, { signal: first.signal });
assert.equal(stale.cancelled, true);
assert.equal(admitted, 1);
let finishLoading;
loaded = new Promise((resolve) => { finishLoading = resolve; });
const second = new AbortController();
const pending = runner('open_stories', {}, { signal: second.signal });
assert.equal(admitted, 2);
second.abort();
finishLoading();
const canceled = await pending;
assert.equal(canceled.cancelled, true);
assert.equal(canceled.applied, false);
assert.equal(opened, 1);
});
test('dependent voice navigation waits for the destination viewport to arrive', async () => {
globalThis.window = globalThis.window || {
clearTimeout,