mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-15 21:56:18 -08:00
fix(xtream): preserve collection metadata and dashboard handoffs
This commit is contained in:
1 parent
29b0333fde
commit
2d975e0b29
11 files changed
+308
-34
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import { expect, test } from './fixtures';
|
||||
import {
|
||||
addXtreamPortal,
|
||||
DEFAULT_PASSWORD,
|
||||
DEFAULT_USERNAME,
|
||||
interceptXtreamRequests,
|
||||
MOCK_SERVER,
|
||||
} from './xtream-series-playback.fixture';
|
||||
@@ -11,6 +13,91 @@ test.beforeEach(async ({ page, request }) => {
|
||||
await interceptXtreamRequests(page);
|
||||
});
|
||||
|
||||
test('@xtream @collections catalog browsing preserves imported favorite metadata after reload', async ({
|
||||
page,
|
||||
request,
|
||||
}) => {
|
||||
const response = await request.get(`${MOCK_SERVER}/player_api.php`, {
|
||||
params: {
|
||||
username: DEFAULT_USERNAME,
|
||||
password: DEFAULT_PASSWORD,
|
||||
action: 'get_vod_streams',
|
||||
},
|
||||
});
|
||||
expect(response.ok()).toBeTruthy();
|
||||
const movie = (await response.json())[0];
|
||||
await addXtreamPortal(page, { name: 'Saved Metadata Portal' });
|
||||
const playlistPath = new URL(page.url()).pathname.replace(/\/vod.*$/, '');
|
||||
const rawId = playlistPath.split('/').pop();
|
||||
if (!rawId) throw new Error('Missing playlist ID in the portal route');
|
||||
const playlistId = decodeURIComponent(rawId);
|
||||
const favorite = {
|
||||
contentType: 'movie',
|
||||
xtreamId: movie.stream_id,
|
||||
addedAt: '2026-01-02T12:00:00.000Z',
|
||||
position: 3,
|
||||
snapshot: {
|
||||
title: movie.name,
|
||||
tmdbId: 949,
|
||||
releaseYear: 1995,
|
||||
originalTitle: 'Saved original title',
|
||||
},
|
||||
};
|
||||
await page.evaluate(
|
||||
({ playlistId, favorite }) =>
|
||||
localStorage.setItem(
|
||||
`xtream-restore-${playlistId}`,
|
||||
JSON.stringify({
|
||||
hiddenCategories: [],
|
||||
favorites: [favorite],
|
||||
recentlyViewed: [],
|
||||
playbackPositions: [],
|
||||
})
|
||||
),
|
||||
{ playlistId, favorite }
|
||||
);
|
||||
await page.reload();
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(
|
||||
(id) => localStorage.getItem(`xtream-restore-${id}`),
|
||||
playlistId
|
||||
)
|
||||
)
|
||||
.toBeNull();
|
||||
await page
|
||||
.locator(`[data-category-id="${movie.category_id}"]`)
|
||||
.first()
|
||||
.click();
|
||||
await expect(
|
||||
page.getByText(movie.name, { exact: true }).first()
|
||||
).toBeVisible();
|
||||
// Keep the catalog in memory while opening Favorites, exercising the merge.
|
||||
await page.getByRole('link', { name: 'Global favorites', exact: true }).click();
|
||||
await expect(
|
||||
page.getByText(movie.name, { exact: true }).first()
|
||||
).toBeVisible();
|
||||
await page.reload();
|
||||
await expect(
|
||||
page.getByText(movie.name, { exact: true }).first()
|
||||
).toBeVisible();
|
||||
expect(
|
||||
await page.evaluate(
|
||||
({ playlistId, key }) =>
|
||||
JSON.parse(
|
||||
localStorage.getItem('xtream-collection-items') ?? '{}'
|
||||
)[playlistId]?.[key],
|
||||
{ playlistId, key: `movie:${movie.stream_id}` }
|
||||
)
|
||||
).toMatchObject({
|
||||
tmdb_id: 949,
|
||||
release_year: 1995,
|
||||
original_title: 'Saved original title',
|
||||
added_at: favorite.addedAt,
|
||||
position: 3,
|
||||
});
|
||||
});
|
||||
|
||||
test('@xtream @collections PWA retries retain saved favorite metadata when snapshot storage is full', async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in new issue
Block a user