veza/tests/e2e/audit/functional/06-data-integrity.spec.ts
senke 7b39efa176 fix: stabilize frontend — 98 TS errors to 0, align API endpoints, optimize bundle
- Fix 98 TypeScript errors across 37 files:
  - Service layer double-unwrapping (subscriptionService, distributionService, gearService)
  - Self-referencing variables in SearchPageResults
  - FeedView/ExploreView .posts→.items alignment
  - useQueueSync Zustand subscribe API
  - AdminAuditLogsView missing interface fields
  - Toast proxy type, interceptor type narrowing
  - 22 unused imports/variables removed
  - 5 storybook mock data fixes

- Align frontend API calls with backend endpoints:
  - Analytics: useAnalyticsView now calls /creator/analytics/dashboard (was /analytics)
  - Chat: chatService uses /conversations (was mock data), WS URL from backend token
  - Dashboard StatsSection: uses real /dashboard API data (was hardcoded zeros)
  - Settings: suppress 2FA toast error when endpoint unavailable

- Fix marketplace products: seed uses 'active' status (was 'published')
- Enrich seed: admin follows all creators (feed has content)

- Optimize bundle: vendor catch-all 793KB→318KB gzip (-60%)
  Split into vendor-charts, vendor-emoji, vendor-swagger, vendor-media, etc.

- Clean repo: remove ~100 orphaned screenshots, audit reports, logs from root

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 21:18:49 +01:00

62 lines
2.9 KiB
TypeScript

import { test, expect } from '@chromatic-com/playwright';
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);
}
});
});