Skip to content

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

test(e2e): cover the rejected-login path

Sergey Kozyrenko7acd0b6cca71
diff --git a/frontend/e2e/mocks/cassettes/smoke.ts b/frontend/e2e/mocks/cassettes/smoke.ts
index 78461c33..f06e3f81 100644
--- a/frontend/e2e/mocks/cassettes/smoke.ts
+++ b/frontend/e2e/mocks/cassettes/smoke.ts
@@ -24,3 +24,15 @@ 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.
+export const loginFailCassette: Cassette = {
+ queries: baseQueries(),
+ rest: {
+ ...baseRest(),
+ 'GET /api/v1/info': [guestInfoEntry()],
+ 'POST /api/v1/auth/login': [{ body: { error: 'invalid credentials', status: 'error' } }],
+ },
+};
diff --git a/frontend/e2e/specs/smoke.spec.ts b/frontend/e2e/specs/smoke.spec.ts
index e553b23f..0254b754 100644
--- a/frontend/e2e/specs/smoke.spec.ts
+++ b/frontend/e2e/specs/smoke.spec.ts
@@ -1,7 +1,7 @@
import { SEEDED_USER } from '../fixtures/auth.ts';
import { expect, test } from '../fixtures/test.ts';
import { expectCleanPage } from '../helpers/errors.ts';
-import { loginJourneyCassette, smokeCassette } from '../mocks/cassettes/smoke.ts';
+import { loginFailCassette, loginJourneyCassette, smokeCassette } from '../mocks/cassettes/smoke.ts';
test.describe('smoke', { tag: '@smoke' }, () => {
test.describe('unauthenticated', () => {
@@ -26,6 +26,23 @@ test.describe('smoke', { tag: '@smoke' }, () => {
});
});
+ test.describe('rejected login', () => {
+ test.use({ cassette: loginFailCassette, isAuthSeeded: false });
+
+ test('surfaces the error and re-disables Sign in until a field changes', async ({ page }) => {
+ await page.goto('/login');
+ await page.getByLabel('Login').fill(SEEDED_USER.mail);
+ 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).toHaveURL(/\/login/);
+ // react-hook-form leaves Submit disabled after a failed submit until
+ // an input changes.
+ await expect(page.getByRole('button', { name: 'Sign in' })).toBeDisabled();
+ });
+ });
+
test.describe('authenticated', () => {
test.use({ cassette: smokeCassette });