Release v2.10.6
This commit is contained in:
@@ -149,6 +149,125 @@ test('playlist refresh queues updates until the next slide transition', async ()
|
||||
assert.equal(calls.logDebug.some((entry) => entry.includes('applying on next slide transition')), true);
|
||||
});
|
||||
|
||||
test('playlist refresh reloads source data after a cached snapshot receives 304', async () => {
|
||||
const requests = [];
|
||||
const sandbox = {
|
||||
window: null,
|
||||
location: { origin: 'http://localhost' },
|
||||
Date,
|
||||
JSON,
|
||||
Math,
|
||||
Number,
|
||||
String,
|
||||
Boolean,
|
||||
Array,
|
||||
Object,
|
||||
Promise,
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
console,
|
||||
slug: 'test',
|
||||
initialData: null,
|
||||
currentPlaylistEtag: '"cached-etag"',
|
||||
currentPlaylistSignature: 'cached-signature',
|
||||
currentPlaylistFadeBetweenSlides: false,
|
||||
currentPlaylistSkipUnavailableRtmp: false,
|
||||
pendingPlaylistUpdate: null,
|
||||
slides: [{ id: 1, duration_seconds: 10 }],
|
||||
lastRenderedSlide: null,
|
||||
activeSlidesCacheKey: '',
|
||||
activeSlidesCacheValue: [],
|
||||
slideMarkupCache: Object.create(null),
|
||||
templateLayoutCache: Object.create(null),
|
||||
templateRenderPlanCache: Object.create(null),
|
||||
getCurrentActiveSlides() { return sandbox.slides; },
|
||||
getPlaylistRevision(data) { return data.signature; },
|
||||
normalizeSlide(slide) { return slide; },
|
||||
getActiveSlidesFrom(slideList) { return slideList; },
|
||||
savePlaylistSnapshot() {},
|
||||
markRefreshHealthy() {},
|
||||
setOfflineBannerVisible() {},
|
||||
scheduleRefreshRetry() {},
|
||||
syncWebpagePreloads() {},
|
||||
syncRtmpWarmups() {},
|
||||
showCurrent() {},
|
||||
sendCommandState() {},
|
||||
scheduleSlideAdvance() {},
|
||||
logDebug() {}
|
||||
};
|
||||
sandbox.window = sandbox;
|
||||
|
||||
class XhrStub {
|
||||
open(method, url) {
|
||||
this.method = method;
|
||||
this.url = url;
|
||||
requests.push(this);
|
||||
}
|
||||
|
||||
setRequestHeader(name, value) {
|
||||
this.headers = this.headers || {};
|
||||
this.headers[name] = value;
|
||||
}
|
||||
|
||||
getResponseHeader() { return ''; }
|
||||
|
||||
send() {
|
||||
this.readyState = 4;
|
||||
if (requests.length === 1) {
|
||||
this.status = 304;
|
||||
this.responseText = '';
|
||||
} else {
|
||||
this.status = 200;
|
||||
this.responseText = JSON.stringify({
|
||||
signature: 'fresh-signature',
|
||||
slides: [{ id: 1, duration_seconds: 10 }],
|
||||
rssFeeds: [],
|
||||
apiSources: [{ id: 1 }],
|
||||
timetableGroups: [],
|
||||
weatherLocations: [{ id: 1 }],
|
||||
playlist: { fade_between_slides: false, skip_unavailable_rtmp: false }
|
||||
});
|
||||
}
|
||||
this.onreadystatechange();
|
||||
}
|
||||
}
|
||||
|
||||
sandbox.XMLHttpRequest = XhrStub;
|
||||
const scriptPath = path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-playback.js');
|
||||
vm.runInNewContext(fs.readFileSync(scriptPath, 'utf8'), sandbox, { filename: scriptPath });
|
||||
|
||||
await sandbox.refresh();
|
||||
|
||||
assert.equal(requests.length, 2);
|
||||
assert.equal(requests[1].headers && requests[1].headers['If-None-Match'], undefined);
|
||||
assert.deepEqual(sandbox.initialData.apiSources, [{ id: 1 }]);
|
||||
assert.deepEqual(sandbox.initialData.weatherLocations, [{ id: 1 }]);
|
||||
});
|
||||
|
||||
test('centralized slide advance timing preserves the configured slide duration', () => {
|
||||
const sandbox = {
|
||||
window: null,
|
||||
currentPlaylistFadeBetweenSlides: false,
|
||||
slideFadeLengthMs: 560,
|
||||
slideFadeOffsetMs: 280,
|
||||
getSlideHoldDelay(value) {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
sandbox.window = sandbox;
|
||||
|
||||
const scriptPath = path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-playback.js');
|
||||
const script = fs.readFileSync(scriptPath, 'utf8');
|
||||
vm.runInNewContext(script, sandbox, { filename: scriptPath });
|
||||
|
||||
assert.equal(sandbox.getSlideAdvanceDelay({ duration_seconds: 12 }), 12000);
|
||||
sandbox.currentPlaylistFadeBetweenSlides = true;
|
||||
assert.equal(sandbox.getSlideAdvanceDelay({ duration_seconds: 10 }), 9720);
|
||||
assert.equal(sandbox.getSlideAdvanceDelay({ duration_seconds: 10, use_video_duration: true }), 9440);
|
||||
assert.equal(sandbox.getSlideAdvanceDelay({ duration_seconds: 12 }), 11720);
|
||||
assert.equal(sandbox.getSlideAdvanceDelay({ duration_seconds: 12, use_video_duration: true }), 11440);
|
||||
});
|
||||
|
||||
test('single-slide playlists re-render the active slide instead of refreshing after a queued update', async () => {
|
||||
const calls = {
|
||||
showCurrent: 0,
|
||||
@@ -247,8 +366,10 @@ test('single-slide playlists re-render the active slide instead of refreshing af
|
||||
sandbox.XMLHttpRequest = XhrStub;
|
||||
|
||||
const scriptPath = path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-playback.js');
|
||||
const transitionPath = path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-transition.js');
|
||||
const commandsPath = path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-commands.js');
|
||||
const playbackScript = fs.readFileSync(scriptPath, 'utf8');
|
||||
const transitionScript = fs.readFileSync(transitionPath, 'utf8');
|
||||
const commandsScript = fs.readFileSync(commandsPath, 'utf8');
|
||||
const prelude = `
|
||||
var pendingPlaylistUpdate = null;
|
||||
@@ -270,7 +391,7 @@ test('single-slide playlists re-render the active slide instead of refreshing af
|
||||
var templateLayoutCache = Object.create(null);
|
||||
var templateRenderPlanCache = Object.create(null);
|
||||
`;
|
||||
vm.runInNewContext(prelude + '\n' + playbackScript + '\n' + commandsScript, sandbox, { filename: scriptPath });
|
||||
vm.runInNewContext(prelude + '\n' + transitionScript + '\n' + playbackScript + '\n' + commandsScript, sandbox, { filename: scriptPath });
|
||||
sandbox.showCurrent = function () {
|
||||
calls.showCurrent += 1;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user