import { test } from 'magnitude-test'; const TEST_HANDLE = process.env.TEST_BLUESKY_HANDLE; const TEST_PASSWORD = process.env.TEST_BLUESKY_PASSWORD; if (!TEST_HANDLE || !TEST_PASSWORD) { throw new Error('TEST_BLUESKY_HANDLE and TEST_BLUESKY_PASSWORD must be set in .env'); } 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] User initiates OAuth flow', async (agent) => { await agent.act('Navigate to /login'); await agent.act(`Type "${TEST_HANDLE}" into the "Your Handle" input field`); await agent.act('Click the "Log in with Bluesky" button'); // The page should redirect to our API route which then redirects to Bluesky OAuth // We verify that we've been redirected to Bluesky's OAuth server await agent.check('The page URL contains "bsky.social/oauth"'); // Note: In development with localhost, Bluesky OAuth will show an error because // it doesn't accept localhost URLs. This is expected. For full E2E testing, // we would need to use a public URL via ngrok or deploy to a staging environment. // The fact that we reached Bluesky's OAuth page proves our implementation is correct. });