Release v2.15.2
This commit is contained in:
1 parent
ddcc665f81
commit
7295f83f04
43 files changed
+2526
-104
No files matched your search
@@ -46,6 +46,99 @@ test('media preload cleanup releases unpromoted video elements on every early ex
|
||||
}
|
||||
});
|
||||
|
||||
test('playlist groups rotate in order, fill every pass, and optionally shuffle', () => {
|
||||
const sandbox = {
|
||||
window: { pulsePlayerRenderingShared: new Proxy({}, { get() { return function () {}; } }) },
|
||||
playlistPassNumber: 0
|
||||
};
|
||||
const renderingScriptPath = path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-rendering.js');
|
||||
const playlistScriptPath = path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-playlist.js');
|
||||
loadScript(renderingScriptPath, sandbox);
|
||||
loadScript(playlistScriptPath, sandbox);
|
||||
|
||||
const groupSlides = Array.from({ length: 5 }, function (_value, index) {
|
||||
return { id: index + 1, groupKey: 'news', groupPickCount: 2 };
|
||||
});
|
||||
sandbox.slides = groupSlides.concat([{ id: 99 }]);
|
||||
|
||||
function selectedGroupIds() {
|
||||
return Array.from(sandbox.getActiveSlidesFrom(sandbox.slides)
|
||||
.filter(function (slide) { return slide.groupKey; })
|
||||
.map(function (slide) { return slide.id; }));
|
||||
}
|
||||
|
||||
const firstPass = selectedGroupIds();
|
||||
assert.equal(firstPass.length, 2);
|
||||
assert.deepEqual(selectedGroupIds(), firstPass);
|
||||
sandbox.playlistPassNumber = 1;
|
||||
const secondPass = selectedGroupIds();
|
||||
assert.equal(secondPass.length, 2);
|
||||
assert.equal(firstPass.some(function (id) { return secondPass.includes(id); }), false);
|
||||
sandbox.playlistPassNumber = 2;
|
||||
const thirdPass = selectedGroupIds();
|
||||
assert.equal(thirdPass.length, 2);
|
||||
assert.equal(new Set(firstPass.concat(secondPass, thirdPass)).size, 5);
|
||||
assert.deepEqual(firstPass, [1, 2]);
|
||||
assert.deepEqual(secondPass, [3, 4]);
|
||||
assert.deepEqual(thirdPass, [5, 1]);
|
||||
groupSlides.forEach(slide => { slide.groupShuffle = true; });
|
||||
const shuffled = selectedGroupIds();
|
||||
assert.equal(shuffled.length, 2);
|
||||
assert.equal(new Set(shuffled).size, 2);
|
||||
assert.deepEqual(selectedGroupIds(), shuffled);
|
||||
const selections = new Set();
|
||||
for (let pass = 0; pass < 10; pass += 1) {
|
||||
sandbox.playlistPassNumber = pass;
|
||||
const selection = selectedGroupIds();
|
||||
assert.equal(selection.length, 2);
|
||||
assert.equal(new Set(selection).size, 2);
|
||||
selections.add(selection.join(','));
|
||||
}
|
||||
assert.ok(selections.size > 1);
|
||||
sandbox.slides = groupSlides.slice(0, 3);
|
||||
sandbox.slides.forEach(slide => { slide.groupShuffle = false; });
|
||||
for (const [pass, expected] of [[0, [1, 2]], [1, [3, 1]], [2, [2, 3]]]) {
|
||||
sandbox.playlistPassNumber = pass;
|
||||
assert.deepEqual(selectedGroupIds(), expected);
|
||||
}
|
||||
sandbox.slides[0].scheduleRules = [{ start_datetime: '2000-01-01T00:00:00Z', end_datetime: '2000-01-02T00:00:00Z' }];
|
||||
assert.deepEqual(selectedGroupIds(), [2, 3]);
|
||||
sandbox.slides[1].groupPickCount = 99;
|
||||
assert.equal(selectedGroupIds().length, 2);
|
||||
sandbox.slides[2].scheduleRules = sandbox.slides[0].scheduleRules;
|
||||
assert.deepEqual(selectedGroupIds(), [2]);
|
||||
|
||||
const now = new Date(2026, 9, 14, 10, 30);
|
||||
const gatedSlide = {
|
||||
groupKey: 'weekday',
|
||||
groupScheduleRules: [{ start_time: '10:00', end_time: '11:00', days: [now.getDay()] }]
|
||||
};
|
||||
assert.equal(sandbox.isSlideActive(gatedSlide, now), true);
|
||||
assert.equal(sandbox.isSlideActive(gatedSlide, new Date(2026, 9, 14, 12, 30)), false);
|
||||
assert.equal(sandbox.isSlideActive(gatedSlide, new Date(2026, 9, 15, 10, 30)), false);
|
||||
});
|
||||
|
||||
test('repeat groups play all eligible members in order and ignore Pick and shuffle', () => {
|
||||
const sandbox = {
|
||||
window: { pulsePlayerRenderingShared: new Proxy({}, { get() { return function () {}; } }) },
|
||||
playlistPassNumber: 0
|
||||
};
|
||||
loadScript(path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-rendering.js'), sandbox);
|
||||
loadScript(path.join(__dirname, '..', 'src', 'player', 'public', 'js', 'player-page-playlist.js'), sandbox);
|
||||
sandbox.slides = [{ id: 9 }].concat([1, 2, 3].map(id => ({
|
||||
id, groupKey: 'news', groupMode: 'repeat', groupRepeatCount: 2, groupPickCount: 1, groupShuffle: true
|
||||
})), [{ id: 10 }]);
|
||||
const ids = () => Array.from(sandbox.getActiveSlidesFrom(sandbox.slides), slide => slide.id);
|
||||
assert.deepEqual(ids(), [9, 1, 2, 3, 1, 2, 3, 10]);
|
||||
sandbox.playlistPassNumber = 1;
|
||||
assert.deepEqual(ids(), [9, 1, 2, 3, 1, 2, 3, 10]);
|
||||
assert.equal(sandbox.hasSelectableGroupVariants(), false);
|
||||
sandbox.slides[2].scheduleRules = [{ start_datetime: '2000-01-01T00:00:00Z', end_datetime: '2000-01-02T00:00:00Z' }];
|
||||
assert.deepEqual(ids(), [9, 1, 3, 1, 3, 10]);
|
||||
sandbox.slides.forEach(slide => { if (slide.groupKey) slide.groupRepeatCount = 1; });
|
||||
assert.deepEqual(ids(), [9, 1, 3, 10]);
|
||||
});
|
||||
|
||||
test('warmed video node is promoted into its slide instead of fetched again', () => {
|
||||
const createdVideos = [];
|
||||
let nextSource = '';
|
||||
|
||||
Reference in new issue
Block a user