Files
iptvnator/libs/shared/interfaces/src/lib/xtream-recently-added.utils.spec.ts
T
4gray 5b091809ef fix(xtream): ignore future recently added dates
## Summary
- Normalize Xtream recently-added timestamps across UI, import, and dashboard query paths.
- Filter future/invalid provider dates before ranking rails and migrate legacy millisecond cache rows.
- Add regression coverage for future timestamps, series date priority, and DB migration behavior.

## Validation
- GitHub checks passed, including Unit Tests and Typechecks, Web E2E, Electron E2E on macOS/Ubuntu/Windows, CodeQL, builds, and Greptile Review.
2026-05-19 14:39:38 +02:00

29 lines
989 B
TypeScript

import {
getXtreamRecentlyAddedMaxEpochSeconds,
toXtreamRecentlyAddedTimestamp,
} from './xtream-recently-added.utils';
describe('Xtream recently-added timestamp helpers', () => {
const now = Date.parse('2026-05-19T00:00:00.000Z');
it('treats far-future provider timestamps as invalid for recent ranking', () => {
expect(toXtreamRecentlyAddedTimestamp('1893456000', now)).toBe(0);
});
it('normalizes valid epoch seconds to milliseconds', () => {
expect(toXtreamRecentlyAddedTimestamp('1779062400', now)).toBe(
Date.parse('2026-05-18T00:00:00.000Z')
);
});
it('treats the epoch unit threshold itself as milliseconds', () => {
expect(toXtreamRecentlyAddedTimestamp('10000000000', now)).toBe(
10_000_000_000
);
});
it('builds the query upper-bound with the same future grace window', () => {
expect(getXtreamRecentlyAddedMaxEpochSeconds(now)).toBe('1779235200');
});
});