Add Playwright e2e coverage + comment-level video upload workflow (#40)
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m31s
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m31s
## Summary - add Playwright e2e auth setup + seeded test DB flow - fix Playwright startup order so DB seed runs before web server uses SQLite - add full trip-planning e2e scenario (future trip, travellers, destination, flight, lodging, upcoming verification) - configure Auth.js custom sign-in page for base-path routing - add repo guidance in AGENTS.md / CLAUDE.md requiring e2e for user-facing changes - document and validate comment-level Gitea video attachment workflow (create comment, upload to comment assets endpoint) ## Validation - bunx playwright test e2e/auth.test.ts --project=chromium\n- bunx playwright test e2e/trip-planning.test.ts --project=chromium - PW_VIDEO_MODE=on PW_TRACE_MODE=off bunx playwright test e2e/trip-planning.test.ts --project=chromium ## Issue - relates to #38 Co-authored-by: AI Agent <ai-agent@campbellwireless.net> Reviewed-on: #40 Co-authored-by: Shaun Campbell <shaun@campbellwireless.net> Co-committed-by: Shaun Campbell <shaun@campbellwireless.net>
This commit was merged in pull request #40.
This commit is contained in:
56
e2e/auth.test.ts
Normal file
56
e2e/auth.test.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { TEST_USERS } from './setup/test-users.js';
|
||||
|
||||
const LOGIN_URL = '/trips/login';
|
||||
const DASHBOARD_URL = '/trips/dashboard';
|
||||
const ADMIN_USERS_URL = '/trips/admin/users';
|
||||
|
||||
async function loginAsLocalUser(page: Page, username: string, password: string): Promise<void> {
|
||||
await page.goto(LOGIN_URL);
|
||||
await page.fill('input[name="identifier"]', username);
|
||||
await page.fill('input[name="password"]', password);
|
||||
await page.click('button[type="submit"]:has-text("Sign in locally")');
|
||||
await page.waitForURL(`**${DASHBOARD_URL}`, { timeout: 15_000 });
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
await context.clearCookies();
|
||||
});
|
||||
|
||||
test.describe('regular user', () => {
|
||||
test('can log in and lands on dashboard', async ({ page }) => {
|
||||
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await expect(page).toHaveURL(/\/trips\/dashboard/);
|
||||
});
|
||||
|
||||
test('cannot access admin — redirected to dashboard', async ({ page }) => {
|
||||
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await page.goto(ADMIN_USERS_URL);
|
||||
await expect(page).toHaveURL(/\/trips\/dashboard/);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('admin user', () => {
|
||||
test('can log in and lands on dashboard', async ({ page }) => {
|
||||
await loginAsLocalUser(page, TEST_USERS.admin.username, TEST_USERS.admin.password);
|
||||
await expect(page).toHaveURL(/\/trips\/dashboard/);
|
||||
});
|
||||
|
||||
test('can access /admin/users', async ({ page }) => {
|
||||
await loginAsLocalUser(page, TEST_USERS.admin.username, TEST_USERS.admin.password);
|
||||
await page.goto(ADMIN_USERS_URL);
|
||||
await expect(page).toHaveURL(/\/trips\/admin\/users/);
|
||||
await expect(page.locator('h1')).toContainText('Users');
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('error handling', () => {
|
||||
test('bad password shows error on login page', async ({ page }) => {
|
||||
await page.goto(LOGIN_URL);
|
||||
await page.fill('input[name="identifier"]', TEST_USERS.regular.username);
|
||||
await page.fill('input[name="password"]', 'wrong-password-long-enough');
|
||||
await page.click('button[type="submit"]:has-text("Sign in locally")');
|
||||
await page.waitForURL(/error=CredentialsSignin/, { timeout: 10_000 });
|
||||
await expect(page.locator('.text-rose-700')).toContainText('Invalid credentials');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user