Show one-source events' pictures and play their clips in the News panel

A feed card shows its event's picture whatever the number of sources, so a
lone Telegram post opening with a video gets its preview; the globe's
picture cards still need two. An event picture may carry its post's clip (an
HTTPS MP4 or WebM file): the card marks it with a play sign, and opened, it
plays with controls and sound, loading nothing before. An expired link drops
the clip.
This commit is contained in:
Denis Groshev committed 2026-11-06 00:45:30 +01:00
1 parent f72f79f48b
commit 74d40c4b1a
7 files changed
+171 -12

No files matched your search

+46
View File
@@ -314,3 +314,49 @@ test('the panel names the window the server serves', () => {
'Last 12 h',
);
});
test('a clip waits behind its picture and plays, on request, in the open card', () => {
const { news, panel } = fixture();
const clipped = report('clip', {
event: {
size: 1,
sides: [],
image: {
url: 'https://cdn4.telesco.pe/file/v.jpg',
publisher: 'Channel',
video: 'https://cdn4.telesco.pe/file/v.mp4?token=x',
},
},
});
news.update(view({ items: [feedCardView(clipped, NOW)] }));
const card = panel.querySelector('.news-card');
assert.equal(card.querySelector('.news-card__play').textContent, '▶');
assert.equal(card.querySelector('video'), null);
news.update(
view({
items: [feedCardView(clipped, NOW)],
selected: feedCardView(clipped, NOW),
}),
);
const video = panel.querySelector('.news-card.is-open video');
assert.equal(
video.getAttribute('src'),
'https://cdn4.telesco.pe/file/v.mp4?token=x',
);
assert.equal(
video.getAttribute('poster'),
'https://cdn4.telesco.pe/file/v.jpg',
);
assert.equal(video.getAttribute('preload'), 'none');
assert.ok(video.hasAttribute('controls'));
// An expired link leaves the card without the clip.
video.dispatchEvent(new Event('error'));
news.update(
view({
items: [feedCardView(clipped, NOW)],
selected: feedCardView(clipped, NOW),
}),
);
assert.equal(panel.querySelector('.news-card.is-open video'), null);
news.destroy();
});