Skip to content

OUT-4083: cover untested error and guard branches in sync + webhook - #139

Merged
SandipBajracharya merged 3 commits into
mainfrom
OUT-4083
Aug 21, 2026
Merged

OUT-4083: cover untested error and guard branches in sync + webhook#139
SandipBajracharya merged 3 commits into
mainfrom
OUT-4083

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

What & why

A coverage pass found a few defensive branches the existing tests never reached. This adds integration tests for them. Test-only — no production changes, and it fits the existing harness.

Linear: OUT-4083

Coverage (9 new tests)

Sync.service create / root-path guards

  • Assembly → Dropbox create returns the existing folder's id without re-uploading when the folder already exists.
  • handleChannelMap records the Dropbox root folder id for a valid folder, and rejects a non-folder root path with a 400.
  • The leaf create stamps the Assembly file id before uploading, so a "file created" echo dedupes against the row (asserted by reading the row at upload time).

Channel map

  • updateChannelMap only updates when the root path matches exactly; a moved/stale root path matches nothing and leaves the row unchanged.

Webhook debounce + fetch

  • handleDropboxEvents skips an account with no active connection (asserts the sync is never triggered), and skips when a webhook is already pending even past the debounce window.
  • fetchDropBoxChanges returns early when the connection is missing or has no refresh token.

Notes

  • Each test targets the exact branch: the "existing folder" and "not-a-folder" tests register no move/upload mocks, so a stray call trips onUnhandledRequest:'error'; the stamp-before-upload and no-active-connection tests use call-time reads / trigger spies so they fail if the guard regresses.

Testing

  • pnpm typecheck ✅ · pnpm lint ✅ · pnpm test → 192 passed ✅
  • pnpm test:integration → 179 passed ✅ (was 170; +9)

🤖 Generated with Claude Code

SandipBajracharya and others added 3 commits August 20, 2026 18:53
- createAndUploadFileInDropbox returns the existing folder id without uploading
  when the folder already exists in Dropbox.
- handleChannelMap records the Dropbox root folder id for a valid folder, and
  rejects a non-folder root path with a 400.
- completePendingAssemblyCreate stamps the Assembly file id before uploading, so
  a "file created" echo dedupes against the row (asserted via upload-time read).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
updateChannelMap only updates the channel when the root path matches exactly;
a moved/stale root path matches nothing and leaves the row unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- handleDropboxEvents skips an account with no active connection (asserts the
  sync is never triggered), and skips when a webhook is already pending even
  past the debounce window.
- fetchDropBoxChanges returns early when the connection is missing or has no
  refresh token, before the end-of-sync timestamp is stamped.

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

linear-code Bot commented Aug 20, 2026

Copy link
Copy Markdown

OUT-4083

@vercel

vercel Bot commented Aug 20, 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 1:11pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

This test-only PR expands integration coverage for defensive sync, channel-map, and Dropbox webhook behavior.

  • Verifies exact root-path matching, root-folder validation, and existing-folder handling.
  • Verifies Assembly file IDs are persisted before content upload.
  • Covers inactive, pending, missing-connection, and missing-refresh-token webhook guards.
  • Adds assertions for error propagation and cleanup behavior in synchronization flows.

Confidence Score: 5/5

The PR appears safe to merge because it only adds focused integration tests and no actionable defects were identified.

The added fixtures, mocks, and assertions reach the intended production guard and ordering branches while remaining consistent with the repository’s test isolation and request-handler conventions.

Important Files Changed

Filename Overview
test/flows/channel-map-resync-guards.integration.test.ts Adds deterministic database-backed coverage for exact channel-map path matching alongside connection and resync cleanup guards.
test/flows/dropbox-to-assembly.initial-sync.integration.test.ts Adds an MSW-backed ordering test confirming the Assembly file ID is persisted before the upload request occurs.
test/flows/dropbox-webhook-debounce.integration.test.ts Adds isolated coverage for inactive connections and already-pending webhook events without changing production behavior.
test/flows/dropbox-webhook-internals.integration.test.ts Adds early-return coverage for missing or unusable Dropbox connections.
test/flows/sync-error-shape.integration.test.ts Adds coverage for existing-folder reuse and Dropbox root-path folder validation.

Reviews (1): Last reviewed commit: "test(OUT-4083): cover webhook debounce +..." | Re-trigger Greptile

@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 39d49a0 into main Aug 21, 2026
11 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