Skip to content

Screen 5: Export #33

Closed

Description

@adamveld12

Story 5: As an adjuster, I can export my completed assessment

  • User exports completed assessment as organized .zip file
  • User shares .zip via email/messaging to claims department

Generate .zip file with:

  • Photos named by position (LeftSide.jpg, Front.jpg, etc.)
  • Text files with damage notes (LeftSide_label.txt, etc.)
  • Use native OS share sheet for email/messaging
  • Mark assessment as complete
Assessment Complete!
9 photos captured
[Export Assessment Button]
→ Creates: Assessment_[VIN]_[Date].zip
  - LeftSide.jpg
  - LeftSide_label.txt
  - Front.jpg
  - Front_label.txt
  ... etc

Activity

  1. added
    Enhancement
    on Sep 6, 2025
  2. self-assigned this
    on Oct 21, 2025
  3. adamveld12 commented on Oct 21, 2025

    @adamveld12
    ContributorAuthor

    Background Context Report

    Problem Statement

    Adjusters need the ability to export completed assessments as a shareable package containing all photos and damage notes. The export must be organized, easily shareable via email/messaging, and mark the assessment as complete.

    Services/Areas Involved

    • Photo Storage Layer: IndexedDB (photo-storage-indexeddb.ts) for retrieving photo blobs
    • Claims Management: useClaims() hook and claim storage for assessment data
    • Photo Position System: photo-positions.ts for position labels and metadata
    • Next.js App Router: New export/review page at /assessments/[id]/export or /assessments/[id]/review
    • UI Components: New export button and completion screen components

    Technical Specifications

    Functional Requirements

    1. Zip File Generation

      • File naming: Assessment_[VIN]_[YYYY-MM-DD].zip
      • Contents:
        • Photos named by position label (e.g., FrontView.jpg, DriverSide.jpg)
        • Text files with damage notes (e.g., FrontView_notes.txt) - only if notes exist
      • File structure matches photo position order from carrier workflow
    2. Native Sharing

      • Use Web Share API for native OS share sheet
      • Fallback to download link for unsupported browsers
      • Share targets: Email, messaging apps, file managers
    3. Assessment Completion

      • Update claim status from in_progress → completed
      • Update completion timestamp
      • Persist to localStorage
    4. User Flow

      • Show completion summary (photo count, VIN, date)
      • Single "Export Assessment" button
      • Progress indicator during zip generation
      • Success confirmation after export

    Non-Functional Requirements

    • Performance: Generate zip file in <3 seconds for typical 9-photo assessment
    • Offline Support: Must work without network (PWA requirement)
    • Mobile Optimization: Touch-friendly UI, works on iOS/Android
    • Error Handling: Handle missing photos, storage errors, share failures gracefully

    Visual Design

    ┌─────────────────────────────────────┐
    │  ← Back to Assessments              │
    ├─────────────────────────────────────┤
    │                                     │
    │      ✓ Assessment Complete!         │
    │                                     │
    │    Vehicle: [VIN]                   │
    │    Photos captured: 9               │
    │    Date: Jan 21, 2025              │
    │                                     │
    │  ┌─────────────────────────────────┐   │
    │  │   📦 Export Assessment      │   │
    │  └─────────────────────────────────┘   │
    │                                     │
    │  Creates: Assessment_[VIN]_[Date]  │
    │                                     │
    └─────────────────────────────────────┘
    

    New Libraries Required

    • jszip (v3.10.1+): Browser-based zip file creation
      • Mature, well-maintained, 9.5k+ GitHub stars
      • Works offline, no server required
      • Supports Blob output for Web Share API

    Code Areas Requiring Modification

    1. New Files:

      • /packages/client/src/app/assessments/[id]/export/page.tsx - Export screen
      • /packages/client/src/lib/export-assessment.ts - Zip generation utility
      • /packages/client/src/hooks/useAssessmentExport.ts - Export logic hook
    2. Modified Files:

      • /packages/client/src/app/assessments/[id]/photos/page.tsx - Add "Complete & Export" button when all photos captured
      • /packages/client/src/types/claim.ts - Add completedAt?: Date field to Claim interface
      • /packages/client/package.json - Add jszip dependency
    3. New UI Components (in @snapscope/ui):

      • ExportButton - Styled export button with loading state
      • CompletionSummary - Assessment completion card

    Assumptions & Unknowns

    • Assumption: All required photos must be captured before export is available
    • Assumption: Web Share API availability (95%+ modern browsers, fallback for others)
    • Unknown: Whether to allow re-export of completed assessments (likely yes)
    • Unknown: Whether to include vehicle metadata file (make, model, year) in zip
    • Design Decision: Should incomplete assessments be exportable? (Recommend: No, enforce completion)
  4. adamveld12 commented on Oct 21, 2025

    @adamveld12
    ContributorAuthor

    Implementation Plan

    Step 1: Add jszip Dependency

    • Navigate to packages/client/
    • Run pnpm add jszip
    • Run pnpm add -D @types/jszip

    Step 2: Extend Claim Type Definition

    • Edit packages/client/src/types/claim.ts
    • Add completedAt?: Date field to Claim interface
    • Add exportedAt?: Date field for tracking export history

    Step 3: Create Export Utility (export-assessment.ts)

    • Create /packages/client/src/lib/export-assessment.ts
    • Implement generateAssessmentZip(claimId: string): Promise<Blob>
      • Fetch claim from storage
      • Iterate through claim.photos Record
      • For each photo:
        • Get position metadata via getPositionById()
        • Fetch photo blob via photoStorage.getPhotoBlob(photoId)
        • Add to zip with clean filename (e.g., FrontView.jpg)
        • If photo.notes exists, create FrontView_notes.txt
      • Add metadata file: assessment_info.txt with VIN, date, photo count
      • Return zip as Blob

    Step 4: Create Export Hook (useAssessmentExport.ts)

    • Create /packages/client/src/hooks/useAssessmentExport.ts
    • Implement hook with:
      • exportAssessment(claimId: string) function
      • Loading state management
      • Error handling
      • Web Share API detection
      • Fallback download logic
      • Claim status update to completed
      • Set completedAt and exportedAt timestamps

    Step 5: Create Export UI Components

    • In packages/client/src/app/assessments/[id]/export/page.tsx:

      • Create export screen component
      • Display completion summary (VIN, photo count, date)
      • Show "Export Assessment" button
      • Handle export flow with loading state
      • Show success/error messages
      • Navigate back to assessment list on success
    • In packages/ui/src/:

      • Create export-button.tsx component with loading spinner
      • Create completion-summary.tsx card component
      • Create Storybook stories for both components

    Step 6: Integrate Export into Photo Workflow

    • Edit /packages/client/src/app/assessments/[id]/photos/page.tsx
    • Add completion check: Count captured photos vs required positions
    • When all required photos captured:
      • Show "Complete Assessment" button at bottom
      • Button navigates to /assessments/[id]/export
    • Update progress indicator to show completion state

    Step 7: Update Assessment List Page

    • Edit /packages/client/src/app/assessments/page.tsx
    • Add visual indicator for completed assessments
    • Add "Re-export" option for completed assessments
    • Show completion date if available

    Step 8: Testing & Validation

    • Test with different photo counts (9 photos, 6 photos)
    • Test Web Share API on iOS Safari, Android Chrome
    • Test fallback download on desktop browsers
    • Verify zip file structure and naming
    • Test with/without damage notes
    • Verify offline functionality
    • Test re-export of completed assessments

    Step 9: Error Handling & Edge Cases

    • Handle missing photos gracefully
    • Handle IndexedDB storage errors
    • Handle zip generation failures
    • Handle Web Share API rejection
    • Add user-friendly error messages
    • Validate all required photos exist before allowing export
  5. adamveld12 commented on Oct 21, 2025

    @adamveld12
    ContributorAuthor

    Testing Plan

    Test Environment Setup

    • Devices: iOS (Safari), Android (Chrome), Desktop (Chrome, Firefox, Safari)
    • Network: Online and Offline (PWA mode)
    • Sample Data: Create test assessments with varying photo counts (3, 6, 9 photos)
    • Test VINs: Use real VINs from testing guide: 1FMPU18L9WLA04056, JTEDS41AX82059224

    Test Cases

    TC-1: Basic Export Flow (Happy Path)

    Preconditions: Complete assessment with 9 photos, all with damage notes
    Steps:

    1. Navigate to /assessments/{id}/photos
    2. Verify "Complete Assessment" button appears after last photo
    3. Click "Complete Assessment"
    4. Verify redirect to /assessments/{id}/export
    5. Verify completion summary shows correct VIN, photo count, date
    6. Click "Export Assessment"
    7. Verify loading state appears
    8. Verify Web Share API sheet opens (mobile) or download triggers (desktop)
    9. Share/save the ZIP file
    10. Verify claim status updated to completed in assessment list

    Expected Results:

    • ZIP file named Assessment_[VIN]_[YYYY-MM-DD].zip
    • Contains 9 JPG files (e.g., FrontView.jpg, DriverSide.jpg)
    • Contains 9 TXT files with damage notes (e.g., FrontView_notes.txt)
    • Contains assessment_info.txt with metadata
    • Assessment marked as completed in list

    TC-2: Export Without Damage Notes

    Preconditions: Complete assessment with 9 photos, NO damage notes
    Steps:

    1. Complete photo workflow without adding notes
    2. Navigate to export screen
    3. Export assessment

    Expected Results:

    • ZIP contains 9 JPG files
    • ZIP contains NO TXT note files
    • ZIP contains assessment_info.txt
    • File count: 10 files (9 photos + 1 info)

    TC-3: Partial Assessment Export Prevention

    Preconditions: Assessment with only 5 of 9 required photos
    Steps:

    1. Capture 5 photos
    2. Navigate to /assessments/{id}/photos

    Expected Results:

    • "Complete Assessment" button is DISABLED or HIDDEN
    • User cannot navigate to export screen
    • Clear indication of which photos are still required

    TC-4: Re-Export Completed Assessment

    Preconditions: Previously exported assessment (status = completed)
    Steps:

    1. Navigate to assessment list
    2. Select completed assessment
    3. Click "Re-export" or navigate to export screen
    4. Export again

    Expected Results:

    • ZIP generated successfully
    • exportedAt timestamp updated
    • Status remains completed
    • ZIP filename uses current date, not original completion date

    TC-5: Web Share API - iOS Safari

    Preconditions: iPhone with Safari, completed assessment
    Platform: iOS 14+ (Safari)
    Steps:

    1. Export assessment
    2. Verify iOS share sheet opens
    3. Select "Mail" from share options
    4. Verify ZIP file attached to email
    5. Verify filename and file size displayed correctly

    Expected Results:

    • Native iOS share sheet appears
    • ZIP file shareable via Mail, Messages, Files, AirDrop
    • File previews correctly as ZIP archive

    TC-6: Web Share API Fallback - Desktop Chrome

    Preconditions: Desktop Chrome browser (no Web Share API)
    Platform: macOS/Windows Chrome
    Steps:

    1. Export assessment
    2. Verify download link appears (fallback behavior)
    3. Click download link
    4. Verify ZIP downloads to Downloads folder

    Expected Results:

    • No share sheet appears (API not available)
    • Download link prominently displayed
    • ZIP downloads with correct filename
    • Browser shows download progress

    TC-7: Offline Export (PWA Mode)

    Preconditions: PWA installed, completed assessment, device offline
    Platform: Any mobile device
    Steps:

    1. Enable Airplane Mode
    2. Open Snapscope PWA
    3. Navigate to completed assessment
    4. Click "Export Assessment"
    5. Verify ZIP generation completes
    6. Share or save ZIP file

    Expected Results:

    • Export completes without network errors
    • All photos retrieved from IndexedDB
    • ZIP generation successful
    • Share/download works offline

    TC-8: Large Assessment (Performance Test)

    Preconditions: Assessment with 15+ photos (custom carrier workflow)
    Steps:

    1. Create assessment with carrier requiring 15 positions
    2. Capture all photos (mix of 2MB+ images)
    3. Export assessment
    4. Measure time from click to ZIP ready

    Expected Results:

    • ZIP generation completes in <5 seconds
    • No UI freezing or lag
    • Loading indicator displays throughout
    • Memory usage stays reasonable (<100MB)

    TC-9: Missing Photo Error Handling

    Preconditions: Claim record with photo reference, but photo blob missing from IndexedDB
    Steps:

    1. Manually delete photo from IndexedDB (simulate corruption)
    2. Attempt export

    Expected Results:

    • Export fails gracefully
    • Error message: "Some photos are missing. Please retake missing photos."
    • User redirected to photo workflow
    • Missing photos highlighted

    TC-10: IndexedDB Storage Quota Error

    Preconditions: Device storage nearly full
    Steps:

    1. Attempt export with storage quota exceeded

    Expected Results:

    • Clear error message: "Storage full. Free up space and try again."
    • Export process cancels safely
    • No data corruption
    • User can retry after freeing space

    TC-11: Filename Sanitization

    Preconditions: Assessment with unusual VIN characters
    Test VINs: Use VINs with special chars (if possible)
    Steps:

    1. Create assessment with edge-case VIN
    2. Export assessment
    3. Verify filename

    Expected Results:

    • Special characters replaced/sanitized
    • Filename remains readable
    • File system accepts filename (no errors)

    TC-12: Photo Position Label Mapping

    Preconditions: Assessment with custom carrier workflow
    Steps:

    1. Create assessment with carrier having custom position names
    2. Export assessment
    3. Extract and inspect ZIP contents

    Expected Results:

    • Photo filenames use position labels (not IDs)
    • Labels match carrier workflow (e.g., "LeftFrontFender.jpg")
    • Notes files match photo names (e.g., "LeftFrontFender_notes.txt")

    TC-13: Concurrent Export Prevention

    Preconditions: Assessment ready to export
    Steps:

    1. Click "Export Assessment"
    2. Immediately click again (double-click)

    Expected Results:

    • Only one export process runs
    • Button disabled during export
    • Loading state prevents additional clicks
    • No duplicate downloads/shares

    TC-14: Assessment Info Metadata File

    Preconditions: Completed assessment
    Steps:

    1. Export assessment
    2. Extract ZIP
    3. Open assessment_info.txt

    Expected Results:
    File contains:

    Assessment Information
    VIN: [Vehicle VIN]
    Date: [Completion Date]
    Photos Captured: [Count]
    Carrier: [Carrier Name or "Default"]
    Adjuster: [User info if available]
    

    TC-15: Browser Back Button During Export

    Preconditions: Export in progress
    Steps:

    1. Click "Export Assessment"
    2. Immediately press browser back button
    3. Observe behavior

    Expected Results:

    • Export continues in background OR
    • Export cancels gracefully
    • No broken state
    • User can retry export

    Regression Tests

    After implementation, verify these existing features still work:

    • ✅ Photo capture flow unchanged
    • ✅ Damage notes save/load correctly
    • ✅ Assessment list displays correctly
    • ✅ VIN validation works
    • ✅ Carrier workflow selection intact
    • ✅ IndexedDB migration from localStorage works

    Manual QA Checklist

    • Test on iPhone (Safari)
    • Test on Android (Chrome)
    • Test on iPad (Safari)
    • Test on Desktop Chrome
    • Test on Desktop Firefox
    • Test on Desktop Safari
    • Test offline (airplane mode)
    • Test with slow network (throttling)
    • Test with 3 photos, 6 photos, 9 photos, 15+ photos
    • Test with/without damage notes
    • Test re-export functionality
    • Test error states (missing photos, storage full)
    • Verify ZIP file structure and contents
    • Verify file naming conventions
    • Test accessibility (keyboard navigation, screen readers)

    Acceptance Criteria Verification

    From original issue:

    • ✅ User exports completed assessment as organized .zip file
    • ✅ User shares .zip via email/messaging to claims department
    • ✅ Photos named by position (LeftSide.jpg, Front.jpg, etc.)
    • ✅ Text files with damage notes (LeftSide_label.txt, etc.)
    • ✅ Use native OS share sheet for email/messaging
    • ✅ Mark assessment as complete
    • ✅ Creates: Assessment_[VIN]_[Date].zip

    Performance Benchmarks

    • ZIP generation: <3 seconds for 9 photos (~20MB)
    • ZIP generation: <5 seconds for 15 photos (~35MB)
    • UI remains responsive during generation
    • Memory usage: <100MB additional during export
    • Works smoothly on iPhone 12 and newer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Enhancement

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions