Files
iptvnator/apps/electron-backend-e2e/src/xtream-live-format.fixture.ts
T
4grayandClaude Opus 5.5 0ea9ecdb27 fix(import): consistent add-source forms with masked passwords and URL errors
- Mask the Xtream password in add and edit (and the Stalker one in edit)
  behind a shared PasswordVisibilityToggleDirective: one translated
  "Show password" label, state in aria-pressed, type="button".
- Give the Xtream server URL its own mat-error and a neutral hint instead
  of the EPG file error; give the M3U URL a mat-error.
- Use "Playlist title" in every add form, "MAC address" casing, a single
  ellipsis in "Validating portal…" and one "Add playlist" submit label;
  translate the method radiogroup's aria-label.
- Show Stalker refusals inline under the portal URL (role="status", like
  the Xtream connection test), translated in the template and cleared by
  edits; translate the snackbars for outcomes that close the dialog.
- Translate new strings into all locales; reuse the identical Stalker URL
  error translations; fix MAC casing and ellipses; drop unused keys.
- Unit specs per form, edit-dialog spec, new add-source-forms web E2E;
  update E2E locators; UI guidelines Forms section; Stalker contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 09:55:16 +02:00

82 lines
3.1 KiB
TypeScript

import { expect, type Page } from '@playwright/test';
export const liveFormatMock = `http://localhost:${process.env['XTREAM_MOCK_PORT'] ?? '3211'}`;
export type LiveFormatPlayer = 'html5' | 'videojs' | 'artplayer';
export async function configureLiveFormat(
page: Page,
player: LiveFormatPlayer,
format = 'auto'
) {
await page.getByRole('link', { name: 'Open settings' }).click();
await page.locator('[data-test-id="settings-section-playback"]').click();
await page.locator('[data-test-id="select-video-player"]').click();
await page
.getByRole('option', {
name: {
html5: 'HTML5 video player',
videojs: 'Video.js player',
artplayer: 'ArtPlayer',
}[player],
exact: true,
})
.click();
await page.locator('[data-test-id="select-stream-format"]').click();
await page.getByRole('option', { name: format, exact: true }).click();
if (player !== 'videojs' || format !== 'auto') {
const save = page.getByRole('button', { name: 'Save changes' });
await expect(save).toBeVisible();
await save.click();
await expect(save).toBeHidden();
}
await page.getByRole('button', { name: 'Back', exact: true }).click();
}
export async function addLiveFormatPortal(page: Page) {
await page.getByRole('button', { name: 'Add playlist' }).click();
const dialog = page.getByRole('dialog');
await dialog.getByRole('radio', { name: /Xtream credentials/i }).click();
await dialog.locator('#title').fill('Synthetic live');
await dialog.locator('#serverUrl').fill(liveFormatMock);
await dialog.locator('#username').fill('live-fallback');
await dialog.locator('#password').fill('live-fallback');
await dialog
.getByRole('button', { name: 'Add playlist', exact: true })
.click();
await page.waitForURL(/xtreams.*vod/);
await page.getByRole('link', { name: 'Live TV', exact: true }).click();
await page.locator('.context-panel .category-item').first().click();
await expect(liveChannels(page).first()).toBeVisible();
}
export const liveChannels = (page: Page) =>
page.locator('app-live-stream-layout [data-test-id="channel-item"]');
export function observeLiveFormatMedia(page: Page) {
const media: { file: string; status: number }[] = [];
page.on('response', (response) => {
if (response.url().startsWith(`${liveFormatMock}/live/`))
media.push({
file: new URL(response.url()).pathname.split('/').pop() ?? '',
status: response.status(),
});
});
return media;
}
export async function expectLiveFormatPlaying(
page: Page,
player: LiveFormatPlayer
) {
await expect(
page.locator(
`app-${player === 'html5' ? 'html-video' : player === 'videojs' ? 'vjs' : 'art'}-player`
)
).toBeVisible();
const video = page.locator('app-web-player-view video').first();
await expect
.poll(() => video.evaluate((v: HTMLVideoElement) => v.currentTime), {
timeout: 50_000,
})
.toBeGreaterThan(0.5);
return video;
}