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`);
|
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 }) => {
|
||||||
|
|||||||
@@ -25,15 +25,18 @@ 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');
|
||||||
|
const pools = ['paginated_queries.cache', 'users.cache'];
|
||||||
|
for (const pool of pools) {
|
||||||
try {
|
try {
|
||||||
execSync(
|
execSync(
|
||||||
`docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear paginated_queries.cache 2>&1`,
|
`docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear ${pool} 2>&1`,
|
||||||
{ encoding: 'utf-8' }
|
{ encoding: 'utf-8' }
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
// Cache pool may not exist in all environments
|
// Cache pool may not exist in all environments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-empty-pattern
|
// eslint-disable-next-line no-empty-pattern
|
||||||
test.beforeAll(async ({}, testInfo) => {
|
test.beforeAll(async ({}, testInfo) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user