fix: Corriger le test E2E user-blocking qui échoue à cause du cache Redis
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:
@@ -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 }) => {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user