mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-23 00:11:28 -07:00
test: address latest review feedback
This commit is contained in:
@@ -90,6 +90,16 @@ test('resolveMediaArtworkUrl prefers youtube thumbnails for video and channel im
|
||||
assert.equal(resolveMediaArtworkUrl(localVideo, 'channel'), null);
|
||||
});
|
||||
|
||||
test('resolveMediaArtworkUrl normalizes blank thumbnail urls to null', () => {
|
||||
const item = {
|
||||
videoThumbnailUrl: ' ',
|
||||
channelThumbnailUrl: '',
|
||||
};
|
||||
|
||||
assert.equal(resolveMediaArtworkUrl(item, 'video'), null);
|
||||
assert.equal(resolveMediaArtworkUrl(item, 'channel'), null);
|
||||
});
|
||||
|
||||
test('summarizeMediaLibraryGroups stays aligned with rendered group buckets', () => {
|
||||
const groups = groupMediaLibraryItems([youtubeEpisodeA, localVideo, youtubeEpisodeB]);
|
||||
const summary = summarizeMediaLibraryGroups(groups);
|
||||
@@ -100,6 +110,24 @@ test('summarizeMediaLibraryGroups stays aligned with rendered group buckets', ()
|
||||
});
|
||||
});
|
||||
|
||||
test('groupMediaLibraryItems backfills missing group artwork from later items', () => {
|
||||
const first = {
|
||||
...youtubeEpisodeA,
|
||||
videoId: 10,
|
||||
videoThumbnailUrl: null,
|
||||
channelThumbnailUrl: null,
|
||||
};
|
||||
const second = {
|
||||
...youtubeEpisodeB,
|
||||
videoId: 11,
|
||||
channelThumbnailUrl: null,
|
||||
};
|
||||
|
||||
const groups = groupMediaLibraryItems([first, second]);
|
||||
|
||||
assert.equal(groups[0]?.imageUrl, second.videoThumbnailUrl);
|
||||
});
|
||||
|
||||
test('CoverImage renders explicit remote artwork when src is provided', () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<CoverImage
|
||||
|
||||
@@ -17,10 +17,9 @@ export function resolveMediaArtworkUrl(
|
||||
item: Pick<MediaLibraryItem, 'videoThumbnailUrl' | 'channelThumbnailUrl'>,
|
||||
kind: 'video' | 'channel',
|
||||
): string | null {
|
||||
if (kind === 'channel') {
|
||||
return item.channelThumbnailUrl ?? null;
|
||||
}
|
||||
return item.videoThumbnailUrl ?? null;
|
||||
const raw = kind === 'channel' ? item.channelThumbnailUrl : item.videoThumbnailUrl;
|
||||
const normalized = raw?.trim() ?? '';
|
||||
return normalized.length > 0 ? normalized : null;
|
||||
}
|
||||
|
||||
export function resolveMediaCoverApiUrl(videoId: number): string {
|
||||
@@ -61,6 +60,10 @@ export function groupMediaLibraryItems(items: MediaLibraryItem[]): MediaLibraryG
|
||||
existing.totalActiveMs += item.totalActiveMs;
|
||||
existing.totalCards += item.totalCards;
|
||||
existing.lastWatchedMs = Math.max(existing.lastWatchedMs, item.lastWatchedMs);
|
||||
if (!existing.imageUrl) {
|
||||
existing.imageUrl =
|
||||
resolveMediaArtworkUrl(item, 'channel') ?? resolveMediaArtworkUrl(item, 'video');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user