59 lines
2.3 KiB
TypeScript
59 lines
2.3 KiB
TypeScript
/**
|
|
* Play flow E2E: after login, go to library or search, click a track, verify track page or player visible.
|
|
*/
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
import {
|
|
TEST_CONFIG,
|
|
loginAsUser,
|
|
setupErrorCapture,
|
|
} from '../utils/test-helpers';
|
|
|
|
test.describe('Play Flow', () => {
|
|
test.use({ storageState: { cookies: [], origins: [] } });
|
|
|
|
let consoleErrors: string[] = [];
|
|
let networkErrors: Array<{ url: string; status: number; method: string }> = [];
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
const errorCapture = setupErrorCapture(page);
|
|
consoleErrors = errorCapture.consoleErrors;
|
|
networkErrors = errorCapture.networkErrors;
|
|
});
|
|
|
|
test('after login, search or library -> click track -> track page or player visible', async ({ page }) => {
|
|
test.setTimeout(60000);
|
|
|
|
await loginAsUser(page);
|
|
|
|
await page.goto(`${TEST_CONFIG.FRONTEND_URL}/search`, { waitUntil: 'domcontentloaded' });
|
|
await page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {});
|
|
|
|
const searchInput = page.locator(
|
|
'input[type="search"], input[placeholder*="Search" i], input[placeholder*="Recherche" i], input[name="q"]'
|
|
).first();
|
|
await searchInput.fill('test').catch(() => {});
|
|
await page.waitForTimeout(1000);
|
|
|
|
const trackLink = page.locator('a[href*="/tracks/"]').first();
|
|
const hasTrack = await trackLink.isVisible({ timeout: 5000 }).catch(() => false);
|
|
|
|
if (hasTrack) {
|
|
await trackLink.click();
|
|
await page.waitForURL(/\/tracks\//, { timeout: 10000 }).catch(() => {});
|
|
const onTrackPage = (await page.url()).includes('/tracks/');
|
|
expect(onTrackPage).toBe(true);
|
|
|
|
const trackPageOrPlayer = page.locator(
|
|
'[data-testid="track-detail"], [data-testid="track-detail-page"], main, .fixed.bottom-0'
|
|
).first();
|
|
await expect(trackPageOrPlayer).toBeVisible({ timeout: 10000 });
|
|
} else {
|
|
const resultsArea = page.locator('main, [data-testid="search-results"], [aria-label*="search" i]').first();
|
|
const noResults = page.getByText(/no results|aucun résultat/i);
|
|
const hasContent = await resultsArea.isVisible({ timeout: 3000 }).catch(() => false)
|
|
|| await noResults.isVisible({ timeout: 2000 }).catch(() => false);
|
|
expect(hasContent).toBe(true);
|
|
}
|
|
});
|
|
});
|