mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-12 20:16:15 -08:00
test(stalker): cover route playlist fallback paths
This commit is contained in:
1 parent
56f8ded835
commit
a8342f125c
2 files changed
+33
-7
No files matched your search
+28
-1
@@ -1,7 +1,7 @@
|
||||
import { signal } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { Subject, of } from 'rxjs';
|
||||
import { EMPTY, Subject, of } from 'rxjs';
|
||||
import { PlaylistContextFacade } from '@iptvnator/playlist/shared/util';
|
||||
import { StalkerStore } from '@iptvnator/portal/stalker/data-access';
|
||||
import { PlaylistsService } from '@iptvnator/services';
|
||||
@@ -173,4 +173,31 @@ describe('StalkerWorkspaceRouteSession', () => {
|
||||
FULL_STALKER_PLAYLIST
|
||||
);
|
||||
});
|
||||
|
||||
it('falls back to the active playlist when the full playlist lookup completes empty', async () => {
|
||||
activePlaylist.set(ACTIVE_PLAYLIST);
|
||||
playlistsService.getPlaylistById.mockReturnValue(EMPTY);
|
||||
|
||||
TestBed.inject(StalkerWorkspaceRouteSession);
|
||||
await flushEffects();
|
||||
|
||||
expect(playlistsService.getPlaylistById).toHaveBeenCalledWith(
|
||||
PLAYLIST_ID
|
||||
);
|
||||
expect(stalkerStore.setCurrentPlaylist).toHaveBeenCalledWith(
|
||||
ACTIVE_PLAYLIST
|
||||
);
|
||||
});
|
||||
|
||||
it('uses active Stalker playlist metadata directly when the portal mode is explicit', async () => {
|
||||
activePlaylist.set(FULL_STALKER_PLAYLIST);
|
||||
|
||||
TestBed.inject(StalkerWorkspaceRouteSession);
|
||||
await flushEffects();
|
||||
|
||||
expect(playlistsService.getPlaylistById).not.toHaveBeenCalled();
|
||||
expect(stalkerStore.setCurrentPlaylist).toHaveBeenCalledWith(
|
||||
FULL_STALKER_PLAYLIST
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -113,13 +113,12 @@ export class StalkerWorkspaceRouteSession {
|
||||
return activePlaylist;
|
||||
}
|
||||
|
||||
return (
|
||||
(await firstValueFrom(
|
||||
this.playlistsService.getPlaylistById(playlistId)
|
||||
)) ??
|
||||
activePlaylist ??
|
||||
undefined
|
||||
const storedPlaylist = await firstValueFrom(
|
||||
this.playlistsService.getPlaylistById(playlistId),
|
||||
{ defaultValue: null }
|
||||
);
|
||||
|
||||
return storedPlaylist ?? activePlaylist ?? undefined;
|
||||
}
|
||||
|
||||
private hasExplicitStalkerPortalMode(
|
||||
|
||||
Reference in new issue
Block a user