From e156755b86ff1098ac4436f55fe4f6276bbb6090 Mon Sep 17 00:00:00 2001 From: Mathias STRASSER Date: Tue, 3 Mar 2026 22:52:05 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20Corriger=20le=20test=20E2E=20user-blocki?= =?UTF-8?q?ng=20qui=20=C3=A9choue=20=C3=A0=20cause=20du=20cache=20Redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le beforeAll du test réinitialise le statut de l'utilisateur cible via SQL direct (dbal:run-sql), mais le CachedUserRepository (cache-aside Redis) conserve l'ancienne entrée avec statut "suspended". Quand le BlockUserHandler charge l'utilisateur, il lit le cache Redis périmé et refuse le blocage car le compte apparaît déjà suspendu. Le clearCache() ne vidait que paginated_queries.cache. En ajoutant users.cache, le cache Redis de l'utilisateur est invalidé et le handler lit bien le statut "active" depuis PostgreSQL. --- frontend/e2e/periods.spec.ts | 2 +- frontend/e2e/user-blocking.spec.ts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/e2e/periods.spec.ts b/frontend/e2e/periods.spec.ts index 32e7d23..4c5e5bf 100644 --- a/frontend/e2e/periods.spec.ts +++ b/frontend/e2e/periods.spec.ts @@ -81,7 +81,7 @@ test.describe('Periods Management (Story 2.3)', () => { await page.goto(`${ALPHA_URL}/admin/academic-year/periods`); const tabs = page.getByRole('tab'); - await expect(tabs).toHaveCount(3); + await expect(tabs).toHaveCount(3, { timeout: 10000 }); }); test('current year tab is active by default', async ({ page }) => { diff --git a/frontend/e2e/user-blocking.spec.ts b/frontend/e2e/user-blocking.spec.ts index 9cfaca3..b310a02 100644 --- a/frontend/e2e/user-blocking.spec.ts +++ b/frontend/e2e/user-blocking.spec.ts @@ -25,13 +25,16 @@ test.describe('User Blocking', () => { function clearCache() { const projectRoot = join(__dirname, '../..'); const composeFile = join(projectRoot, 'compose.yaml'); - try { - execSync( - `docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear paginated_queries.cache 2>&1`, - { encoding: 'utf-8' } - ); - } catch { - // Cache pool may not exist in all environments + const pools = ['paginated_queries.cache', 'users.cache']; + for (const pool of pools) { + try { + execSync( + `docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear ${pool} 2>&1`, + { encoding: 'utf-8' } + ); + } catch { + // Cache pool may not exist in all environments + } } }