chore: improve tests for better coverage and increase reliability#27
chore: improve tests for better coverage and increase reliability#27
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis pull request adds and extends tests across multiple packages: core (payload extraction, error handling, secret-resolution fallbacks, HMAC verification including base64 paths, webhook stats, and observer behavior), express/gcp-functions/nextjs (verifying observers do not mutate original webhook instances), github (adds installation and installation_repositories event schemas and tests, plus signature verification cases), and ragie (adds partition_limit_exceeded event type/schema and related tests). No public API declarations are removed; a few new types/schemas are exported in github and ragie. Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Improves test coverage and reliability across packages by adding new schema validation tests, strengthening adapter behavior assertions, and expanding webhook verification/edge-case scenarios.
Changes:
- Added schema validation tests for new/previously untested event types (Ragie partition limit, GitHub installation events).
- Improved adapter tests (Next.js/GCP Functions/Express) to ensure observer usage doesn’t mutate the original webhook.
- Expanded core webhook tests for payload extraction, error-handler robustness, secret resolution, and HMAC verification edge cases.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ragie/src/index.test.ts | Adds schema coverage for partition limit events and a missing-eventType webhook edge case. |
| packages/nextjs/src/index.test.ts | Strengthens option passing assertion and adds immutability coverage when observer is used. |
| packages/github/src/index.test.ts | Adds installation-related schema tests and expands signature/secret handling coverage. |
| packages/gcp-functions/src/index.test.ts | Adds immutability coverage when observer is used. |
| packages/express/src/index.test.ts | Adds immutability coverage when observer is used. |
| packages/core/src/index.test.ts | Adds payload extraction tests, resilience to observer callback failures, secret fallback coverage, and more HMAC/stats edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d73539 to
5bf19ed
Compare
|
@greptile-ai review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5bf19ed to
b3a0f5f
Compare
Greptile Overview
Greptile Summary
Enhanced test suite with 408 lines of new tests across 6 packages to improve coverage and reliability. Key improvements include proper environment variable cleanup with try-finally blocks, error handler resilience testing, payload extraction validation, observer immutability verification, and edge case handling for signature verification and stats tracking.
Key Test Additions
packages/core/src/index.test.ts:765-792using try-finally to prevent test pollution (addresses previous review comment about env leakage)onErrorandonVerificationFailedhandlers don't break the webhook processing flowgetPayload()correctly extracts nested payloads and merges nonce values for idempotencytoExpress,toGCPFunction,toNextJS) don't mutate the original webhook instanceConfidence Score: 5/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant Test as Test Suite participant Webhook as Webhook Builder participant Provider as Provider participant Handler as Event Handler participant Observer as Observer/Stats Note over Test,Observer: Environment Variable Cleanup Tests Test->>Test: Store previous env vars Test->>Webhook: process() without secret Webhook->>Provider: verify() with WEBHOOK_SECRET Provider-->>Webhook: verification result Test->>Test: Restore env vars in finally block Note over Test,Observer: Error Handler Resilience Tests Test->>Webhook: process() with failing onError Webhook->>Handler: execute handler (throws error) Handler-->>Webhook: error thrown Webhook->>Observer: call onError (throws) Observer-->>Webhook: error ignored Webhook-->>Test: return 500 status Note over Test,Observer: Payload Extraction Tests Test->>Webhook: process() with envelope structure Webhook->>Provider: getPayload(body) Provider->>Provider: Extract payload and nonce Provider-->>Webhook: merged payload with nonce Webhook->>Handler: execute with extracted payload Handler-->>Test: verify nonce present Note over Test,Observer: Observer Immutability Tests Test->>Webhook: create original webhook Test->>Webhook: toAdapter(webhook, {observer}) Webhook->>Webhook: clone with observer Test->>Webhook: process() on original Test->>Webhook: process() on adapter Test-->>Test: verify original unchanged