mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Trim the Radio Next/Previous change to the HAL-722 scope
- Selections take the playback fallback as a `playFallback` option and set it after releasing a stale stream, instead of callers arming state that the release then had to save and restore. - Move the tuner `station-unavailable` release and the Pause label while a stream connects out of this branch: both were wrong on main already and go in a separate change. - Share the Radio layer test setup in src/testSupport/radioLayerHarness.mjs and fold overlapping Next/Previous tests (13 to 7). - One-line comments and a two-line changelog entry.
This commit is contained in:
1 parent
fa840ae3c3
commit
a55450e2e7
10 files changed
+172
-340
No files matched your search
+10
-73
@@ -51,6 +51,7 @@ import {
|
||||
radioViewIsGlobal,
|
||||
stationMatchesRadioCategory,
|
||||
} from './radio.js';
|
||||
import { radioStationRow, withRadioLayer } from '../testSupport/radioLayerHarness.mjs';
|
||||
|
||||
const stations = [
|
||||
{ id: 'news', tags: ['News', 'Weather Radio', 'air traffic'] },
|
||||
@@ -883,83 +884,24 @@ test('tuner drag keeps one immutable catalog resolution through refresh and rele
|
||||
});
|
||||
|
||||
test('failed exact tuner release cannot consume a stale playback fallback', async () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
const originalAudio = globalThis.Audio;
|
||||
const playUrls = [];
|
||||
const stationRows = [
|
||||
{
|
||||
radioStationRow({
|
||||
id: '00000000-0000-4000-8000-000000000071',
|
||||
name: 'Exact target',
|
||||
lat: 30,
|
||||
lon: -97,
|
||||
streamUrl: 'https://radio.example.com/exact.mp3',
|
||||
homepage: null,
|
||||
tags: ['news'],
|
||||
languages: ['English'],
|
||||
state: 'Texas',
|
||||
country: 'United States',
|
||||
countryCode: 'US',
|
||||
metadataTrust: 'untrusted-community',
|
||||
codec: 'MP3',
|
||||
bitrate: 128,
|
||||
},
|
||||
{
|
||||
}),
|
||||
radioStationRow({
|
||||
id: '00000000-0000-4000-8000-000000000072',
|
||||
name: 'Stale fallback',
|
||||
lat: 31,
|
||||
lon: -98,
|
||||
streamUrl: 'https://radio.example.com/fallback.mp3',
|
||||
homepage: null,
|
||||
tags: ['news'],
|
||||
languages: ['English'],
|
||||
state: 'Texas',
|
||||
country: 'United States',
|
||||
countryCode: 'US',
|
||||
metadataTrust: 'untrusted-community',
|
||||
codec: 'MP3',
|
||||
bitrate: 128,
|
||||
},
|
||||
}),
|
||||
];
|
||||
globalThis.Audio = class FakeAudio {
|
||||
constructor() {
|
||||
this.volume = 0.8;
|
||||
this.src = '';
|
||||
}
|
||||
|
||||
addEventListener() {}
|
||||
pause() {}
|
||||
play() {
|
||||
playUrls.push(this.src);
|
||||
if (this.src === stationRows[0].streamUrl) {
|
||||
return Promise.reject(new DOMException('Exact target unavailable', 'NotSupportedError'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
removeAttribute() { this.src = ''; }
|
||||
load() {}
|
||||
};
|
||||
globalThis.fetch = async (url) => String(url).startsWith('/api/radio/click/')
|
||||
? { ok: true }
|
||||
: new Response(JSON.stringify({
|
||||
stations: stationRows,
|
||||
stale: false,
|
||||
degraded: false,
|
||||
acceptedGeneration: 1,
|
||||
catalogInstance: 'qa-instance-a',
|
||||
updatedAt: new Date().toISOString(),
|
||||
}), { status: 200, headers: { 'Content-Type': 'application/json' } });
|
||||
const viewer = {
|
||||
camera: { positionWC: { x: 7_000_000, y: 0, z: 0 } },
|
||||
scene: { canvas: { disableRootEvents: true, onwheel: null, addEventListener() {}, removeEventListener() {} } },
|
||||
dataSources: { add() {}, remove() {} },
|
||||
entities: { add(entity) { return entity; }, remove() {} },
|
||||
};
|
||||
|
||||
radioLayer.destroy();
|
||||
try {
|
||||
radioLayer.init(viewer);
|
||||
radioLayer.enable();
|
||||
await radioLayer.update();
|
||||
await withRadioLayer({
|
||||
stations: stationRows,
|
||||
failingUrls: [stationRows[0].streamUrl],
|
||||
}, async ({ playUrls }) => {
|
||||
assert.equal(radioLayer.selectStation(stationRows[0].id, { autoplay: false }), true);
|
||||
assert.equal(radioLayer.cycleStation(1, {
|
||||
stationIds: stationRows.map(({ id }) => id),
|
||||
@@ -976,12 +918,7 @@ test('failed exact tuner release cannot consume a stale playback fallback', asyn
|
||||
assert.equal(state.audioState, 'error');
|
||||
assert.equal(state.tuningStatic, true);
|
||||
assert.equal(state.tuningAwaitingStationId, stationRows[0].id);
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
if (originalAudio === undefined) delete globalThis.Audio;
|
||||
else globalThis.Audio = originalAudio;
|
||||
radioLayer.destroy();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('tuner cancellation restores the frozen start marker after catalog removal', async () => {
|
||||
|
||||
Reference in new issue
Block a user