Skip to content

Salesforce Marketing Cloud: Unit tests for V2 functionality#3600

Open
nick-Ag wants to merge 2 commits intomainfrom
SFMC-unit-tests
Open

Salesforce Marketing Cloud: Unit tests for V2 functionality#3600
nick-Ag wants to merge 2 commits intomainfrom
SFMC-unit-tests

Conversation

@nick-Ag
Copy link
Contributor

@nick-Ag nick-Ag commented Feb 12, 2026

This PR adds unit tests for previously untested V2 functionality in this destination.

Testing

Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

Security Review

Please ensure sensitive data is properly protected in your integration.

  • Reviewed all field definitions for sensitive data (API keys, tokens, passwords, client secrets) and confirmed they use type: 'password'

New Destination Checklist

  • Extracted all action API versions to verioning-info.ts file. example

  Add complete test coverage for dataExtensionV2 and contactDataExtensionV2
  actions, which previously had zero test coverage. These V2 actions use
  hooks for data extension configuration and dynamic field resolution.

  Test coverage includes:
  - perform() and performBatch() methods for both actions
  - Hook integration (onMappingSave and retlOnMappingSave)
  - Error handling (400, 500, missing config, retryable errors)
  - Dynamic field resolution (primary/non-primary key filtering)
  - Multistatus response handling
  - Default contactKey mapping from userId

  Tests follow patterns from asyncDataExtension.test.ts and validate
  the upsertRowsV2() and executeUpsertWithMultiStatus() functions.

  Total: 35 passing tests (18 for dataExtensionV2, 17 for contactDataExtensionV2)

  Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

New required fields detected

Warning

Your PR adds new required fields to an existing destination. Adding new required settings/mappings for a destination already in production requires updating existing customer destination configuration. Ignore this warning if this PR is for a new destination with no active customers in production.

The following required fields were added in this PR:

  • Destination: Salesforce Marketing Cloud (Actions), Settings:subdomain,account_id,client_id,client_secret
  • Destination: Salesforce Marketing Cloud (Actions), Action:contact, Fields:contactKey
  • Destination: Salesforce Marketing Cloud (Actions), Action:dataExtension, Fields:keys,values
  • Destination: Salesforce Marketing Cloud (Actions), Action:contactDataExtension, Fields:keys,values
  • Destination: Salesforce Marketing Cloud (Actions), Action:apiEvent, Fields:eventDefinitionKey,contactKey
  • Destination: Salesforce Marketing Cloud (Actions), Action:dataExtensionV2, Fields:keys,values
  • Destination: Salesforce Marketing Cloud (Actions), Action:contactDataExtensionV2, Fields:keys,values
  • Destination: Salesforce Marketing Cloud (Actions), Action:asyncDataExtension, Fields:keys,values

Add these new fields as optional instead and assume default values in perform or performBatch block.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.42%. Comparing base (6366770) to head (4cb003f).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3600      +/-   ##
==========================================
+ Coverage   80.25%   80.42%   +0.17%     
==========================================
  Files        1276     1283       +7     
  Lines       23485    23567      +82     
  Branches     4692     4726      +34     
==========================================
+ Hits        18848    18954     +106     
+ Misses       3762     3730      -32     
- Partials      875      883       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nick-Ag
Copy link
Contributor Author

nick-Ag commented Feb 13, 2026

New required fields detected

Warning

Your PR adds new required fields to an existing destination. Adding new required settings/mappings for a destination already in production requires updating existing customer destination configuration. Ignore this warning if this PR is for a new destination with no active customers in production.

The following required fields were added in this PR:

  • Destination: Salesforce Marketing Cloud (Actions), Settings:subdomain,account_id,client_id,client_secret
  • Destination: Salesforce Marketing Cloud (Actions), Action:contact, Fields:contactKey
  • Destination: Salesforce Marketing Cloud (Actions), Action:dataExtension, Fields:keys,values
  • Destination: Salesforce Marketing Cloud (Actions), Action:contactDataExtension, Fields:keys,values
  • Destination: Salesforce Marketing Cloud (Actions), Action:apiEvent, Fields:eventDefinitionKey,contactKey
  • Destination: Salesforce Marketing Cloud (Actions), Action:dataExtensionV2, Fields:keys,values
  • Destination: Salesforce Marketing Cloud (Actions), Action:contactDataExtensionV2, Fields:keys,values
  • Destination: Salesforce Marketing Cloud (Actions), Action:asyncDataExtension, Fields:keys,values

Add these new fields as optional instead and assume default values in perform or performBatch block.

This is wrong - Only .test.ts files have been updated here so this is impossible

@nick-Ag nick-Ag changed the title Sfmc unit tests Salesforce Marketing Cloud: Unit tests for V2 functionality Feb 24, 2026
@nick-Ag nick-Ag marked this pull request as ready for review February 24, 2026 17:55
@nick-Ag nick-Ag requested a review from a team as a code owner February 24, 2026 17:55
Copy link
Contributor

@itsarijitray itsarijitray left a comment

Choose a reason for hiding this comment

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

Approving this as these are only test changes 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants