Files
iptvnator/apps/web-e2e/src/settings.e2e.ts
T
4grayandClaude Opus 4.7 a8253c5801 test(e2e): adapt to v0.22 dialog + theme picker redesigns
The redesign rollup in this branch replaced the Add Playlist dialog's
2-level type × subtype tabs with a single flat 5-card radiogroup, and
replaced the Settings theme list with a compact segmented control whose
options are just "Light"/"Dark"/"System" (no "theme" suffix). E2E tests
that pinned to the old roles/labels failed in CI:

  - basic / xtream / stalker / self-hosted: getByRole('tab', ...) on
    "Add via file upload" / "Xtream" / "Stalker" — there are no tabs in
    the new dialog. Switched to getByRole('radio', { name: /M3U file/i })
    and friends, matched against the new radio labels.
  - settings: getByRole('radio', { name: 'System theme' }) — the new
    picker uses just "System". Scoped to the [data-test-id="select-theme"]
    radiogroup so it doesn't collide with the identically-labelled
    cover-size options below.

The Electron `clickDialogSegmentedOption` helper grew a radio-role lookup
as its primary path and keeps the old tab/button/legacy-selector
fallbacks so a future redesign won't break every fixture again. The
"M3U" parent category becomes a no-op (the new picker has no standalone
M3U tile — callers always specialise to M3U URL/file/text immediately
after, which is what we want anyway).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 22:07:26 +02:00

104 lines
3.3 KiB
TypeScript

import { expect, Page, test } from '@playwright/test';
import { join } from 'path';
async function openSettings(page: Page) {
await page.locator('a[href$="/workspace/settings"]').click();
await page.waitForURL(/\/workspace\/settings$/);
await expect(page.locator('.settings-container')).toBeVisible();
await expect(page.locator('.settings-back-button')).toBeVisible();
}
async function saveSettings(page: Page) {
const saveButton = page.locator('[data-test-id="save-settings"]');
await saveButton.click();
await expect(saveButton).toBeDisabled();
}
test.describe('Settings', () => {
test.beforeEach(async ({ page }) => {
// Playwright creates a fresh browser context per test, so extra
// IndexedDB cleanup here only risks racing with app-managed DB handles.
await page.goto('/');
});
test('Check settings page', async ({ page }) => {
await openSettings(page);
await page.locator('.settings-back-button').click();
});
test('Change video player', async ({ page }) => {
await openSettings(page);
const playerSelect = page.locator('[data-test-id="select-video-player"]');
await expect(playerSelect).toContainText(
/Video\.js/i
);
await playerSelect.click();
await page.locator('mat-option[data-test-id="html5"]').click();
await saveSettings(page);
await page.reload();
await openSettings(page);
await expect(playerSelect).toContainText(
/HTML5/i
);
});
test('Change app theme', async ({ page }) => {
await openSettings(page);
// v0.22 compact theme picker exposes the segmented control as a
// radiogroup with options labelled just "Light"/"Dark"/"System".
// Scope to the theme radiogroup so we don't collide with the
// identically-labelled cover-size options below.
const themeGroup = page.locator(
'[data-test-id="select-theme"][role="radiogroup"]'
);
await expect(
themeGroup.getByRole('radio', { name: 'System', exact: true })
).toHaveAttribute('aria-checked', 'true');
await themeGroup
.getByRole('radio', { name: 'Dark', exact: true })
.click();
await saveSettings(page);
await page.reload();
await openSettings(page);
await expect(
themeGroup.getByRole('radio', { name: 'Dark', exact: true })
).toHaveAttribute('aria-checked', 'true');
});
test('Change app language', async ({ page }) => {
await openSettings(page);
const languageSelect = page.locator('[data-test-id="select-language"]');
await expect(languageSelect).toContainText(
'English'
);
await languageSelect.click();
await page.locator('mat-option[data-test-id="de"]').click();
await saveSettings(page);
await page.reload();
await openSettings(page);
await expect(languageSelect).toContainText(
'Deutsch'
);
});
test.afterEach(async ({ page }, testInfo) => {
await page.screenshot({
path: join(
process.cwd(),
'dist/.playwright/apps/web-e2e/screenshots/settings',
`${testInfo.title}.png`
),
});
});
});