design: apply Pixel design system tokens (Fira Sans/Code, CSS vars, badge helpers); add Playwright E2E setup + auth spec

This commit is contained in:
Forge
2026-03-26 08:54:44 +08:00
parent 4970c70546
commit 981b415430
8 changed files with 243 additions and 53 deletions

39
e2e/auth.spec.ts Normal file
View File

@@ -0,0 +1,39 @@
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/);
});
});

16
e2e/helpers/auth.ts Normal file
View File

@@ -0,0 +1,16 @@
import { Page } from '@playwright/test';
export const DEMO = {
tenant: 'demo-isp',
email: 'admin@demo-isp.com',
password: 'Admin123!',
};
export async function login(page: Page, creds = DEMO) {
await page.goto('/login');
await page.fill('input[placeholder="e.g. demo-isp"]', creds.tenant);
await page.fill('input[type="email"]', creds.email);
await page.fill('input[type="password"]', creds.password);
await page.click('button[type="submit"]');
await page.waitForURL('**/dashboard', { timeout: 10000 });
}