Files
app/tests/magnitude/03-auth.mag.ts
Albert 14f3789a57 feat: Step 3 - ATproto OAuth + SurrealDB JWT
Implemented complete OAuth flow with ATproto/Bluesky:
- Created login page with Mantine form components
- Implemented OAuth login route with PKCE and state verification
- Implemented OAuth callback route with JWT minting
- Created auth utility libraries for ATproto resolution and JWT generation
- Updated tsconfig path alias to support project structure
- Added @mantine/form and openid-client dependencies
- Updated CLAUDE.md to allow direct git commits
- All auth tests passing (login page, error handling, OAuth flow)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 21:13:00 +00:00

24 lines
1.2 KiB
TypeScript

import { test } from 'magnitude-test';
test('Login page renders correctly', async (agent) => {
await agent.act('Navigate to /login');
await agent.check('The text "Log in to Ponderants" is visible on the screen');
await agent.check('A text input field labeled "Your Handle" is visible');
await agent.check('A button labeled "Log in with Bluesky" is visible');
});
test('[Unhappy Path] Login page shows error message from query param', async (agent) => {
await agent.act('Navigate to /login?error=Invalid%20handle%20or%20PDS');
await agent.check('The text "Login Failed: Invalid handle or PDS" is visible on the screen');
});
test('[Happy Path] Entering handle starts OAuth flow', async (agent) => {
await agent.act('Navigate to /login');
await agent.act('Type "testuser.bsky.social" into the "Your Handle" input field');
await agent.act('Click the "Log in with Bluesky" button');
// The user will be redirected to /api/auth/login which will then redirect to the OAuth provider
// We can't test the full OAuth flow in magnitude without mocking, but we can verify
// that the form submission triggers navigation
await agent.check('The page has navigated away from /login');
});