Files
ProjectE/e2e/reports.spec.ts
T
mbatchelder 8f55626e03 refactor: migrate to monorepo structure with Docker, PocketBase, and e2e tests
- Reorganize into apps/, packages/, docs/, e2e/, pocketbase/ directories
- Add Dockerfiles for web, worker, and PocketBase services
- Add docker-compose.yml for local orchestration
- Add turbo.json for monorepo task management
- Add Playwright e2e test infrastructure
- Add PocketBase backend with migrations
- Remove Vite/Next.js/ESLint/PostCSS config files
- Update package.json with workspace dependencies
- Add .env.example and .dockerignore
2026-07-16 06:19:58 -04:00

105 lines
3.6 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { login } from './helpers/auth';
import { testReports } from './helpers/fixtures';
test.describe('Reports', () => {
test.beforeEach(async ({ page }) => {
await login(page);
await page.goto('/reports');
// Wait for the reports page to load
await expect(page.getByRole('heading', { name: /reports/i })).toBeVisible();
});
test.describe('Reports page layout', () => {
test('should display two-panel layout', async ({ page }) => {
// Reports page has: reports list | editor
await expect(page.getByText(/step back and see/i)).toBeVisible();
await expect(page.getByRole('button', { name: /new report/i })).toBeVisible();
await expect(page.getByRole('button', { name: /from template/i })).toBeVisible();
});
test('should show empty state when no reports exist', async ({ page }) => {
const reportItems = page.locator('button[aria-label^="Open report:"]');
const count = await reportItems.count();
if (count === 0) {
await expect(page.getByText(/no reports yet/i)).toBeVisible();
}
});
});
test.describe('Create report', () => {
test('should create a new report when clicking "New report"', async ({ page }) => {
const createResponsePromise = page.waitForResponse(
(resp) => resp.url().includes('/api/reports') && resp.request().method() === 'POST',
);
await page.getByRole('button', { name: /new report/i }).click();
const response = await createResponsePromise;
expect(response.ok()).toBeTruthy();
await page.waitForTimeout(1_000);
});
});
test.describe('Report from template', () => {
test('should show templates view when clicking "From template"', async ({ page }) => {
await page.getByRole('button', { name: /from template/i }).click();
await page.waitForTimeout(1_000);
// Should show template options or a templates view
});
});
test.describe('Report editor', () => {
test('should show editor when a report is selected', async ({ page }) => {
const reportItems = page.locator('button[aria-label^="Open report:"]');
const count = await reportItems.count();
if (count === 0) {
// Create a report first
await page.getByRole('button', { name: /new report/i }).click();
await page.waitForTimeout(1_000);
}
// Report title input should be visible
await expect(page.getByLabel('Report title')).toBeVisible();
});
test('should update report title when edited', async ({ page }) => {
const reportItems = page.locator('button[aria-label^="Open report:"]');
const count = await reportItems.count();
if (count === 0) {
await page.getByRole('button', { name: /new report/i }).click();
await page.waitForTimeout(1_000);
}
const titleInput = page.getByLabel('Report title');
await expect(titleInput).toBeVisible();
await titleInput.clear();
await titleInput.fill(testReports.title);
await titleInput.blur();
await page.waitForTimeout(500);
});
test('should show report metadata badges', async ({ page }) => {
const reportItems = page.locator('button[aria-label^="Open report:"]');
const count = await reportItems.count();
if (count > 0) {
await reportItems.first().click();
await page.waitForTimeout(500);
// Should show report type and domain badges
const badges = page.locator('[class*="badge"]');
const badgeCount = await badges.count();
expect(badgeCount).toBeGreaterThan(0);
} else {
test.skip();
}
});
});
});