import { test, expect } from '@playwright/test' import { resetDb } from './helpers/api' /** * Scénarios plans de relance. * * On valide la list view (4 plans pré-fournis après signup) + la * navigation vers le wizard de création. Le wizard 4 étapes lui-même * (avec génération IA des emails) est testé par les tests japa * functional pour le détail métier, et reste hors scope E2E V1. */ async function signupAndOnboard(page: import('@playwright/test').Page, tag = 'pl') { const email = `${tag}+${Date.now()}@rubis.test` await page.goto('/signup') await page.getByLabel(/Prénom \/ Nom/i).fill('Test User') 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() await page.waitForURL(/\/onboarding\/compte/, { timeout: 10_000 }) await page.getByRole('button', { name: /continuer/i }).click() await page.waitForURL(/\/onboarding\/entreprise/) await page.getByLabel(/nom de l'entreprise/i).fill('Atelier Test') await page.getByRole('button', { name: /continuer/i }).click() await page.waitForURL(/\/onboarding\/signature/) await page.getByRole('button', { name: /terminer/i }).click() await page.waitForURL('/', { timeout: 10_000 }) } test.describe('Plans de relance', () => { test.beforeEach(async () => { await resetDb() }) test('les 4 plans pré-fournis sont visibles après signup', async ({ page }) => { await signupAndOnboard(page, 'pl-default') await page.goto('/plans') await expect( page.getByRole('heading', { name: /plans de.*relance/i }), ).toBeVisible() // Les 4 plans pré-fournis ont des slugs `standard-30j`, `rapide-15j`, // `patient-60j`, `ferme-7j`. Leurs noms d'affichage utilisent les mots // "Standard", "Rapide", "Patient", "Ferme". await expect(page.getByText(/standard/i).first()).toBeVisible() await expect(page.getByText(/rapide/i).first()).toBeVisible() await expect(page.getByText(/patient/i).first()).toBeVisible() await expect(page.getByText(/ferme/i).first()).toBeVisible() // La carte "+ Créer un plan" est aussi visible await expect(page.getByRole('link', { name: /créer un plan/i })).toBeVisible() }) test('clic "Créer un plan" → arrive sur le wizard', async ({ page }) => { await signupAndOnboard(page, 'pl-wizard') await page.goto('/plans') await page.getByRole('link', { name: /créer un plan/i }).click() await expect(page).toHaveURL(/\/plans\/nouveau/, { timeout: 5_000 }) }) test('clic "Modifier" sur un plan → page détail du plan', async ({ page }) => { await signupAndOnboard(page, 'pl-detail') await page.goto('/plans') // Chaque PlanCard a un lien "Modifier" → /plans/$slug. On clique sur // le premier (qui correspondra à un des 4 plans pré-fournis). await page.getByRole('link', { name: /^modifier/i }).first().click() await expect(page).toHaveURL(/\/plans\/(standard|rapide|patient|ferme)/, { timeout: 5_000, }) }) })