fix: Corriger le test E2E user-blocking qui échoue à cause du cache Redis
Some checks failed
CI / Backend Tests (push) Has been cancelled
CI / Frontend Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Naming Conventions (push) Has been cancelled
CI / Build Check (push) Has been cancelled

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.
This commit is contained in:
2026-03-03 22:52:05 +01:00
parent d103b34023
commit e156755b86
2 changed files with 11 additions and 8 deletions

View File

@@ -81,7 +81,7 @@ test.describe('Periods Management (Story 2.3)', () => {
await page.goto(`${ALPHA_URL}/admin/academic-year/periods`); await page.goto(`${ALPHA_URL}/admin/academic-year/periods`);
const tabs = page.getByRole('tab'); 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 }) => { test('current year tab is active by default', async ({ page }) => {

View File

@@ -25,13 +25,16 @@ test.describe('User Blocking', () => {
function clearCache() { function clearCache() {
const projectRoot = join(__dirname, '../..'); const projectRoot = join(__dirname, '../..');
const composeFile = join(projectRoot, 'compose.yaml'); const composeFile = join(projectRoot, 'compose.yaml');
try { const pools = ['paginated_queries.cache', 'users.cache'];
execSync( for (const pool of pools) {
`docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear paginated_queries.cache 2>&1`, try {
{ encoding: 'utf-8' } execSync(
); `docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear ${pool} 2>&1`,
} catch { { encoding: 'utf-8' }
// Cache pool may not exist in all environments );
} catch {
// Cache pool may not exist in all environments
}
} }
} }