Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

test(e2e): make the rejected-login cassette answer 401 like the backend

Sergey Kozyrenkobe585b64f4a5
diff --git a/frontend/e2e/mocks/cassettes/smoke.ts b/frontend/e2e/mocks/cassettes/smoke.ts
index 52bbab11..60264711 100644
--- a/frontend/e2e/mocks/cassettes/smoke.ts
+++ b/frontend/e2e/mocks/cassettes/smoke.ts
@@ -23,14 +23,19 @@ export const loginJourneyCassette: Cassette = {
},
};
-// A rejected login: the backend answers 200 with an error envelope (not a 401,
-// which the axios interceptor would turn into a redirect), the session stays
-// guest, and the form surfaces the error.
+// The real backend answers 401 here (not a 200 error envelope); the axios
+// interceptor clears the auth key and rejects, so the app hits its catch branch.
export const loginFailCassette: Cassette = {
queries: baseQueries(),
rest: {
...baseRest(),
'GET /api/v1/info': [guestInfoEntry()],
- 'POST /api/v1/auth/login': [{ body: { error: 'invalid credentials', status: 'error' } }],
+ 'POST /api/v1/auth/login': [
+ {
+ body: { code: 'Auth.InvalidCredentials', msg: 'invalid login or password', status: 'error' },
+ bodySubset: { mail: SEEDED_USER.mail, password: 'wrong-password' },
+ status: 401,
+ },
+ ],
},
};
diff --git a/frontend/e2e/specs/smoke.spec.ts b/frontend/e2e/specs/smoke.spec.ts
index 0254b754..e6fd4cca 100644
--- a/frontend/e2e/specs/smoke.spec.ts
+++ b/frontend/e2e/specs/smoke.spec.ts
@@ -35,7 +35,7 @@ test.describe('smoke', { tag: '@smoke' }, () => {
await page.getByRole('textbox', { name: 'Password' }).fill('wrong-password');
await page.getByRole('button', { name: 'Sign in' }).click();
- await expect(page.getByText('Invalid login or password').first()).toBeVisible();
+ await expect(page.getByText('Login failed. Please try again.').first()).toBeVisible();
await expect(page).toHaveURL(/\/login/);
// react-hook-form leaves Submit disabled after a failed submit until
// an input changes.