Refine auth, player, tracks, playlists, search, workflows, edge cases, forms, responsive, network errors, error boundary, performance, visual regression, cross-browser, profile, smoke, storybook, chat, and session tests. Add audit test suite (accessibility, ethical, functional, design tokens). Update test helpers and visual snapshots. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62 lines
2.9 KiB
TypeScript
62 lines
2.9 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { loginViaAPI, navigateTo } from '../helpers';
|
|
import { TEST_USERS } from '../design-tokens';
|
|
|
|
test.describe('FONCTIONNEL — Intégrité des données', () => {
|
|
test('API /auth/me retourne les données du user connecté', async ({ page }) => {
|
|
await loginViaAPI(page, TEST_USERS.listener.email, TEST_USERS.listener.password);
|
|
|
|
const response = await page.request.get('/api/v1/auth/me');
|
|
expect(response.ok(), `GET /auth/me a retourné ${response.status()}`).toBe(true);
|
|
|
|
const body = await response.json();
|
|
const user = body?.data || body;
|
|
expect(user).toHaveProperty('email');
|
|
expect(user.email).toBe(TEST_USERS.listener.email);
|
|
});
|
|
|
|
test('Pages error 404 et 500 se chargent correctement', async ({ page }) => {
|
|
await page.goto('/404', { waitUntil: 'domcontentloaded' });
|
|
await page.waitForLoadState('networkidle').catch(() => {});
|
|
const body404 = await page.textContent('body');
|
|
expect(body404).toMatch(/404|not found|page introuvable|n'existe pas/i);
|
|
|
|
await page.goto('/500', { waitUntil: 'domcontentloaded' });
|
|
await page.waitForLoadState('networkidle').catch(() => {});
|
|
const body500 = await page.textContent('body');
|
|
expect(body500).toMatch(/500|server error|erreur serveur|problème/i);
|
|
});
|
|
|
|
test('Route inexistante redirige vers 404', async ({ page }) => {
|
|
await page.goto('/this-page-does-not-exist-at-all', { waitUntil: 'domcontentloaded' });
|
|
await page.waitForLoadState('networkidle').catch(() => {});
|
|
await page.waitForTimeout(3_000);
|
|
expect(page.url()).toContain('/404');
|
|
});
|
|
|
|
test('Le sidebar affiche les liens de navigation', async ({ page }) => {
|
|
await loginViaAPI(page, TEST_USERS.listener.email, TEST_USERS.listener.password);
|
|
await navigateTo(page, '/dashboard');
|
|
|
|
const sidebar = page.locator('[data-testid="app-sidebar"]');
|
|
// Le sidebar peut être caché sur mobile, vérifier sur desktop viewport
|
|
if (await sidebar.isVisible({ timeout: 5_000 }).catch(() => false)) {
|
|
const links = await sidebar.locator('a[href], [role="link"]').count();
|
|
expect(links, 'Le sidebar devrait avoir au moins 3 liens de navigation').toBeGreaterThanOrEqual(3);
|
|
}
|
|
});
|
|
|
|
test('La recherche retourne des résultats cohérents', async ({ page }) => {
|
|
await loginViaAPI(page, TEST_USERS.listener.email, TEST_USERS.listener.password);
|
|
await navigateTo(page, '/search');
|
|
|
|
const searchInput = page.locator('[data-testid="search-input"], input[type="search"], input[role="searchbox"]').first();
|
|
if (await searchInput.isVisible({ timeout: 5_000 }).catch(() => false)) {
|
|
await searchInput.fill('test');
|
|
await page.waitForTimeout(2_000);
|
|
// La page ne devrait pas crasher après une recherche
|
|
const body = await page.textContent('body');
|
|
expect(body).not.toMatch(/500|Internal Server Error/i);
|
|
}
|
|
});
|
|
});
|