test(xtream): cover live auto-open state reset

This commit is contained in:
4gray committed 2026-06-19 21:00:22 +02:00
1 parent 6ad5f5e207
commit bfa865c55c
3 files changed
+44

No files matched your search

@@ -0,0 +1,38 @@
import { LiveStreamAutoOpenStateService } from './live-stream-auto-open-state.service';
describe('LiveStreamAutoOpenStateService', () => {
let service: LiveStreamAutoOpenStateService;
beforeEach(() => {
service = new LiveStreamAutoOpenStateService();
window.history.replaceState({}, document.title);
});
afterEach(() => {
window.history.replaceState({}, document.title);
});
it('captures a positive live item id from history state', () => {
window.history.replaceState(
{ openXtreamLiveItemId: 101 },
document.title
);
service.captureFromHistoryState();
expect(service.pendingItemId()).toBe(101);
});
it('clears the pending item id when history state has no live item id', () => {
window.history.replaceState(
{ openXtreamLiveItemId: 101 },
document.title
);
service.captureFromHistoryState();
window.history.replaceState({}, document.title);
service.captureFromHistoryState();
expect(service.pendingItemId()).toBeNull();
});
});
@@ -12,7 +12,10 @@ export class LiveStreamAutoOpenStateService {
);
if (Number.isFinite(requestedItemId) && requestedItemId > 0) {
this.pendingItemId.set(requestedItemId);
return;
}
this.pendingItemId.set(null);
}
clearPendingItem(): void {
@@ -376,6 +376,9 @@ export class LiveStreamLayoutComponent implements OnInit, OnDestroy {
startPlayback = !this.settingsStore.openStreamOnDoubleClick()
) {
const streamUrl = this.xtreamStore.constructStreamUrl(item);
// Keep both root/recently-added playback and same-category replays in
// sync with the category rail. For already-selected channels this is a
// store no-op.
this.selectLiveItemCategory(item);
this.activePlayback.set({
streamUrl,