From 7d4d9a280ae38a148e16ab1e049f85fa9ff0f0cc Mon Sep 17 00:00:00 2001 From: 4gray Date: Sat, 11 Apr 2026 22:32:17 +0200 Subject: [PATCH] test(xtream): add end-to-end test for handling empty VOD metadata fallback --- .../src/xtream-vod-details.e2e.ts | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 apps/electron-backend-e2e/src/xtream-vod-details.e2e.ts diff --git a/apps/electron-backend-e2e/src/xtream-vod-details.e2e.ts b/apps/electron-backend-e2e/src/xtream-vod-details.e2e.ts new file mode 100644 index 000000000..43c07c7b5 --- /dev/null +++ b/apps/electron-backend-e2e/src/xtream-vod-details.e2e.ts @@ -0,0 +1,75 @@ +import { + addXtreamPortal, + clickCategoryByNameExact, + clickGridListCardByTitle, + closeElectronApp, + expect, + launchElectronApp, + resetMockServers, + test, + waitForXtreamWorkspaceReady, +} from './electron-test-fixtures'; +import { + fetchXtreamVodFixture, + getXtreamTitle, + pickDistinctTitles, +} from './portal-mock-fixtures'; + +const emptyMetadataCredentials = { + password: 'emptyvod', + username: 'emptyvod', +}; + +test.describe('Xtream VOD Details', () => { + test('shows a curated fallback when the portal returns empty VOD metadata', async ({ + dataDir, + request, + }) => { + await resetMockServers(request, ['xtream']); + const vodFixture = await fetchXtreamVodFixture( + request, + emptyMetadataCredentials + ); + const [movieTitle] = pickDistinctTitles(vodFixture.items, getXtreamTitle); + const app = await launchElectronApp(dataDir); + + try { + await addXtreamPortal(app.mainWindow, { + ...emptyMetadataCredentials, + name: 'Xtream Empty Metadata', + }); + await waitForXtreamWorkspaceReady(app.mainWindow); + + await app.mainWindow + .getByRole('link', { name: 'Movies', exact: true }) + .click(); + await clickCategoryByNameExact(app.mainWindow, vodFixture.categoryName); + await clickGridListCardByTitle(app.mainWindow, movieTitle); + + await app.mainWindow.waitForURL( + /\/workspace\/xtreams\/[^/]+\/vod\/[^/]+\/[^/]+$/ + ); + await expect(app.mainWindow.locator('app-content-hero')).toContainText( + movieTitle + ); + await expect( + app.mainWindow.locator('[data-testid="xtream-vod-fallback-status"]') + ).toContainText('Portal metadata unavailable'); + await expect( + app.mainWindow.locator('[data-testid="xtream-vod-fallback"]') + ).toContainText( + 'Extended metadata was not provided by this portal.' + ); + + await expect(app.mainWindow.locator('button.play-btn')).toHaveCount(0); + await expect(app.mainWindow.locator('button.favorite-btn')).toHaveCount( + 0 + ); + await expect(app.mainWindow.locator('button.download-btn')).toHaveCount( + 0 + ); + } finally { + await closeElectronApp(app); + } + }); +});