import { test, expect } from '@playwright/test' import { resetDb } from './helpers/api' /** * Scénario : un user lambda découvre l'app, crée son compte, complète * l'onboarding, atterrit sur le dashboard. * * Ce test ne touche pas à Stripe — il vérifie que la chaîne * signup → onboarding → dashboard fonctionne de bout en bout (auth, * persistence DB, redirections Tanstack Router, rendu SPA). */ test.describe('Signup + onboarding', () => { test.beforeEach(async () => { await resetDb() }) test('un user lambda peut créer son compte et arriver sur le dashboard', async ({ page, }) => { const email = `alice+${Date.now()}@rubis.test` // 1. Landing → /signup await page.goto('/signup') await expect(page.getByRole('heading', { name: /créer votre compte/i })).toBeVisible() // 2. Remplir le formulaire signup. Le label est "Prénom / Nom" + email + mdp. await page.getByLabel(/Prénom \/ Nom/i).fill('Alice Dupont') await page.getByLabel(/Email professionnel/i).fill(email) await page.getByLabel(/Mot de passe/i).fill('motdepasse-fort-123') await page.getByRole('button', { name: /créer mon compte/i }).click() // 3. Redirige vers onboarding compte await expect(page).toHaveURL(/\/onboarding\/compte/) await expect( page.getByRole('heading', { name: /bienvenue/i }), ).toBeVisible() // 4. Étape compte : fullName + email déjà préremplis, on continue await page.getByRole('button', { name: /continuer/i }).click() await expect(page).toHaveURL(/\/onboarding\/entreprise/) // 5. Étape entreprise : nom obligatoire await page.getByLabel(/nom de l'entreprise/i).fill('Atelier Alice') await page.getByRole('button', { name: /continuer/i }).click() await expect(page).toHaveURL(/\/onboarding\/signature/) // 6. Étape signature : on accepte le default await page.getByRole('button', { name: /terminer/i }).click() // 7. Arrivée sur le dashboard — pas de H1 strict, on assert sur des // signaux stables du dashboard : la phrase "rubis gagnés" du RubisHero // + la sidebar (lien Tableau de bord). await expect(page).toHaveURL('/') await expect(page.getByText(/rubis.*gagnés/i)).toBeVisible({ timeout: 10_000 }) await expect(page.getByRole('link', { name: /tableau de bord/i })).toBeVisible() }) })