Skip to content

Commit bb40048

Browse files
committed
base url fix + tests fix (rabbit hints)
1 parent 3750c6f commit bb40048

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

frontend/e2e/auth.spec.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,27 @@ test.describe('Authentication', () => {
2222
await expect(page.locator('button[type="submit"]')).toBeVisible();
2323
});
2424

25-
test('shows validation when submitting empty form', async ({ page }) => {
25+
test('prevents submission and shows validation for empty form', async ({ page }) => {
2626
await page.goto('/login');
2727
await page.waitForSelector('#username');
2828

29+
// Click submit without filling any fields
30+
await page.click('button[type="submit"]');
31+
32+
// Form should not submit - still on login page
33+
await expect(page).toHaveURL(/\/login/);
34+
35+
// Browser focuses first invalid required field and shows validation
2936
const usernameInput = page.locator('#username');
30-
await expect(usernameInput).toHaveAttribute('required', '');
37+
await expect(usernameInput).toBeFocused();
38+
39+
// Check HTML5 validity state
40+
const isInvalid = await usernameInput.evaluate((el: HTMLInputElement) => !el.validity.valid);
41+
expect(isInvalid).toBe(true);
42+
43+
// Verify validation message exists (browser shows "Please fill out this field" or similar)
44+
const validationMessage = await usernameInput.evaluate((el: HTMLInputElement) => el.validationMessage);
45+
expect(validationMessage.length).toBeGreaterThan(0);
3146
});
3247

3348
test('shows error with invalid credentials', async ({ page }) => {
@@ -124,12 +139,11 @@ test.describe('Logout', () => {
124139
});
125140

126141
test('can logout from authenticated state', async ({ page }) => {
127-
// Find and click logout button
128-
const logoutButton = page.locator('button:has-text("Logout"), a:has-text("Logout"), [data-testid="logout"]');
142+
// Logout button is in the header - must exist when authenticated
143+
const logoutButton = page.locator('button:has-text("Logout")').first();
129144

130-
if (await logoutButton.isVisible()) {
131-
await logoutButton.click();
132-
await expect(page).toHaveURL(/\/login/);
133-
}
145+
await expect(logoutButton).toBeVisible();
146+
await logoutButton.click();
147+
await expect(page).toHaveURL(/\/login/);
134148
});
135149
});

frontend/src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { mount } from 'svelte';
33
import App from './App.svelte';
44
import './app.css';
55

6-
// Configure the API client with base URL and credentials
6+
// Configure the API client with credentials
7+
// Note: SDK already has full paths like '/api/v1/auth/login', so baseUrl should be empty
78
client.setConfig({
8-
baseUrl: '/api/v1',
9+
baseUrl: '',
910
credentials: 'include',
1011
});
1112

0 commit comments

Comments
 (0)