mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
* fix: re-sync globe map on fullscreen transitions * fix: call resize() instead of render() and anchor test regex resize() propagates to MapLibre canvas resize in DeckGL mode, fixing stale canvas dimensions after fullscreen transitions. Anchor test regex to setupMapFullscreen to avoid matching the wrong toggle block. --------- Co-authored-by: Elie Habib <elie.habib@gmail.com>
31 lines
1.5 KiB
JavaScript
31 lines
1.5 KiB
JavaScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import { dirname, join, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = resolve(__dirname, '..');
|
|
const src = readFileSync(join(root, 'src', 'app', 'event-handlers.ts'), 'utf-8');
|
|
|
|
describe('map fullscreen resize sync', () => {
|
|
it('defines a shared layout-sync helper that calls resize()', () => {
|
|
assert.match(src, /private syncMapAfterLayoutChange\(delayMs = 320\): void \{/);
|
|
assert.match(src, /this\.ctx\.map\?\.resize\(\)/);
|
|
assert.match(src, /requestAnimationFrame\(sync\)/);
|
|
assert.match(src, /window\.setTimeout\(sync, delayMs\)/);
|
|
});
|
|
|
|
it('re-syncs the map after browser fullscreen changes', () => {
|
|
const fullscreenHandlerBlock = src.match(/this\.boundFullscreenHandler = \(\) => \{([\s\S]*?)\n\s*\};/);
|
|
assert.ok(fullscreenHandlerBlock, 'Expected fullscreenchange handler block');
|
|
assert.match(fullscreenHandlerBlock[1], /this\.syncMapAfterLayoutChange\(\)/);
|
|
});
|
|
|
|
it('re-syncs the map after map-panel fullscreen toggles', () => {
|
|
const mapFullscreenBlock = src.match(/setupMapFullscreen[\s\S]*?const toggle = \(\) => \{([\s\S]*?)\n\s*\};/);
|
|
assert.ok(mapFullscreenBlock, 'Expected map fullscreen toggle block inside setupMapFullscreen');
|
|
assert.match(mapFullscreenBlock[1], /this\.syncMapAfterLayoutChange\(\)/);
|
|
});
|
|
});
|