🐛(frontend) improve e2e tests avoiding race condition from mocks

Reorder mock setup with page.route so that it takes place before nav.
This commit is contained in:
Laurent Bossavit
2025-01-16 12:30:35 +01:00
committed by Laurent Bossavit
parent 8a2b0d0a76
commit e7af1fd591
8 changed files with 168 additions and 87 deletions

View File

@@ -60,12 +60,6 @@ test.describe('Config', () => {
page,
browserName,
}) => {
await page.goto('/');
// Login with a user who has the visibility on the groups should see groups
// It's now the backend that decides if the user can see the group menu and they
// should be redirected to the groups page in such case
await keyCloakSignIn(page, browserName, 'team-administrator');
await page.route('**/api/v1.0/config/', async (route) => {
const request = route.request();
if (request.method().includes('GET')) {
@@ -83,6 +77,12 @@ test.describe('Config', () => {
}
});
await page.goto('/');
// Login with a user who has the visibility on the groups should see groups
// It's now the backend that decides if the user can see the group menu and they
// should be redirected to the groups page in such case
await keyCloakSignIn(page, browserName, 'team-administrator');
await expect(page.locator('menu')).toBeHidden();
await expect(page.getByText('Groups')).toBeVisible();