mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 02:02:21 +00:00
The logo in the title was only a picture. It is now a button, "Back to live at the starting view": the world clock goes live and the camera flies to the view the app started from, letting go of whatever it follows as Reset Globe does. The shell's returnToStart() does it. It flies to the `homeView` option of createApplicationControls, which is the start view unless given: an application that passes `startView` only to carry a view across a rebuild can keep the logo on its own first view. START_VIEW is exported from ./application/controls for that. The title heading keeps "GOD'S EYE VIEW" as its name beside the button.
83 lines
3.3 KiB
JavaScript
83 lines
3.3 KiB
JavaScript
// src/ui/frameRateView.test.mjs — the title bar's FPS readout renders what
|
||
// createFrameRateMonitor() publishes and toggles with the backquote key.
|
||
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 { createFrameRateMonitor } from './frameRateMonitor.js';
|
||
import SceneChromeView from './views/SceneChromeView.vue';
|
||
import { bindRenderer } from '../render/rendererOf.js';
|
||
import { fakeSceneFrame } from '../testSupport/fakeCesiumScene.mjs';
|
||
|
||
test('the FPS readout sits in the title bar, hidden until the backquote key', async (t) => {
|
||
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 readout = () =>
|
||
document.querySelector('#title-bar .frame-rate-readout');
|
||
assert.equal(readout(), null, 'no readout without a monitor');
|
||
const viewer = {
|
||
scene: { postRender: { addEventListener: () => () => {} } },
|
||
};
|
||
bindRenderer(viewer, { frame: fakeSceneFrame(viewer) });
|
||
const monitor = createFrameRateMonitor({
|
||
viewer,
|
||
store: useStatusStore(pinia),
|
||
});
|
||
t.after(() => monitor.destroy());
|
||
await nextTick();
|
||
const element = readout();
|
||
assert.ok(element.previousElementSibling.classList.contains('subtitle'));
|
||
assert.ok(element.classList.contains('scene-text-holdout'));
|
||
assert.equal(element.hidden, true);
|
||
assert.equal(element.textContent, 'FPS —');
|
||
assert.equal(
|
||
element.title,
|
||
'Rendered globe frames per second · toggle with `',
|
||
);
|
||
document.dispatchEvent(
|
||
new KeyboardEvent('keydown', { key: '`', bubbles: true, cancelable: true }),
|
||
);
|
||
await nextTick();
|
||
assert.equal(readout().hidden, false);
|
||
monitor.destroy();
|
||
await nextTick();
|
||
assert.equal(readout(), null);
|
||
});
|
||
|
||
test('the title logo is a button that asks for the way back to live at the start view', async (t) => {
|
||
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 { useGlobeActionsStore } = await import('./stores/globeActions.js');
|
||
const calls = [];
|
||
useGlobeActionsStore(pinia).connect({ home: () => calls.push('home') });
|
||
const logo = document.querySelector('#title-bar h1 > button.title-logo');
|
||
assert.ok(logo, 'the logo is the title heading’s button');
|
||
assert.equal(
|
||
logo.getAttribute('aria-label'),
|
||
'Back to live at the starting view',
|
||
);
|
||
assert.ok(logo.hasAttribute('data-logo-gaze'));
|
||
logo.click();
|
||
assert.deepEqual(calls, ['home']);
|
||
});
|
||
|
||
test('the title heading keeps its own name beside the logo button', async (t) => {
|
||
document.body.replaceChildren();
|
||
const app = createApp(SceneChromeView).use(createPinia());
|
||
app.mount(document.body.appendChild(document.createElement('div')));
|
||
t.after(() => app.unmount());
|
||
const heading = document.querySelector('#title-bar h1');
|
||
const named = document.getElementById(
|
||
heading.getAttribute('aria-labelledby'),
|
||
);
|
||
assert.equal(named.textContent.replace(/\s+/g, ' ').trim(), "GOD'S EYE VIEW");
|
||
});
|