import { test as setup, expect } from '@playwright/test'; import { fileURLToPath } from 'node:url'; import path from 'node:path'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const authFile = path.join(__dirname, '../.playwright/.auth/user.json'); setup('authenticate', async ({ page }) => { // Navigate to login page await page.goto('http://localhost:3000/login'); // Fill in the Bluesky handle await page.getByPlaceholder('e.g., yourname.bsky.social').fill('aprongecko.bsky.social'); // Click login button await page.getByRole('button', { name: 'Log in with Bluesky' }).click(); // Wait for OAuth redirect and handle it // This will open the Bluesky authorization page // In a real test, you would need to handle the OAuth flow // For now, we'll wait for the callback await page.waitForURL(/callback/, { timeout: 30000 }); // After successful auth, should redirect to chat await page.waitForURL(/chat/, { timeout: 10000 }); // Verify we're logged in await expect(page.getByText('Ponderants Interview')).toBeVisible(); // Save authenticated state await page.context().storageState({ path: authFile }); });