import { test, expect } from './fixtures';

test('Debug Login Payload', async ({ page, createUniqueUser }) => {
    const user = await createUniqueUser();
    console.log('Created user:', user);

    await page.goto('/');

    // Intercept login request
    await page.route('**/api/auth/login', async route => {
        const request = route.request();
        const postData = request.postDataJSON();
        console.log('LOGIN REQUEST BODY:', JSON.stringify(postData, null, 2));
        console.log('LOGIN REQUEST HEADERS:', JSON.stringify(request.headers(), null, 2));
        await route.continue();
    });

    await page.getByLabel('Email').fill(user.email);
    await page.getByLabel('Password').fill(user.password);
    await page.getByRole('button', { name: 'Login' }).click();

    // Wait a bit for request to happen
    await page.waitForTimeout(3000);
});
