/** * E2E test: User settings persistence. * * Validates that a user can: * 1. Navigate to /settings * 2. Change the batch_size input * 3. Save * 4. Reload the page * 5. Assert the batch_size value persisted */ import { test, expect } from '@playwright/test'; import { loginAsUser } from '../helpers/auth'; test.describe('Settings', () => { test('should save and persist batch_size setting across page reloads', async ({ page, }) => { // Step 1: Login as regular user via cookie injection await loginAsUser(page); // Step 2: Navigate to settings await page.goto('/settings', { waitUntil: 'domcontentloaded' }); // Wait for the settings page to load await expect( page.locator('h1', { hasText: 'Parametres de generation' }), ).toBeVisible({ timeout: 10_000 }); // Step 3: Change the batch_size input to 10 const batchSizeInput = page.locator('#batchSize'); await expect(batchSizeInput).toBeVisible(); // Clear existing value and type new one await batchSizeInput.fill('10'); // Verify the input has the new value await expect(batchSizeInput).toHaveValue('10'); // Step 4: Click the save button const saveButton = page.locator('button', { hasText: 'Enregistrer les parametres', }); await saveButton.click(); // Wait for save confirmation message await expect( page.getByText('Parametres enregistres avec succes'), ).toBeVisible({ timeout: 5_000 }); // Step 5: Reload the page await page.reload(); // Wait for the settings page to reload await expect( page.locator('h1', { hasText: 'Parametres de generation' }), ).toBeVisible({ timeout: 10_000 }); // Step 6: Assert the batch_size input value is 10 await expect(page.locator('#batchSize')).toHaveValue('10'); }); });