mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Address samehkhamis's review on #1113: - show_street_level checks the turn, the camera's owner (navigation stamp, re-taken where its own flight lands, or a press/wheel on the globe) and the hiding modes after the flight, the map switch, the layer switch-on and the lookup; a photo that opened after either is closed again. The hidden panel is also refused before the flight. - An open photo closes before a new request arms or looks up, so a place with no imagery shows its own error. - The panel posts every view with `fresh`; the inline app opens a billed photo only for a fresh one. - A passed-through view's street_level point moves with a new camera position; revealPanel does nothing above 720px, scrolling included. - Document that the app's own links do not carry `sl`.
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import assert from 'node:assert/strict';
|
||
import test from 'node:test';
|
||
import { StyleManager } from './applicationShell.js';
|
||
|
||
function reveal({ phone }) {
|
||
const sheets = [];
|
||
const scrolls = [];
|
||
const panel = { scrollIntoView: (options) => scrolls.push(options) };
|
||
const saved = globalThis.document;
|
||
const savedMatchMedia = globalThis.matchMedia;
|
||
globalThis.document = {
|
||
getElementById: (id) => (id === 'street-level-panel' ? panel : null),
|
||
};
|
||
globalThis.matchMedia = (query) => ({
|
||
matches: phone && query === '(max-width: 720px)',
|
||
});
|
||
try {
|
||
StyleManager.prototype.revealPanel.call(
|
||
{ _mobileShell: { setSheet: (sheet) => sheets.push(sheet) } },
|
||
'street-level-panel',
|
||
);
|
||
} finally {
|
||
globalThis.document = saved;
|
||
globalThis.matchMedia = savedMatchMedia;
|
||
}
|
||
return { sheets, scrolls };
|
||
}
|
||
|
||
test('revealing a panel opens its phone sheet and scrolls the panel into view', () => {
|
||
const { sheets, scrolls } = reveal({ phone: true });
|
||
assert.deepEqual(sheets, ['cameras']);
|
||
// The panel sits below the sheet's first screen at 375×812.
|
||
assert.deepEqual(scrolls, [{ block: 'nearest' }]);
|
||
});
|
||
|
||
test('revealing a panel above 720px neither opens a sheet nor scrolls the rail', () => {
|
||
assert.deepEqual(reveal({ phone: false }), { sheets: [], scrolls: [] });
|
||
});
|