import { test, expect } from '@playwright/test';

const authFile = 'playwright/.auth/user.json';

test('Authenticate', async ({ page }) => {
  await page.goto('/login');
  await page.waitForSelector('input[name="user"]', { timeout: 3000 });
  await page.getByPlaceholder('Username').fill(process.env.ADMIN_USER);
  await page.getByPlaceholder('Password').fill(process.env.ADMIN_PASS);
  await page.getByRole('link', { name: 'Login' }).click();
  await page.waitForSelector('span:has-text("Quick Actions")', { timeout: 3000 });
  expect(await page.title()).toBe('Difuse - Dashboard - Router');
  await page.context().storageState({ path: authFile });
});