Skip to content

OUT-4068: residual service-branch tests (resync helper, root-move, delta, folder recovery) - #136

Merged
SandipBajracharya merged 4 commits into
OUT-4066from
OUT-4068
Aug 20, 2026
Merged

OUT-4068: residual service-branch tests (resync helper, root-move, delta, folder recovery)#136
SandipBajracharya merged 4 commits into
OUT-4066from
OUT-4068

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

Stacked on #135 (OUT-4066). Base is OUT-4066 so this diff shows only the L3b tests; GitHub will retarget it to main once #135 merges. Review/merge #135 first.

What & why

The final ticket of the Unit & Integration test milestone. Covers the residual service branches left after L1/L2/L3a — the ones no happy-path flow reaches and the sibling unit tests only partially exercise. Test-only: no production changes, reuses the existing MSW harness.

Linear: OUT-4068

Coverage (35 new tests)

Resync-helper guard/error branches (resync-sweep.integration.test.ts, +22) — cases 132–137

  • retryDeleteInAssembly / retryDeleteInDropbox: missing-field + already-gone (Copilot 404 / Dropbox 409 path_lookup_not_found) → markDeleted; other → markFailure.
  • retryCreateInDropbox: missing assemblyFileId/itemPath/channelSync → markFailure; retrieve 404 → markDeleted; still-pending → markFailure.
  • retryCreateInAssembly + reconcileExistingAssemblyFile: missing fields → markFailure; Dropbox not_found/deleted-tag → markDeleted; non-not_found metadata error → markFailure; recreate on null/404 assemblyFileId; non-404 reconcile error → markFailure; abandoned path nulls assemblyFileId before deleting the stale file (ordering).

Root-move + delta (dropbox-webhook-internals.integration.test.ts, new, +6) — cases 108/109, 114/115/116

  • handleDbxRootPathMove: 409 path-gone → re-fetch by dbxRootId, refresh cursor, update map, skip cycle; non-409 rethrows.
  • getDropboxChanges: deleted entry with no mapped row / no dbxFileId → dropped; malformed entry → throws; root-scope prefix filter (case-insensitive).

Sync.service residuals (+7) — cases 46, 79, 84, 85, 86

  • createAndUploadFileInDropbox existing-file → rename via filesMoveV2 + re-upload.
  • createFolderInAssembly "Folder already exists": row found → stamp only; non-matching error → rethrow.
  • recoverUnmappedAssemblyFolder: multi-page nextToken traversal; never-found → give up.
  • handleFolderCreatedCase: no-op when not the last folder item.
  • resyncLeafOnContentChange: recreate carries assemblyPathOverride = existing.assemblyPath.

Notes

  • Two seams to call out: 108/109 inject the metadata outcome at getDropboxFileMetadata (its withRetry adds ~20s backoff, impractical through MSW); the 136e ordering test uses a delete-mock that reads the row's live assemblyFileId at call-time to prove null-before-delete.
  • The 12h stuck-pending boundary micro-test was intentionally dropped (no clock control → flaky; existing 11h/13h tests already bracket the threshold) — recorded in the design doc.

Testing

  • pnpm typecheck ✅ · pnpm lint ✅ · pnpm test → 203 passed ✅
  • pnpm test:integration → 170 passed ✅ (was 141; +29)

🤖 Generated with Claude Code

SandipBajracharya and others added 3 commits August 18, 2026 21:49
Add the untested guard/error legs of the resync retry handlers (cases 132-137),
driven via retryFailedSyncsForPortal:
- retryDeleteInAssembly / retryDeleteInDropbox: missing-field + already-gone
  (Copilot 404 / Dropbox 409 path_lookup_not_found) → markDeleted; other → markFailure.
- retryCreateInDropbox: missing assemblyFileId/itemPath/channelSync → markFailure;
  retrieve 404 → markDeleted; still-pending → markFailure.
- retryCreateInAssembly + reconcileExistingAssemblyFile: missing fields → markFailure;
  Dropbox not_found / deleted-tag → markDeleted; non-not_found metadata error → markFailure;
  recreate on null/404 assemblyFileId; non-404 reconcile error → markFailure; abandoned
  path nulls assemblyFileId before deleting the stale file (ordering).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- handleDbxRootPathMove: 409 path-gone → re-fetch by dbxRootId, refresh cursor,
  update the channel map, skip the cycle; non-409 error rethrows, map untouched.
  (Metadata is injected at the getDropboxFileMetadata seam to skip withRetry's backoff.)
- getDropboxChanges: deleted entry with no mapped row / no dbxFileId → dropped;
  malformed entry → throws; entries scoped to the root path (case-insensitive).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- createAndUploadFileInDropbox: existing file at the path → rename via filesMoveV2
  to a timestamped name, then re-upload the new content.
- createFolderInAssembly "Folder already exists" catch: row found on re-lookup →
  stamp only (no recovery); non-matching error → rethrow.
- recoverUnmappedAssemblyFolder: match on a later listFiles page (nextToken paging);
  never-found → log + give up (no insert, no throw).
- handleFolderCreatedCase: no-op when not the last folder item.
- resyncLeafOnContentChange: recreate carries assemblyPathOverride = existing.assemblyPath.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Aug 18, 2026

Copy link
Copy Markdown

OUT-4068

@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
dropbox-integration Ready Ready Preview Aug 20, 2026 5:15am

Request Review

@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown

Greptile Summary

This test-only PR expands coverage for residual sync-service branches, including resync recovery, Dropbox root moves and delta filtering, folder recovery, and content-change recreation.

  • Adds resync guard, error-classification, reconciliation, and operation-ordering coverage.
  • Adds integration coverage for Dropbox root-path moves and delta-entry handling.
  • Adds folder recovery pagination and existing-row behavior tests.
  • Verifies Assembly-path preservation and Dropbox rename-before-reupload behavior.

Confidence Score: 5/5

The PR appears safe to merge because it changes only tests and no concrete test correctness or isolation issue remains.

The added tests reach the intended production branches, use the repository’s per-test database and MSW isolation, and introduce no production behavior changes.

Important Files Changed

Filename Overview
src/features/sync/lib/tests/Sync.folderRecovery.test.ts Adds focused unit coverage for folder-exists recovery, pagination, concurrent insertion, error propagation, and the non-final-folder guard.
src/features/sync/lib/tests/Sync.resyncLeaf.test.ts Verifies that content-change recreation preserves the existing Assembly path override.
test/flows/dropbox-webhook-internals.integration.test.ts Adds isolated integration coverage for root-move recovery and Dropbox delta validation, deletion resolution, and root filtering.
test/flows/resync-sweep.integration.test.ts Substantially expands resync branch coverage across missing fields, already-deleted objects, API failures, recreation, and stale-file cleanup ordering.
test/flows/sync-error-shape.integration.test.ts Adds coverage for the existing-file rename-and-reupload flow and its expected Dropbox operations.

Reviews (1): Last reviewed commit: "test(OUT-4068): cover Dropbox rename + f..." | Re-trigger Greptile

Rewrite the L3b test/describe titles in plain language and remove the
"(case NN)" references to the local scoping catalog (not committed, so
meaningless to readers). Labels only — no behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@priosshrsth priosshrsth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@SandipBajracharya
SandipBajracharya merged commit 2fce1ec into main Aug 20, 2026
10 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