import { test, expect } from '@playwright/test'; import { login, DEMO } from './helpers/auth'; test.describe('Authentication', () => { test('login page renders correctly', async ({ page }) => { await page.goto('/login'); await expect(page.locator('text=FiberOps')).toBeVisible(); await expect(page.locator('text=Sign in to your account')).toBeVisible(); await expect(page.locator('input[placeholder="e.g. demo-isp"]')).toBeVisible(); await expect(page.locator('input[type="email"]')).toBeVisible(); await expect(page.locator('input[type="password"]')).toBeVisible(); }); test('login with valid credentials redirects to dashboard', async ({ page }) => { await login(page); await expect(page).toHaveURL(/\/dashboard/); }); test('login with wrong credentials shows error', async ({ page }) => { await page.goto('/login'); await page.fill('input[placeholder="e.g. demo-isp"]', DEMO.tenant); await page.fill('input[type="email"]', DEMO.email); await page.fill('input[type="password"]', 'wrongpassword'); await page.click('button[type="submit"]'); // Should show error toast or stay on login await expect(page).toHaveURL(/\/login/); }); test('unauthenticated redirect to login', async ({ page }) => { await page.goto('/dashboard'); await expect(page).toHaveURL(/\/login/); }); test('logout returns to login', async ({ page }) => { await login(page); await page.click('button:has-text("Logout"), a:has-text("Logout")'); await expect(page).toHaveURL(/\/login/); }); });