UNPKG

oneie

Version:

Build apps, websites, and AI agents in English. Zero-interaction setup for AI agents (Claude Code, Cursor, Windsurf). Download to your computer, run in the cloud, deploy to the edge. Open source and free forever.

577 lines (428 loc) 14.2 kB
--- title: 2 Tests dimension: things category: features tags: agent, ai, backend, frontend related_dimensions: knowledge scope: global created: 2025-11-03 updated: 2025-11-03 version: 1.0.0 ai_context: | This document is part of the things dimension in the features category. Location: one/things/features/2-tests.md Purpose: Documents feature 2: backend-agnostic frontend - test specification Related dimensions: knowledge For AI agents: Read this to understand 2 tests. --- # Feature 2: Backend-Agnostic Frontend - Test Specification **Feature ID:** `feature_2_tests` **Plan:** `plan_2_backend_agnostic_frontend` **Owner:** Quality Agent **Status:** Awaiting Detailed Specification **Priority:** P0 (Critical - Quality Assurance) **Effort:** Ongoing throughout all features **Dependencies:** All features 2-1 through 2-7 --- ## Assignment This feature is assigned to **Quality Agent**. ### Instructions Please create a COMPREHENSIVE test specification covering: 1. **Complete Test Strategy** - Test categories (unit, integration, e2e, performance) - Test coverage requirements (90%+ unit, 80%+ integration) - Test execution schedule (after each feature) - Test environments (dev, staging, production) 2. **Test Cases for All Features** - Feature 2-1: DataProvider Interface & ConvexProvider (20+ test cases) - Feature 2-2: Configuration System (15+ test cases) - Feature 2-3: Effect.ts Services (30+ test cases) - Feature 2-4: React Hooks (25+ test cases) - Feature 2-5: Auth Migration (50+ test cases - CRITICAL) - Feature 2-6: Dashboard Migration (40+ test cases) - Feature 2-7: Alternative Providers (30+ test cases) 3. **Acceptance Criteria (Per Feature)** - Functional requirements checklist - Non-functional requirements checklist - Performance benchmarks - Security requirements - Accessibility requirements 4. **Quality Gates** - Gate 1: Interface Complete (End of Week 1) - Gate 2: Services Complete (End of Week 2) - Gate 3: Auth Migration Complete (End of Week 3) - Gate 4: Full Migration Complete (End of Week 4) - Gate 5: Alternative Providers Working (End of Week 6) 5. **CI/CD Configuration** - Automated test execution - Pre-commit hooks - Pull request checks - Deployment gates 6. **Performance Testing** - Baseline performance metrics - Performance targets (<10ms DataProvider overhead) - Load testing scenarios - Real-time update performance 7. **Regression Testing** - Auth regression suite (50+ tests MUST pass) - Dashboard regression suite - E2E regression suite - Visual regression testing --- ## Test Categories ### 1. Unit Tests (90%+ Coverage) **DataProvider Interface (Feature 2-1):** - [ ] Interface defines all 6-dimension operations - [ ] ConvexProvider implements all operations - [ ] ConvexProvider handles errors correctly - [ ] ConvexProvider transforms data correctly - [ ] Provider factory creates correct provider type - [ ] Type safety enforced at compile time **Configuration System (Feature 2-2):** - [ ] Environment variables parsed correctly - [ ] Provider registry manages multiple providers - [ ] Provider switching works - [ ] Multi-tenant isolation maintained - [ ] Configuration validation catches errors - [ ] Invalid configurations rejected **Effect.ts Services (Feature 2-3):** - [ ] ThingService creates things - [ ] ThingService lists things with filters - [ ] ThingService updates things - [ ] ThingService deletes things - [ ] ConnectionService creates connections - [ ] EventService logs events - [ ] Error handling works with Effect.ts - [ ] Business rules enforced **React Hooks (Feature 2-4):** - [ ] useThings hook fetches entities - [ ] useThing hook fetches single entity - [ ] useCreateThing hook creates entities - [ ] useConnections hook fetches relationships - [ ] useEvents hook fetches events - [ ] Loading states work correctly - [ ] Error states work correctly - [ ] Real-time updates work ### 2. Integration Tests (80%+ Coverage) **Auth Migration (Feature 2-5):** - [ ] Email/password login works end-to-end - [ ] Email/password signup works end-to-end - [ ] OAuth (Google) login works - [ ] OAuth (GitHub) login works - [ ] OAuth (Apple) login works - [ ] Magic link login works - [ ] Password reset flow works - [ ] Email verification works - [ ] 2FA setup works - [ ] 2FA verification works - [ ] Session management works - [ ] Logout works **Dashboard Migration (Feature 2-6):** - [ ] Dashboard loads with DataProvider - [ ] CourseList displays courses - [ ] CourseDetail shows course data - [ ] LessonList displays lessons - [ ] ActivityFeed shows recent events - [ ] SearchBar searches entities - [ ] CRUD operations work - [ ] Real-time updates work - [ ] Navigation works **Alternative Providers (Feature 2-7):** - [ ] WordPressProvider creates things - [ ] WordPressProvider lists things - [ ] WordPressProvider updates things - [ ] NotionProvider creates things - [ ] NotionProvider lists things - [ ] NotionProvider updates things - [ ] Multi-backend scenarios work - [ ] Provider switching works - [ ] Data integrity maintained ### 3. End-to-End Tests **Complete User Flows:** - [ ] User signs up → creates course → adds lessons → publishes - [ ] User logs in → views dashboard → edits course → logs out - [ ] User resets password → receives email → sets new password → logs in - [ ] Org owner switches backend provider → all data migrates correctly - [ ] Student enrolls in course → completes lessons → receives certificate ### 4. Performance Tests **Baseline Metrics (Convex):** - [ ] Login: <500ms (p95) - [ ] Dashboard load: <1000ms (p95) - [ ] Entity list: <300ms (p95) - [ ] Entity detail: <200ms (p95) - [ ] Search: <500ms (p95) **Target Metrics (DataProvider):** - [ ] DataProvider overhead: <10ms (p95) - [ ] Login: <550ms (p95) - Within 10% - [ ] Dashboard load: <1100ms (p95) - Within 10% - [ ] Entity list: <330ms (p95) - Within 10% - [ ] Entity detail: <220ms (p95) - Within 10% - [ ] Search: <550ms (p95) - Within 10% **Load Testing:** - [ ] 100 concurrent users - response times acceptable - [ ] 1000 concurrent users - response times acceptable - [ ] 10,000 entities - query performance acceptable - [ ] Real-time updates with 100 subscribers - no lag ### 5. Security Tests **Authentication & Authorization:** - [ ] Unauthorized users cannot access protected routes - [ ] Role-based permissions enforced - [ ] SQL injection attempts blocked - [ ] XSS attempts sanitized - [ ] CSRF protection enabled - [ ] API keys secured - [ ] Sensitive data encrypted **Multi-Tenant Isolation:** - [ ] Org A cannot access Org B data - [ ] Provider switching doesn't leak data - [ ] Cross-org queries blocked - [ ] Event logs respect org boundaries ### 6. Accessibility Tests **WCAG 2.1 AA Compliance:** - [ ] Keyboard navigation works - [ ] Screen reader compatible - [ ] Color contrast meets standards - [ ] Focus indicators visible - [ ] ARIA labels correct - [ ] Forms accessible --- ## Quality Gates ### Gate 1: Interface Complete (End of Week 1) **Checklist:** - [ ] All unit tests pass (Feature 2-1, 2-2) - [ ] TypeScript compiles with zero errors - [ ] Performance baseline established - [ ] Documentation complete - [ ] Code review approved **Approval Required From:** - Backend Specialist (implementation complete) - Quality Agent (tests pass) - Engineering Director (gate approval) --- ### Gate 2: Services Complete (End of Week 2) **Checklist:** - [ ] All unit tests pass (Feature 2-3, 2-4) - [ ] Integration tests pass - [ ] Effect.ts error handling works - [ ] React hooks work with DataProvider - [ ] Documentation complete - [ ] Code review approved **Approval Required From:** - Backend Specialist (services complete) - Frontend Specialist (hooks complete) - Quality Agent (tests pass) - Engineering Director (gate approval) --- ### Gate 3: Auth Migration Complete (End of Week 3) **Checklist:** - [ ] **ALL 50+ auth tests pass** (NO EXCEPTIONS) - [ ] Zero functionality regression - [ ] Performance within 10% of baseline - [ ] No TypeScript errors - [ ] No direct Convex imports in auth - [ ] Documentation updated - [ ] Code review approved **Approval Required From:** - Frontend Specialist (migration complete) - Quality Agent (ALL tests pass) - Engineering Director (gate approval) **CRITICAL:** This is the highest-risk gate. All 50+ auth tests MUST pass before proceeding. --- ### Gate 4: Full Migration Complete (End of Week 4) **Checklist:** - [ ] All dashboard components migrated - [ ] All tests pass (unit, integration, e2e) - [ ] Performance maintained - [ ] Zero TypeScript errors - [ ] No direct Convex imports in components - [ ] Documentation updated - [ ] Migration guide published - [ ] Code review approved **Approval Required From:** - Frontend Specialist (dashboard complete) - Quality Agent (all tests pass) - Engineering Director (gate approval) --- ### Gate 5: Alternative Providers Working (End of Week 6) **Checklist:** - [ ] WordPress provider functional - [ ] Notion provider functional - [ ] Multi-backend tests pass - [ ] Provider switching works - [ ] Data integrity validated - [ ] Performance acceptable - [ ] Provider creation guide complete - [ ] Documentation complete - [ ] Code review approved **Approval Required From:** - Integration Specialist (providers complete) - Quality Agent (all tests pass) - Engineering Director (gate approval) --- ## CI/CD Configuration ### Pre-Commit Hooks ```bash # .husky/pre-commit #!/bin/bash # 1. Run type checking echo "Running TypeScript type checking..." cd frontend && bunx astro check if [ $? -ne 0 ]; then echo "❌ Type checking failed" exit 1 fi # 2. Run linting echo "Running ESLint..." bun run lint if [ $? -ne 0 ]; then echo "❌ Linting failed" exit 1 fi # 3. Run unit tests echo "Running unit tests..." bun test --run if [ $? -ne 0 ]; then echo "❌ Unit tests failed" exit 1 fi echo "✅ Pre-commit checks passed" ``` ### Pull Request Checks ```yaml # .github/workflows/pr-checks.yml name: Pull Request Checks on: pull_request: branches: [main, develop] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: oven-sh/setup-bun@v1 - name: Install dependencies run: cd frontend && bun install - name: Type check run: cd frontend && bunx astro check - name: Lint run: cd frontend && bun run lint - name: Unit tests run: cd frontend && bun test --run - name: Integration tests run: cd frontend && bun test:integration --run - name: E2E tests run: cd frontend && bun test:e2e --run - name: Performance tests run: cd frontend && bun test:performance --run ``` ### Deployment Gates ```yaml # Deploy only if all tests pass deploy: needs: [test] if: success() runs-on: ubuntu-latest steps: - name: Deploy to Cloudflare Pages run: wrangler pages deploy dist ``` --- ## Test Execution Schedule ### Daily (During Development) - Run unit tests after each code change - Run integration tests for affected features - Monitor test coverage (maintain 90%+ unit, 80%+ integration) ### Per Feature Completion - Run full test suite for completed feature - Run regression tests for all previous features - Performance benchmarks - Security scans ### Weekly - Full regression test suite - E2E test suite - Load testing - Visual regression testing - Accessibility audit ### Before Release - Complete test suite (all categories) - Performance validation - Security audit - Accessibility validation - Documentation review --- ## Test Environments ### Development - Local Convex deployment - Local frontend (localhost:4321) - Mock external services - Fast feedback loop ### Staging - Staging Convex deployment - Staging frontend (staging.one-platform.com) - Real WordPress instance (staging) - Real Notion workspace (staging) - Production-like environment ### Production - Production Convex deployment - Production frontend (one-platform.com) - Production external services - Monitoring and alerting --- ## Regression Testing ### Auth Regression Suite (50+ Tests) **Must Run After:** - Any auth component change - Any DataProvider change - Any hook change - Feature 2-5 (Auth Migration) **Test Categories:** 1. Email/password authentication (10 tests) 2. OAuth authentication (15 tests) 3. Magic link authentication (5 tests) 4. Password reset (5 tests) 5. Email verification (5 tests) 6. 2FA (10 tests) **Success Criteria:** - ALL 50+ tests MUST pass - Zero functionality regression - Performance within 10% of baseline ### Dashboard Regression Suite (40+ Tests) **Must Run After:** - Any dashboard component change - Any DataProvider change - Any hook change - Feature 2-6 (Dashboard Migration) **Test Categories:** 1. Entity lists (10 tests) 2. Entity details (10 tests) 3. Activity feed (5 tests) 4. Search (10 tests) 5. CRUD operations (5 tests) ### E2E Regression Suite **Must Run After:** - Any major change - Before release **Test Scenarios:** 1. Complete user signup → course creation → lesson addition → publish flow 2. Complete login → dashboard → edit → logout flow 3. Complete password reset flow 4. Complete multi-backend switching flow --- ## Related Files - **Plan:** `one/things/plans/2-backend-agnostic-frontend.md` - **All Features:** `one/things/features/2-{1-7}-*.md` - **Test Implementations:** `frontend/test/` (directory) - **CI/CD Config:** `.github/workflows/` (directory) --- ## Next Steps 1. **Quality Agent:** Create detailed test specifications for each feature 2. **Quality Agent:** Set up test infrastructure 3. **Quality Agent:** Define performance baselines 4. **Quality Agent:** Configure CI/CD pipelines 5. **Quality Agent:** Run tests after each feature completion 6. **Quality Agent:** Report quality metrics to Director --- **Status:** Awaiting Quality Agent to populate detailed test specifications **Created:** 2025-10-13 **Validated By:** Engineering Director Agent **Critical:** Auth regression suite (50+ tests) MUST pass at Gate 3