Files
iptvnator/libs/shared/interfaces/src/lib/provider-overview.util.spec.ts
T
4grayandClaude Fable 5 92be39ef66 fix(xtream): drop URL-only season overviews and fall back to TMDB (#1382)
Xtream panels routinely fill get_series_info seasons[].overview with a
bare cover-image URL, which rendered verbatim under the season tabs.
URL-only overviews are now treated as absent (sanitizeProviderOverview),
and the lazy season enrichment stores the TMDB season overview on the
selection (tmdb_season_overviews) as the fallback description - same
cached /tv/{id}/season/{n} payload, so no extra requests. Provider text
keeps priority when it is real prose.

The enrichment write is also convergent now: the serial detail re-fires
season enrichment after every selection write, and the previous
unconditional rewrite scheduled the next cache-served run indefinitely.
A repeat run that changes nothing no longer writes.

buildSeasonDescriptions is extracted from SerialDetailsComponent, which
would otherwise cross the 400-line max-lines limit.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-08 11:12:59 +02:00

52 lines
1.6 KiB
TypeScript

import { sanitizeProviderOverview } from './provider-overview.util';
describe('sanitizeProviderOverview', () => {
it('keeps real description text', () => {
expect(sanitizeProviderOverview('A tense hijack drama.')).toBe(
'A tense hijack drama.'
);
});
it('trims surrounding whitespace', () => {
expect(sanitizeProviderOverview(' Season text ')).toBe('Season text');
});
it('returns null for empty and missing values', () => {
expect(sanitizeProviderOverview('')).toBeNull();
expect(sanitizeProviderOverview(' ')).toBeNull();
expect(sanitizeProviderOverview(null)).toBeNull();
expect(sanitizeProviderOverview(undefined)).toBeNull();
});
it('drops a bare http image URL', () => {
expect(
sanitizeProviderOverview(
'http://line.example.net:80/images/series/cover_small.jpg'
)
).toBeNull();
});
it('drops a bare https URL with a query string', () => {
expect(
sanitizeProviderOverview('https://cdn.example.com/p.jpg?w=300')
).toBeNull();
});
it('drops a bare URL padded with whitespace', () => {
expect(
sanitizeProviderOverview(' http://cdn.example.com/cover.png ')
).toBeNull();
});
it('drops a protocol-relative URL', () => {
expect(
sanitizeProviderOverview('//cdn.example.com/cover.jpg')
).toBeNull();
});
it('keeps prose that merely contains a URL', () => {
const text = 'More info at http://example.com/season1';
expect(sanitizeProviderOverview(text)).toBe(text);
});
});