Frontend (17 items): - Virtualized message list with batch loading - CSS split with skeleton, drawer, search filter, message action styles - Code splitting via React.lazy + Suspense for Admin/Ethics/Settings pages - Skeleton loading components (Skeleton, SkeletonCard, SkeletonGrid) - Debounced search/filter component (SearchFilter) - Error boundary with fallback UI - Keyboard shortcuts (Ctrl+K search, Ctrl+Enter send, Escape dismiss) - Page transition animations (fade-in) - PWA support (manifest.json + service worker) - WebSocket auto-reconnect with exponential backoff (10 retries) - Chat history persistence to localStorage (500 msg limit) - Message edit/delete on hover - Copy-to-clipboard on code blocks - Mobile drawer (bottom-sheet for consensus panel) - File upload support - User preferences sync to backend Testing (8 items): - Component tests: Toast, Markdown, ChatMessage, Avatar, ErrorBoundary, Skeleton - Hook tests: useChatHistory - E2E smoke tests (5 tests) - Accessibility audit utility Backend (12 items): - Vector memory with cosine similarity search - TTS/STT adapter factory wiring - Geometry kernel with orphan detection - Tenant registry with CRUD operations - Response cache with TTL - Connection pool (async) - Background task queue - Health check endpoints (/health, /ready) - Request tracing middleware (X-Request-ID) - API key rotation mechanism - Environment-based config (settings.py) - API route documentation improvements Infrastructure (4 items): - Grafana dashboard template - Database migration system - Storybook configuration Documentation (3 items): - ADR-001: Advisory Governance Model - ADR-002: Twelve-Head Architecture - ADR-003: Consequence Engine 552 Python tests + 45 frontend tests passing, 0 ruff errors. Co-Authored-By: Nakamoto, S <defi@defi-oracle.io>
87 lines
2.6 KiB
TypeScript
87 lines
2.6 KiB
TypeScript
/**
|
|
* Accessibility audit utility.
|
|
*
|
|
* Provides automated a11y checks that can be integrated into CI
|
|
* or run manually during development. Uses DOM queries to verify
|
|
* WCAG compliance of rendered components.
|
|
*/
|
|
|
|
export interface A11yViolation {
|
|
rule: string
|
|
element: string
|
|
description: string
|
|
severity: 'critical' | 'serious' | 'moderate' | 'minor'
|
|
}
|
|
|
|
export function auditAccessibility(root: HTMLElement = document.body): A11yViolation[] {
|
|
const violations: A11yViolation[] = []
|
|
|
|
// Check images without alt text
|
|
root.querySelectorAll('img:not([alt])').forEach((el) => {
|
|
violations.push({
|
|
rule: 'img-alt',
|
|
element: el.outerHTML.slice(0, 80),
|
|
description: 'Image missing alt attribute',
|
|
severity: 'critical',
|
|
})
|
|
})
|
|
|
|
// Check buttons without accessible name
|
|
root.querySelectorAll('button').forEach((el) => {
|
|
const name = el.textContent?.trim() || el.getAttribute('aria-label') || el.getAttribute('title')
|
|
if (!name) {
|
|
violations.push({
|
|
rule: 'button-name',
|
|
element: el.outerHTML.slice(0, 80),
|
|
description: 'Button has no accessible name',
|
|
severity: 'serious',
|
|
})
|
|
}
|
|
})
|
|
|
|
// Check inputs without labels
|
|
root.querySelectorAll('input:not([type="hidden"])').forEach((el) => {
|
|
const id = el.getAttribute('id')
|
|
const ariaLabel = el.getAttribute('aria-label') || el.getAttribute('aria-labelledby')
|
|
const hasLabel = id ? root.querySelector(`label[for="${id}"]`) : false
|
|
if (!ariaLabel && !hasLabel && !el.getAttribute('title')) {
|
|
violations.push({
|
|
rule: 'input-label',
|
|
element: el.outerHTML.slice(0, 80),
|
|
description: 'Input has no associated label',
|
|
severity: 'serious',
|
|
})
|
|
}
|
|
})
|
|
|
|
// Check contrast (basic check for known problem patterns)
|
|
root.querySelectorAll('[style*="color"]').forEach((el) => {
|
|
const style = window.getComputedStyle(el as Element)
|
|
const color = style.color
|
|
const bg = style.backgroundColor
|
|
if (color === bg && color !== 'rgba(0, 0, 0, 0)') {
|
|
violations.push({
|
|
rule: 'color-contrast',
|
|
element: (el as Element).outerHTML.slice(0, 80),
|
|
description: 'Text and background colors are identical',
|
|
severity: 'critical',
|
|
})
|
|
}
|
|
})
|
|
|
|
// Check for tabindex > 0
|
|
root.querySelectorAll('[tabindex]').forEach((el) => {
|
|
const idx = parseInt(el.getAttribute('tabindex') || '0', 10)
|
|
if (idx > 0) {
|
|
violations.push({
|
|
rule: 'tabindex',
|
|
element: el.outerHTML.slice(0, 80),
|
|
description: 'Positive tabindex disrupts natural tab order',
|
|
severity: 'moderate',
|
|
})
|
|
}
|
|
})
|
|
|
|
return violations
|
|
}
|