mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-14 05:06:16 -08:00
test(e2e): enhance E2E tests for Xtream and Stalker portals, improve category selection logic, and streamline IndexedDB cleanup
This commit is contained in:
1 parent
e01d7caf0b
commit
f229b3b1f2
7 files changed
+647
-95
No files matched your search
@@ -17,18 +17,9 @@ async function saveSettings(page: Page) {
|
||||
|
||||
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('/');
|
||||
// Clear IndexedDB before each test
|
||||
await page.evaluate(async () => {
|
||||
const dbNames = (await window.indexedDB.databases()).map(
|
||||
(db) => db.name
|
||||
);
|
||||
dbNames.forEach((name) =>
|
||||
name !== undefined
|
||||
? window.indexedDB.deleteDatabase(name)
|
||||
: null
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('Check settings page', async ({ page }) => {
|
||||
|
||||
@@ -90,20 +90,6 @@ async function addStalkerPortal(
|
||||
await page.waitForURL(/stalker.*vod/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear IndexedDB state between tests so each test starts fresh.
|
||||
*/
|
||||
async function clearStorage(page: Page): Promise<void> {
|
||||
await page.evaluate(async () => {
|
||||
const dbs = await window.indexedDB.databases();
|
||||
await Promise.all(
|
||||
dbs
|
||||
.filter((db) => db.name != null)
|
||||
.map((db) => window.indexedDB.deleteDatabase(db.name!))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Test setup
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -112,9 +98,9 @@ test.beforeEach(async ({ page, request }) => {
|
||||
// Reset mock server state (clears in-memory favorites and cache)
|
||||
await request.post(`${MOCK_SERVER}/reset`);
|
||||
|
||||
// Playwright creates a fresh browser context per test, so extra
|
||||
// IndexedDB cleanup here only risks racing with app-managed DB handles.
|
||||
await page.goto('/');
|
||||
await clearStorage(page);
|
||||
await page.reload();
|
||||
|
||||
// Redirect backend proxy calls to the mock server
|
||||
await interceptStalkerRequests(page);
|
||||
|
||||
@@ -70,20 +70,6 @@ async function addXtreamPortal(
|
||||
await page.waitForURL(/xtreams.*vod/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear IndexedDB state between tests so each test starts fresh.
|
||||
*/
|
||||
async function clearStorage(page: Page): Promise<void> {
|
||||
await page.evaluate(async () => {
|
||||
const dbs = await window.indexedDB.databases();
|
||||
await Promise.all(
|
||||
dbs
|
||||
.filter((db) => db.name != null)
|
||||
.map((db) => window.indexedDB.deleteDatabase(db.name!))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Test setup
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -91,9 +77,9 @@ async function clearStorage(page: Page): Promise<void> {
|
||||
test.beforeEach(async ({ page, request }) => {
|
||||
await request.post(`${MOCK_SERVER}/reset`);
|
||||
|
||||
// Playwright creates a fresh browser context per test, so extra
|
||||
// IndexedDB cleanup here only risks racing with app-managed DB handles.
|
||||
await page.goto('/');
|
||||
await clearStorage(page);
|
||||
await page.reload();
|
||||
|
||||
await interceptXtreamRequests(page);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user