veza/tests/e2e/playlists-favoris-audit.spec.ts
senke 9a4c0d2af4 feat(web): update all features, stories, e2e tests, and auth interceptor
Update auth, playlists, tracks, search, profile, dashboard, player,
settings, and social features. Add e2e audit specs for all major pages.
Update ESLint config, vitest config, and route configuration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 19:16:36 +02:00

157 lines
7.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { CONFIG, loginViaAPI, navigateTo } from './helpers';
// ===========================================================================
// PLAYLISTS FAVORIS PAGE AUDIT
// ===========================================================================
test.describe('Playlist Favoris Audit (/playlists/favoris)', () => {
// -------------------------------------------------------------------------
// Chargement & Rendu
// -------------------------------------------------------------------------
test.describe('Chargement & Rendu', () => {
test('01. /playlists/favoris redirige vers la playlist detail', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await navigateTo(page, '/playlists/favoris');
// Should redirect to /playlists/:id
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
expect(page.url()).toMatch(/\/playlists\/[0-9a-f-]+$/);
});
test('02. la page de detail affiche le titre "Favoris"', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await navigateTo(page, '/playlists/favoris');
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
await expect(page.getByRole('heading', { name: 'Favoris', level: 1 })).toBeVisible({ timeout: 10_000 });
});
test('03. pas de "Playlist Not Found" apres redirection', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await navigateTo(page, '/playlists/favoris');
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
// Wait for content to settle
await page.waitForTimeout(2000);
// Should NOT show "Playlist Not Found"
await expect(page.getByText('Playlist Not Found')).not.toBeVisible();
});
test('04. onglets Tracks/Collaborators/Recommendations visibles', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await navigateTo(page, '/playlists/favoris');
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
await expect(page.getByRole('tab', { name: /tracks/i })).toBeVisible({ timeout: 10_000 });
await expect(page.getByRole('tab', { name: /collaborators/i })).toBeVisible();
});
test('05. boutons Play All et Shuffle visibles', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await navigateTo(page, '/playlists/favoris');
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
await expect(page.getByRole('button', { name: /play all/i })).toBeVisible({ timeout: 10_000 });
await expect(page.getByRole('button', { name: /shuffle/i })).toBeVisible();
});
});
// -------------------------------------------------------------------------
// Fonctionnalites
// -------------------------------------------------------------------------
test.describe('Fonctionnalites', () => {
test('06. etat vide affiche message quand pas de tracks', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await navigateTo(page, '/playlists/favoris');
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
// If favoris is empty, should show empty message
const hasTracksTab = await page.getByRole('tab', { name: /tracks/i }).isVisible().catch(() => false);
if (hasTracksTab) {
await page.getByRole('tab', { name: /tracks/i }).click();
// Either tracks are shown or empty state
const body = await page.textContent('body') || '';
expect(body.length).toBeGreaterThan(0);
}
});
test('07. bouton Add Tracks visible dans onglet Tracks', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await navigateTo(page, '/playlists/favoris');
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
await expect(page.getByRole('heading', { name: 'Favoris', level: 1 })).toBeVisible({ timeout: 10_000 });
await expect(page.getByRole('button', { name: /add tracks/i })).toBeVisible();
});
});
// -------------------------------------------------------------------------
// Securite
// -------------------------------------------------------------------------
test.describe('Securite', () => {
test('08. /playlists/favoris necessite authentification', async ({ page }) => {
await page.goto(`${CONFIG.baseURL}/playlists/favoris`);
await page.waitForURL(/\/(login|playlists)/, { timeout: CONFIG.timeouts.navigation });
const url = page.url();
if (!url.includes('/playlists')) {
expect(url).toContain('/login');
}
});
});
// -------------------------------------------------------------------------
// Responsive
// -------------------------------------------------------------------------
test.describe('Responsive', () => {
test('09. mobile 375px: page charge correctement', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await page.setViewportSize({ width: 375, height: 812 });
await navigateTo(page, '/playlists/favoris');
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
await expect(page.getByRole('heading', { name: 'Favoris', level: 1 })).toBeVisible({ timeout: 10_000 });
});
});
// -------------------------------------------------------------------------
// Regression
// -------------------------------------------------------------------------
test.describe('Regression', () => {
test('10. BUG#1: getPlaylist ne retourne plus undefined', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
await navigateTo(page, '/playlists/favoris');
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
// The critical fix: playlist detail should load, not show "Not Found"
await expect(page.getByRole('heading', { name: 'Favoris', level: 1 })).toBeVisible({ timeout: 10_000 });
await expect(page.getByText('Playlist Not Found')).not.toBeVisible();
});
test('11. BUG#1: playlist detail page loads for any valid playlist ID', async ({ page }) => {
await loginViaAPI(page, CONFIG.users.creator.email, CONFIG.users.creator.password);
// Navigate to playlists list first to get a playlist ID
await navigateTo(page, '/playlists');
await page.getByRole('article').first().waitFor({ state: 'visible', timeout: 10_000 }).catch(() => {});
const firstLink = page.getByRole('link', { name: /view playlist/i }).first();
if (await firstLink.isVisible().catch(() => false)) {
await firstLink.click();
await page.waitForURL(/\/playlists\/[0-9a-f-]+$/, { timeout: 10_000 });
// Should show playlist title, not "Playlist Not Found"
await page.waitForTimeout(2000);
await expect(page.getByText('Playlist Not Found')).not.toBeVisible();
await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
}
});
});
});