feat(web/m7-user-mgmt): /register page + login link
Public /register form: username, optional display name, password + confirm, optional invite token. Submits to POST /api/auth/register via the new register() helper in auth/store.svelte.ts. On success the server sets the session cookie and the frontend redirects to /; on error the page shows a code-specific message (invite_required, invite_invalid, username_taken, etc.). Login page gets a "Don't have an account? Register" link below the form for symmetry. Tests cover form rendering, password-mismatch client-side rejection, the happy-path submit + redirect, and the invite-invalid error mapping. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,12 @@ describe('login page', () => {
|
||||
expect(screen.getByRole('button', { name: /sign in/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('renders a link to the register page', () => {
|
||||
render(LoginPage);
|
||||
const link = screen.getByRole('link', { name: /register/i });
|
||||
expect(link).toHaveAttribute('href', '/register');
|
||||
});
|
||||
|
||||
test('invalid credentials show inline error and clear password', async () => {
|
||||
(login as ReturnType<typeof vi.fn>).mockRejectedValue({
|
||||
code: 'invalid_credentials', message: 'bad creds', status: 401
|
||||
|
||||
Reference in New Issue
Block a user