Skip to content

OUT-4084: unit tests for helper functions + small fixes - #140

Merged
SandipBajracharya merged 6 commits into
mainfrom
OUT-4084
Aug 21, 2026
Merged

OUT-4084: unit tests for helper functions + small fixes#140
SandipBajracharya merged 6 commits into
mainfrom
OUT-4084

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

What & why

Backfills fast unit tests for pure helpers that had none, plus two small production fixes surfaced along the way.

Linear: OUT-4084

Unit tests added (~52)

  • utilsnormalizeError (per error-type formatting), withErrorHandler / withErrorLogging (error → response / logging + rethrow), dropboxArgHeader (unicode escaping).
  • copilot libgenerateToken (AES round-trip + random IV), isCopilotApiError (shape accept + rejections incl. a Dropbox error), HexColorSchema.
  • sync / webhookgetCompanySelectorValue, the sync request Zod schemas, the Assembly webhook payload schema, validateHandleableEvent / parseWebhook.

Production fixes

  • updateChannelMap return type widened to ... | undefined (it returns undefined on no match; all callers ignore the result).
  • withErrorHandler: reordered the DropboxResponseError branch above the generic Error branch — it was dead code, so Dropbox failures surfaced "Response failed with a X code" instead of error_summary. Now matches normalizeError. (Covered by a new test.)

Test-infra

  • vitest.config.ts: inline @assembly-js/node-sdk in the unit config (mirrors the integration config) so unit tests can import modules that touch the Assembly SDK.

Out of scope

  • filePath helpers — already covered by filePath.test.ts.
  • withRetry — heavier setup (p-retry + Sentry + timers); deferred.

Testing

  • pnpm typecheck ✅ · pnpm lint ✅ · pnpm test → 256 passed ✅
  • pnpm test:integration → 179 passed ✅

🤖 Generated with Claude Code

SandipBajracharya and others added 6 commits August 21, 2026 16:09
updateChannelMap returns undefined when no channel matches the where-clause,
but was typed to always return a row. Callers already ignore the result.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Lets unit tests import modules that touch the Assembly SDK, whose dist does a
directory import Node's ESM loader can't resolve. Mirrors the integration config.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cover normalizeError (per error-type formatting), withErrorHandler and
withErrorLogging (error-to-response / logging + rethrow), and dropboxArgHeader
(unicode escaping).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cover generateToken (AES round-trip + random IV), isCopilotApiError (shape
acceptance and rejections incl. a Dropbox error), and HexColorSchema.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cover getCompanySelectorValue, the sync request schemas, the Assembly webhook
payload schema, and validateHandleableEvent / parseWebhook.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The DropboxResponseError branch sat after the generic Error branch, so it was
dead code (DropboxResponseError extends Error with a truthy message) and Dropbox
failures surfaced "Response failed with a X code" instead of error_summary.
Reorder it above the Error branch, matching normalizeError.

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

linear-code Bot commented Aug 21, 2026

Copy link
Copy Markdown

OUT-4084

@vercel

vercel Bot commented Aug 21, 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 21, 2026 10:35am

Request Review

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown

Greptile Summary

The PR backfills focused unit coverage for sync, webhook, Copilot, and utility helpers while correcting Dropbox error-response selection and accurately typing a potentially unmatched channel-map update.

  • Adds unit tests for request schemas, webhook parsing, selector handling, token generation, error normalization, headers, and logging wrappers.
  • Handles DropboxResponseError before generic Error so provider summaries and statuses reach API responses.
  • Widens updateChannelMap to reflect its existing undefined no-match result.
  • Inlines the Assembly SDK in unit tests to support its module resolution requirements.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, or build failures identified.

The production changes align runtime behavior with existing contracts, all channel-map update callers tolerate the optional result, and the test configuration uses a supported pattern already present in the repository.

Important Files Changed

Filename Overview
src/utils/withErrorHandler.ts Reorders the Dropbox-specific branch so provider status and error summaries are no longer hidden by generic Error handling.
src/features/sync/lib/MapFiles.service.ts Corrects the declared return type of updateChannelMap to include its existing undefined no-match outcome; current callers ignore the result.
vitest.config.ts Inlines the Assembly SDK through Vite for unit-test module resolution, matching the established integration-test configuration.
src/utils/tests/withErrorHandler.test.ts Covers successful handling and API, validation, generic, and Dropbox-specific error responses.
src/features/webhook/assembly/lib/tests/webhook.service.unit.test.ts Adds isolated coverage for supported-event filtering and webhook payload parsing.

Reviews (1): Last reviewed commit: "fix(OUT-4084): surface Dropbox error_sum..." | 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 09692ec 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