Skip to content

Add unit tests for CloudSync backup/restore#29

Merged
catherineluse merged 1 commit into
mainfrom
test-cloudsync-pr
Jul 16, 2026
Merged

Add unit tests for CloudSync backup/restore#29
catherineluse merged 1 commit into
mainfrom
test-cloudsync-pr

Conversation

@gennitdev

Copy link
Copy Markdown
Owner

Summary

Tests src/lib/cloudSync.ts (~1035 lines, was ~1%), taking it to ~23% by covering the CloudSync orchestration class and GoogleDriveProvider basics.

Stacked on #26 (flaky-test fix). Its two test-file changes show here until #26 merges.

Approach

CloudSync.backup/restore take an injectable CloudProvider, so the test uses a fake provider that stores the uploaded blob and returns it on download — with real Encryption + gzip — for a genuine round-trip.

Coverage

  • Round-trip: backup encrypts+compresses (GZ1: prefix), restore decrypts+decompresses back to the exact original database bytes → db.importDatabase.
  • Pre-backup authentication, Failed to upload backup wrapping, missing-backup error, wrong-password → Incorrect password, startAutoSync/stopAutoSync, and SDK-readiness delegation.
  • GoogleDriveProvider: construction, token-based isAuthenticated, and initial isWebSdkReady.

The remaining ~77% is GoogleDriveProvider's auth/upload/download/refresh — Google Drive REST + GIS SDK + CapacitorHttp glue that needs heavy fetch/SDK mocking; a good follow-up.

Testing

npm run lint, type-check, and vitest run pass (Node 22). Full suite: 288 tests across 31 files.

🤖 Generated with Claude Code

Tests the CloudSync orchestration with an injected CloudProvider and a
mocked db, using real Encryption + gzip for a genuine backup->restore
round-trip: verifies the encrypted/compressed payload round-trips back to
the original database bytes, pre-backup authentication, upload-failure
wrapping, missing-backup and wrong-password errors, auto-sync start/stop,
and SDK-readiness delegation. Also covers GoogleDriveProvider basics
(construction, token-based auth state, initial SDK readiness).

cloudSync.ts goes from ~1% to ~23%; the GoogleDriveProvider fetch/GIS
internals remain for a follow-up.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-beta-reader-frontend Ready Ready Preview, Comment Jul 16, 2026 6:33am

Request Review

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@catherineluse
catherineluse merged commit 30e4055 into main Jul 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants