feat: add testing infrastructure — Vitest, Playwright, CI, git hooks
Some checks are pending
Test / vitest (push) Waiting to run
Test / playwright (push) Blocked by required conditions
Test / visual (push) Blocked by required conditions

Add comprehensive testing covering 420 unit/handler tests across 24 Vitest
files, 9 Playwright E2E specs, accessibility scans, and visual regression.
Includes GitHub Actions CI, Husky pre-push hook, and TESTING.md docs.
This commit is contained in:
Jennie Robinson Faber 2026-04-04 16:07:21 +01:00
parent 036af95e00
commit 1e30ba23cd
35 changed files with 3637 additions and 5 deletions

48
e2e/admin-members.spec.js Normal file
View file

@ -0,0 +1,48 @@
import { test, expect } from './helpers/fixtures.js'
test.describe('Admin members page', () => {
test('members list loads for admin', async ({ adminPage }) => {
await adminPage.goto('/admin/members')
await expect(adminPage.locator('h1')).toHaveText('Members')
await expect(adminPage.getByText('Manage members, contributions, and access')).toBeVisible()
})
test('search bar works', async ({ adminPage }) => {
await adminPage.goto('/admin/members')
const searchInput = adminPage.getByPlaceholder('Search members...')
await expect(searchInput).toBeVisible()
await searchInput.fill('nonexistent-query-xyz')
// Page should not crash -- either shows filtered results or the empty state
await expect(
adminPage.locator('table').or(adminPage.getByText('No members found matching your criteria'))
).toBeVisible()
})
test('non-admin redirect', async ({ browser }) => {
const context = await browser.newContext()
const page = await context.newPage()
await page.goto('/admin/members')
// Admin middleware redirects non-admin users to / or /members
await page.waitForURL((url) => !url.pathname.startsWith('/admin'))
expect(page.url()).not.toContain('/admin/members')
await context.close()
})
test('add member button opens modal', async ({ adminPage }) => {
await adminPage.goto('/admin/members')
await adminPage.getByRole('button', { name: 'Add Member' }).click()
// Modal should appear with the form heading and fields
await expect(adminPage.getByText('Add New Member')).toBeVisible()
await expect(adminPage.getByPlaceholder('Full name')).toBeVisible()
await expect(adminPage.getByPlaceholder('email@example.com')).toBeVisible()
})
})