Files
brachnha-insight/_bmad-output/test-design-epic-3.md
Max e9e6fadb1d fix: ChatBubble crash and DeepSeek API compatibility
- Fix ChatBubble to handle non-string content with String() wrapper
- Fix API route to use generateText for non-streaming requests
- Add @ai-sdk/openai-compatible for non-OpenAI providers (DeepSeek, etc.)
- Use Chat Completions API instead of Responses API for compatible providers
- Update ChatBubble tests and fix component exports to kebab-case
- Remove stale PascalCase ChatBubble.tsx file
2026-01-26 16:55:05 +07:00

271 lines
9.6 KiB
Markdown

# Test Design: Epic 3 - "My Legacy" - History, Offline Sync & PWA Polish
**Date:** 2026-01-23
**Author:** Max
**Status:** Approved
---
## Executive Summary
**Scope:** Epic-level test design for Epic 3 covering Story 3.1 (History Feed), 3.2 (Deletion), 3.3 (Offline Sync), and 3.4 (PWA Install). Focus on data integrity, offline resilience, and PWA capabilities.
**Risk Summary:**
- Total risks identified: 4
- High-priority risks (≥6): 2
- Critical categories: DATA, TECH
**Coverage Summary:**
- P0 scenarios: 5 (10 hours)
- P1 scenarios: 6 (6 hours)
- P2/P3 scenarios: 4 (2 hours)
- **Total effort:** 18 hours (~2.5 days)
---
## Risk Assessment
### High-Priority Risks (Score ≥6)
| Risk ID | Category | Description | Probability | Impact | Score | Mitigation | Owner | Timeline |
| ------- | -------- | ------------------------------------------------------------- | ------------ | ------------ | ----- | ---------------------------------------------------------------------------------- | ------ | --------- |
| R-001 | DATA | Data loss during offline-to-online sync if queue fails | 2 (Possible) | 3 (Critical) | 6 | Implement "Action Replay" pattern with retry backoff and persistent queue in Dexie | Dev/QA | Story 3.3 |
| R-002 | DATA | Deletion conflict (deleting item offline that changes online) | 2 (Possible) | 3 (Critical) | 6 | Optimistic UI updates + Soft delete markers + server reconciliation | Dev | Story 3.2 |
### Medium-Priority Risks (Score 3-4)
| Risk ID | Category | Description | Probability | Impact | Score | Mitigation | Owner |
| ------- | -------- | ------------------------------------------------- | ------------ | ------------ | ----- | -------------------------------------------------------------------- | ----- |
| R-003 | PERF | History feed lag with large dataset (>1000 items) | 2 (Possible) | 2 (Degraded) | 4 | Implement virtualization (react-window) and pagination | Dev |
| R-004 | TECH | PWA Install Prompt not appearing on some browsers | 2 (Possible) | 2 (Degraded) | 4 | Fallback manual install instructions / comprehensive browser testing | QA |
### Low-Priority Risks (Score 1-2)
| Risk ID | Category | Description | Probability | Impact | Score | Action |
| ------- | -------- | ------------------------------------------------- | ------------ | ------------ | ----- | ------- |
| R-005 | SEC | Local storage scrutiny (physical access required) | 1 (Unlikely) | 2 (Degraded) | 2 | Monitor |
### Risk Category Legend
- **TECH**: Technical/Architecture
- **SEC**: Security
- **PERF**: Performance
- **DATA**: Data Integrity
- **BUS**: Business Impact
- **OPS**: Operations
---
## Test Coverage Plan
### P0 (Critical) - Run on every commit
**Criteria**: Blocks core journey + High risk (≥6) + No workaround
| Requirement | Test Level | Risk Link | Test Count | Owner | Notes |
| -------------------------- | ----------- | --------- | ---------- | ----- | ------------------------------------------------------- |
| Offline Action Queueing | Integration | R-001 | 3 | Dev | Verify actions added to queue when network disconnected |
| Sync Action Replay | Integration | R-001 | 2 | Dev | Verify queue processes successfully upon reconnection |
| Entry Deletion | Component | R-002 | 1 | Dev | Verify delete dialog and optimistic removal |
| Deletion Persistence | Integration | R-002 | 1 | Dev | Verify deletion persists to DB |
| Initial Load (Empty State) | E2E | - | 1 | QA | Verify app loads correctly for new users |
**Total P0**: 8 tests, 5 hours
### P1 (High) - Run on PR to main
**Criteria**: Important features + Medium risk (3-4) + Common workflows
| Requirement | Test Level | Risk Link | Test Count | Owner | Notes |
| ---------------------- | ----------- | --------- | ---------- | ----- | ---------------------------------------------------- |
| History Feed Rendering | Component | R-003 | 2 | Dev | Verify list renders with mock data |
| PWA Manifest Validity | Unit/Int | R-004 | 1 | Dev | Verify manifest.json served correctly |
| Install Prompt Trigger | Component | R-004 | 1 | Dev | Verify prompt appears on 'beforeinstallprompt' event |
| Pagination/Load More | Integration | R-003 | 1 | Dev | Verify loading more items works |
**Total P1**: 5 tests, 3 hours
### P2 (Medium) - Run nightly/weekly
**Criteria**: Secondary features + Low risk (1-2) + Edge cases
| Requirement | Test Level | Risk Link | Test Count | Owner | Notes |
| ------------------------- | ---------- | --------- | ---------- | ----- | ---------------------------------------------- |
| Data Export Format | Unit | - | 1 | Dev | Verify JSON export structure |
| Scroll Position Retention | E2E | - | 1 | QA | Verify scroll maintained after back navigation |
**Total P2**: 2 tests, 1 hour
### P3 (Low) - Run on-demand
**Criteria**: Nice-to-have + Exploratory + Performance benchmarks
| Requirement | Test Level | Test Count | Owner | Notes |
| -------------------- | ---------- | ---------- | ----- | ---------------------------- |
| Large Dataset Scroll | Perf | 1 | QA | Validate FPS with 1000 items |
**Total P3**: 1 tests, 0.5 hours
---
## Execution Order
### Smoke Tests (<5 min)
**Purpose**: Fast feedback, catch build-breaking issues
- [ ] App Loads (E2E)
- [ ] History Feed Renders (Component)
- [ ] Offline Indicator shows when network off (Integration)
**Total**: 3 scenarios
### P0 Tests (<10 min)
**Purpose**: Critical path validation
- [ ] Offline Sync Queue add/process (Integration)
- [ ] Delete Entry Flow (Integration)
**Total**: 2 scenarios
### P1 Tests (<30 min)
**Purpose**: Important feature coverage
- [ ] PWA Install Prompt (Component)
- [ ] Pagination (Integration)
**Total**: 2 scenarios
### P2/P3 Tests (<60 min)
**Purpose**: Full regression coverage
- [ ] Export Data (Unit)
- [ ] Perf tests
**Total**: 2 scenarios
---
## Resource Estimates
### Test Development Effort
| Priority | Count | Hours/Test | Total Hours | Notes |
| --------- | ------ | ---------- | ----------- | --------------------- |
| P0 | 8 | 0.5 | 4 | Core sync logic tests |
| P1 | 5 | 0.5 | 2.5 | UI/Manifest tests |
| P2 | 2 | 0.5 | 1 | Export/UI polish |
| P3 | 1 | 0.5 | 0.5 | Performance check |
| **Total** | **16** | **-** | **8** | **~1 day** |
### Prerequisites
**Test Data:**
- `ChatSession` factory (faker-based)
- `mock-indexeddb` fixture for fast DB testing
**Tooling:**
- `vitest` for Unit/Integration
- `playwright` for E2E
- `@vite-pwa/assets-generator` for icon validation
**Environment:**
- Local dev environment
- Vercel Preview (for PWA manifest validation)
---
## Quality Gate Criteria
### Pass/Fail Thresholds
- **P0 pass rate**: 100% (no exceptions)
- **P1 pass rate**: ≥95% (waivers required for failures)
- **High-risk mitigations**: 100% complete or approved waivers
### Coverage Targets
- **Critical paths (Sync)**: ≥90%
- **Data Integrity**: 100%
### Non-Negotiable Requirements
- [ ] All P0 (Sync/Delete) tests pass
- [ ] No high-risk (≥6) items unmitigated
---
## Mitigation Plans
### R-001: Data loss during offline-to-online sync (Score: 6)
**Mitigation Strategy:** Implement `SyncManager` class with persistent `ActionQueue` in Dexie. Use exponential backoff for retries.
**Owner:** Dev
**Timeline:** Story 3.3
**Status:** Complete
**Verification:** `integration/offline-sync.test.ts` validates queue persistence and processing.
### R-002: Deletion conflict (Score: 6)
**Mitigation Strategy:** Use soft deletes where possible or last-write-wins with version vector (simplified to local-first authority for MVP).
**Owner:** Dev
**Timeline:** Story 3.2
**Status:** Complete
**Verification:** `components/features/journal/DeleteConfirmDialog.test.tsx` and manual verification.
---
## Assumptions and Dependencies
### Assumptions
1. IndexedDB is reliable on supported browsers.
2. User does not clear browser data while offline with pending actions.
### Dependencies
1. `dexie` library stability.
2. `next-pwa` plugin for Service Worker generation.
---
## Approval
**Test Design Approved By:**
- [ ] Product Manager: Max Date: 2026-01-23
- [ ] Tech Lead: Max Date: 2026-01-23
- [ ] QA Lead: Max Date: 2026-01-23
**Comments:**
Review completed. High risks mitigated by architecture decisions in Epic 3 implementation.
---
## Appendix
### Knowledge Base References
- `risk-governance.md`
- `test-priorities-matrix.md`
### Related Documents
- PRD: `_bmad-output/planning-artifacts/prd.md`
- Epic: `_bmad-output/planning-artifacts/epics.md`
- Architecture: `_bmad-output/planning-artifacts/architecture.md`
---
**Generated by**: BMad TEA Agent - Test Architect Module
**Workflow**: `_bmad/bmm/testarch/test-design`
**Version**: 4.0 (BMad v6)