mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
- KML/KMZ import: a per-file canvas budget and cache for ground overlays, limits on rings and vertices of raised polygons, overlays across 360° and near the poles, degenerate holes, polar and single-latitude fills, absolute overlays at their altitude, overlay order by drawOrder as on Cesium, and pins on tiles keep their measured height. - Points on the surface: OSM Places and Street Level cones share the surface sampler and sit on the terrain before they are measured, within a sampling budget per pass; Cockpit's contact-dot bank keeps the dot atlas, and a failed fleet model loads again after a pause. - Startup: the loading screen lifts after the share-link view is restored, the retry screen names the failed engine and takes focus, and the fallback toast stays for 6 s. - Engines: an engine switch lands a running camera flight at its destination (camera.completeFlight on both engines), the sighting card leaves focus on the engine picker after a switch, and a Cesium model error stays with the instance that failed. - The MCP panel builds again: its wind-mesh alias resolves to the stub. - QA: the wildlife switch waits for the camera to rest, GBFS --w2 says it needs the dev server, and test fixtures are shared instead of copied.
100 lines
3.9 KiB
JavaScript
100 lines
3.9 KiB
JavaScript
// src/ui/toastView.test.mjs — the page toast renders what its owners'
|
|
// createToast() publish, each owner on its own timer.
|
|
import '../testSupport/registerDom.mjs';
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { createApp, nextTick } from 'vue';
|
|
import { createPinia } from 'pinia';
|
|
import { useStatusStore } from './stores/status.js';
|
|
import { createToast } from './toast.js';
|
|
import { ShellFeedback } from './shellFeedback.js';
|
|
import { ShellFacade } from './shellFacade.js';
|
|
import SceneChromeView from './views/SceneChromeView.vue';
|
|
|
|
function fixture(t) {
|
|
t.mock.timers.enable({ apis: ['setTimeout'] });
|
|
document.body.replaceChildren();
|
|
const pinia = createPinia();
|
|
const app = createApp(SceneChromeView).use(pinia);
|
|
app.mount(document.body.appendChild(document.createElement('div')));
|
|
t.after(() => app.unmount());
|
|
const store = useStatusStore(pinia);
|
|
const toast = () => document.getElementById('toast');
|
|
return { store, toast };
|
|
}
|
|
|
|
test('a toast shows its message, then fades out keeping its text', async (t) => {
|
|
const { store, toast } = fixture(t);
|
|
assert.equal(toast().textContent, '');
|
|
assert.equal(toast().classList.contains('visible'), false);
|
|
const owner = createToast({ durationMs: 2000, store });
|
|
owner.show('Link copied');
|
|
await nextTick();
|
|
assert.equal(toast().textContent, 'Link copied');
|
|
assert.equal(toast().classList.contains('visible'), true);
|
|
assert.equal(toast().getAttribute('role'), 'status');
|
|
t.mock.timers.tick(1999);
|
|
await nextTick();
|
|
assert.equal(toast().classList.contains('visible'), true);
|
|
t.mock.timers.tick(1);
|
|
await nextTick();
|
|
assert.equal(toast().classList.contains('visible'), false);
|
|
assert.equal(toast().textContent, 'Link copied');
|
|
});
|
|
|
|
test('a newer toast restarts the time, and another owner hides it on its own time', async (t) => {
|
|
const { store, toast } = fixture(t);
|
|
const shell = createToast({ durationMs: 2000, store });
|
|
const scenes = createToast({ durationMs: 2600, store });
|
|
scenes.show('Scene not saved');
|
|
t.mock.timers.tick(1000);
|
|
shell.show('Saved');
|
|
t.mock.timers.tick(1600);
|
|
await nextTick();
|
|
assert.equal(toast().textContent, 'Saved');
|
|
assert.equal(toast().classList.contains('visible'), false);
|
|
shell.show('Again');
|
|
scenes.cancel();
|
|
shell.hide();
|
|
await nextTick();
|
|
assert.equal(toast().classList.contains('visible'), false);
|
|
assert.equal(toast().textContent, 'Again');
|
|
t.mock.timers.tick(5000);
|
|
assert.equal(store.toast.text, 'Again');
|
|
assert.equal(store.toast.visible, false);
|
|
});
|
|
|
|
test('a repeated message is written again so the live region announces it', async (t) => {
|
|
const { store, toast } = fixture(t);
|
|
const owner = createToast({ durationMs: 2000, store });
|
|
owner.show('Fly to a POI first');
|
|
await nextTick();
|
|
const first = toast().firstChild;
|
|
t.mock.timers.tick(2000);
|
|
await nextTick();
|
|
assert.ok(toast().firstChild === first, 'fading out leaves the text alone');
|
|
owner.show('Fly to a POI first');
|
|
await nextTick();
|
|
assert.equal(toast().textContent, 'Fly to a POI first');
|
|
assert.ok(toast().firstChild !== first, 'the repeat is a new text node');
|
|
assert.equal(toast().classList.contains('visible'), true);
|
|
});
|
|
|
|
test('an engine failure can stay readable longer than an ordinary shell toast', async (t) => {
|
|
const { store, toast } = fixture(t);
|
|
const feedback = new ShellFeedback({ readLayers: () => [], store });
|
|
t.after(() => feedback.destroy());
|
|
const shell = { _feedback: feedback };
|
|
ShellFacade.prototype._showToast.call(shell, 'Engine failed', 6000);
|
|
t.mock.timers.tick(2000);
|
|
await nextTick();
|
|
assert.equal(toast().classList.contains('visible'), true);
|
|
t.mock.timers.tick(4000);
|
|
await nextTick();
|
|
assert.equal(toast().classList.contains('visible'), false);
|
|
ShellFacade.prototype._showToast.call(shell, 'Link copied');
|
|
t.mock.timers.tick(2000);
|
|
await nextTick();
|
|
assert.equal(toast().classList.contains('visible'), false);
|
|
});
|