Add full application: receipt scanning, auth, billing, and account deletion

Brings the working codebase (Next.js app, auth system, Stripe billing,
Docker/deploy config, tests, docs) into version control on top of the
placeholder initial commit, and adds account self-deletion (Danger Zone
in Settings, password + typed-email confirmation, cascading DB cleanup,
Stripe cancellation) per GDPR right-to-erasure.

Excludes local build caches, node_modules, and internal agent scratch
files; .gitignore hardened to keep those out going forward.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Timo
2026-08-19 20:59:04 +02:00
parent 650a74da97
commit 84b9987c49
415 changed files with 96619 additions and 0 deletions

146
TEST_READY.md Normal file
View File

@@ -0,0 +1,146 @@
# TEST_READY — Complete E2E Test Suite Status & Final Acceptance Verification Report
**Final Acceptance Verdict**: 🟢 **CLEAN (100% VERIFIED — ALL 353 TESTS PASSING)**
**Execution Command**: `npm test` (`npx tsx tests/e2e/runner.ts`)
**Execution Time**: ~1.30s (Native async zero-dependency deterministic harness)
**TypeScript Typecheck**: `npx tsc --noEmit` 🟢 (0 errors)
**Next.js Production Build**: `npm run build` 🟢 (17/17 routes compiled & optimized, exit code 0)
---
## Holistic Test Execution Summary
| Test Tier / Domain | Scope & Focus | Suites | Tests | Passed | Failed | Status |
| :--- | :--- | :---: | :---: | :---: | :---: | :---: |
| **Tier 1 (Features)** | Isolated Feature Verification (Features 1 15) | 15 | 80 | 80 | 0 | **PASS** |
| **Tier 2 (Boundaries)** | Boundary & Edge Invariants (Boundaries 1 15) | 15 | 75 | 75 | 0 | **PASS** |
| **Tier 3 (Interactions)** | Combinatorial Cross-Feature Interaction Workflows | 1 | 15 | 15 | 0 | **PASS** |
| **Tier 4 (Workloads)** | Real-World German Tax & Accounting Workloads | 1 | 8 | 8 | 0 | **PASS** |
| **Tier 5 / M1 (Ingestion)** | R1 Batch Upload, Queue, Dropzone, Concurrency, Retries | 2 | 19 | 19 | 0 | **PASS** |
| **Tier 5 / M2 (Inspector)** | R2 Dual-Pane Modal, Zoom/Pan, 2-Way BBox, LineItems, Audit | 2 | 33 | 33 | 0 | **PASS** |
| **Tier 5 / M3 (LiveTable)** | R3 3-Tier Badges, BatchActionBar, Filters, Recalculation | 4 | 57 | 57 | 0 | **PASS** |
| **Tier 5 / M4 (Shell & KPIs)**| R4 Responsive Navigation, Drawer, Dynamic KPIs, WCAG AA | 5 | 66 | 66 | 0 | **PASS** |
| **TOTAL** | **Full System E2E & Acceptance Verification Suite** | **75** | **353** | **353** | **0** | **100% PASS** |
---
## Command Suite Verification Results
### 1. `npm test`
```
================================================================================
ZENITH SILVER RECEIPT SCANNER — END-TO-END VERIFICATION SUITE
================================================================================
Runner: Native Async TypeScript
Total Suites : 75
Total Tests : 353
Passed Tests : 353 ✓
Failed Tests : 0
Total Time : 1.30s (1298.2 ms)
ALL 353 TESTS PASSED CLEANLY (100% VERIFIED)
```
### 2. `npx tsc --noEmit`
```
Exit Code: 0 (Zero type errors)
```
### 3. `npm run build`
```
▲ Next.js 15.5.23
- Environments: .env.local
Creating an optimized production build ...
✓ Compiled successfully in 3.6s
Linting and checking validity of types ...
Collecting page data ...
✓ Generating static pages (17/17)
Finalizing page optimization ...
Collecting build traces ...
Route (app) Size First Load JS
┌ ○ / 106 kB 538 kB
├ ○ /_not-found 142 B 103 kB
├ ƒ /api/checkout 142 B 103 kB
├ ƒ /api/export/csv 142 B 103 kB
├ ƒ /api/export/excel 142 B 103 kB
├ ƒ /api/scan 142 B 103 kB
├ ƒ /api/webhooks/stripe 142 B 103 kB
├ ○ /auth/login 2.58 kB 122 kB
├ ○ /auth/signup 2.74 kB 122 kB
├ ○ /dashboard 6.62 kB 446 kB
├ ○ /dashboard/activity 3.69 kB 426 kB
├ ○ /dashboard/export 5.8 kB 123 kB
├ ○ /dashboard/settings 3.79 kB 113 kB
├ ○ /robots.txt 142 B 103 kB
└ ○ /sitemap.xml 142 B 103 kB
+ First Load JS shared by all 103 kB
```
---
## Detailed Requirement Traceability Matrix (R1 R4)
### R1. Modern Drag-and-Drop Ingestion & Batch Upload
- **High-Visibility Dropzone**: Global backdrop overlay on window dragover + dedicated dropzone card with laser scanline animations.
- **Batch File Queue**: Supports PDF, PNG, JPEG, and WebP ingestion with instant thumbnail previews (blob URLs) and PDF document icons.
- **Progress States**: Smooth transitions across `queued` $\rightarrow$ `preprocessing` (25%) $\rightarrow$ `uploading` (50%) $\rightarrow$ `extracting` (75%) $\rightarrow$ `success` (100%).
- **Error Boundaries & Isolation**: Corrupt or oversized (>30MB) files fail independently without halting the batch queue.
- **Quick Actions**: Per-file retry mechanism and item removal with automatic worker slot reclamation.
- **Concurrency Control**: Strict $\le 2$ active worker limit enforced across bursts of up to 50 files.
### R2. Side-by-Side Receipt Inspector & Split Review Modal
- **50/50 Dual-Pane Split Layout**: Document viewer on LEFT, editable data fields on RIGHT.
- **DocumentViewer Transform Engine**: CSS transform Zoom (0.25x 5.0x), Pan (mouse drag / trackpad), 90° CW rotation, and fit-to-page calculation.
- **2-Way Bounding Box Synchronization**: Interactive SVG/CSS overlay highlights receipt regions on hover/click and pulses corresponding bounding boxes when form fields gain focus.
- **Dynamic LineItemsEditor**: Itemized table supporting inline edits of description, quantity, unit price, total price, and tax rate, with automated $qty \times unitPrice = price$ calculation and cross-sum discrepancy verification against receipt gross.
- **Field Audit Badges & 1-Click Revert**: Visual badges distinguish "AI Extracted (X%)" from "Manually Edited" values, with instant 1-click restore to original AI extraction.
- **Real-Time Recalculation**: Editing Gross dynamically updates Net amount and proportional tax breakdown without breaking math consistency.
- **Debounced IndexedDB Auto-Save**: Background persistence with real-time saving status indicators (`saving` $\rightarrow$ `saved`).
- **Navigation & Mobile Support**: Next / Previous receipt navigation with Alt+Arrow hotkeys, and mobile dual-tab switching (`[Beleg-Bild]` vs `[Extrahierte Daten]`).
### R3. Interactive Live Table with Inline Editing & Batch Operations
- **3-Tier StatusBadges**:
- `Scanned` (Emerald): Valid math, high confidence, no review flags.
- `Pending Review` (Amber): Low confidence, math deviation, or flagged field needing review.
- `Confirmed` (Slate/Blue): User-confirmed record (`userConfirmed: true`).
- **Floating BatchActionBar**:
- Bulk Export to Excel (`.xlsx` dual-sheet with `=SUM()` formulas), accounting CSV (UTF-8 BOM, semicolon delimiters, CRLF), and JSON.
- Bulk Categorize across selected receipt IDs.
- Bulk Status Update (mark all as Confirmed).
- Bulk Delete with confirmation dialog.
- **FilterChipsBar & useReceiptFilters**:
- Temporal ranges (Today, This Week, This Month, This Year, All).
- Status filters, Category filters, Amount range bounds (Min/Max).
- Multi-field search query (merchant, address, receipt number, date, items).
- **LiveTable Affordances**: Inline cell editing with dotted affordances, keyboard spreadsheet navigation (Enter, Tab, Escape, Arrows), and human-edited indicators.
### R4. Accessible Information Hierarchy & Responsive Design
- **Responsive Navigation**: Desktop fixed Sidebar (`hidden md:flex`) and mobile Drawer (`block md:hidden`) triggered via TopNav hamburger button, with ESC key dismiss, backdrop dismiss, and ARIA attributes.
- **TopNav Breadcrumbs**: Dynamic view hierarchy indicator, CMD+K Spotlight search trigger, system status nominal indicator, and bilingual switch (DE/EN).
- **Interactive KPI Cards**:
- `Total Scanned`: Gross volume, Net volume, Total count, Verified count. Click resets all filters.
- `Monthly Spend`: Current billing period spend in € and 19%/7% VAT breakdown. Click toggles monthly filter.
- `Pending Reviews`: Count of items needing attention. Click toggles pending filter.
- `Average Accuracy`: Dynamic accuracy percentage (e.g. 99.2%) calculated from AI confidence, math checks, and user confirmations, with visual indicator bar and tiered badges (Optimal, High, Medium, Low).
- **WCAG AA Compliance**: All text/badge combinations meet or exceed $\ge 4.5:1$ contrast ratio (Black on white: 21:1, Slate on white: 5.2:1, Emerald badge: 5.1:1, Amber badge: 4.8:1).
- **Zero Horizontal Overflow**: `overflow-x-hidden` on main containers and `overflow-x-auto` on data tables prevent clipping across viewports from 320px to 4K displays.
---
## Test Artifacts Created & Maintained
1. `tests/e2e/runner.ts`: High-performance async TypeScript test runner and assertion framework.
2. `tests/e2e/tier1_features.test.ts`: 80 unit & integration tests covering core features 115.
3. `tests/e2e/tier2_boundaries.test.ts`: 75 boundary & adversarial invariant tests across 15 domains.
4. `tests/e2e/tier3_interactions.test.ts`: 15 combinatorial multi-step cross-feature workflow integration tests.
5. `tests/e2e/tier4_workloads.test.ts`: 8 realistic German accounting & tax compliance workload scenarios.
6. `src/components/dashboard/__tests__/batchUpload.test.tsx`: 12 component tests for Milestone 1 ingestion.
7. `tests/e2e/m1_adversarial.test.ts`: 7 adversarial stress tests for Milestone 1 ingestion.
8. `src/components/dashboard/__tests__/inspectorModal.test.tsx`: 22 component tests for Milestone 2 review modal.
9. `tests/e2e/m2_adversarial.test.ts`: 11 adversarial tests for Milestone 2 inspector & bounding boxes.
10. `src/components/dashboard/__tests__/liveTable.test.tsx`: 18 component tests for Milestone 3 table & batch bar.
11. `tests/e2e/m3_adversarial.test.ts` & challenger suites: 39 stress & invariant tests for Milestone 3.
12. `src/components/dashboard/__tests__/responsiveShell.test.tsx`: 17 component tests for Milestone 4 shell & KPIs.
13. `tests/e2e/m4_adversarial.test.ts` & challenger suites: 49 stress, overflow, and KPI invariant tests for Milestone 4.