Skip to content

test(intercom): add live integration test suite - #5732

Merged
krishna2020 merged 7 commits into
developfrom
chore/intercom-live-integration-tests
Nov 2, 2026
Merged

krishna2020 merged 7 commits into
developfrom
chore/intercom-live-integration-tests

Conversation

@krishna2020

@krishna2020 krishna2020 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

What are the changes introduced in this PR?

Enrolls Intercom (API v2) in the live integration test suite, and fixes live-harness gaps that apply to every destination.

Live harness fixes (test/integrations/live/):

  • Router outputs are delivered the way rudder-server delivers them (runPipelineStep.ts). rudder-server's router only proxies an output whose statusCode is 200 (router/worker.go); any other 2xx is the job's final status with no delivery: 298 (event filtered) and 299 (event already handled by the transformer). The harness used to proxy every 2xx output, so it replayed writes production never sends: when a transform has already performed the write itself and returns 299, the replay sent it a second time and hid whether the transform's own write happened. Now only 200 outputs are proxied, and 298/299 are recorded as the jobs' final status. Covered by new cases in runPipelineStep.test.ts. Destinations that return 299 (Intercom, Klaviyo, Zendesk, Intercom v2) get the same treatment.
  • CDK v2 destinations are routed correctly (routerTransformRequest.ts, types.ts). The /routerTransform body now sends destination.DestinationDefinition.Name. The service selector routes on that field, so without it every CDK v2 destination fell back to the native path and failed with Cannot find module '../v0/destinations/<dest>/transform'. Destinations already enrolled are v0/v1 and ignore the field.
  • Steps can set their own timeout (component.live.test.ts, types.ts). A step may declare timeoutMs (default stays 120s), for a setup that legitimately waits on a slow, eventually consistent index.

Intercom live suite (test/integrations/destinations/intercom/live/):

Scenario What it covers Read-back
intercom-v2-identify-create identify for an unknown email → POST /contacts contact by email has name + external_id
intercom-v2-identify-anonymous-id identify with email + anonymousId, no userId, sendAnonymousId: true contact by email has external_id = anonymousId
intercom-v2-retl-email rETL identify with identifierType: email contact by email, external_id empty
intercom-v2-identify-update identify for an existing contact → PUT /contacts/<id> updated name
intercom-v2-retl-user-id rETL identify mapped by user_id, no email contact by external_id
intercom-v2-retl-external-id rETL identify mapped by external_id, no email (INT-7442) contact by external_id
intercom-v2-track track for an existing contact → POST /events delivery verdict only
  • Seeds use only reserved Intercom fields, since API 2.10 rejects custom attributes the workspace has not defined.
  • Search-index lag: the transform's searchContact always sends a compound query, even for a single external_id lookup. Intercom returns a new contact to a simple single-field query within seconds, but to the compound form only after ~30–100s. Identify update's setup therefore polls the transform's exact query shape until two consecutive hits (with a 240s step timeout), and its event carries no email, so the transform's search is that single external_id lookup. Otherwise the update is routed to a create and Intercom answers 409.
  • Track's setup only creates the contact: its transform does not search, and Intercom's events API just needs the contact to exist.
  • Every scenario deletes the contacts it created. Data events cannot be deleted via the API, so "CI Live Event" accumulates in the test workspace.

What is the related Linear task?

Related to INT-7442

Please explain the objectives of your changes below

Live coverage of the Intercom v2 delivery paths against a real workspace, including the rETL external_id case fixed in INT-7442.

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

Live harness only, no production code changes:

  • Router transform inputs now include DestinationDefinition.Name (uppercase destination name, as rudder-server sends it).
  • Only router outputs with statusCode 200 are proxied; 298/299 outputs are recorded as completed without delivery, matching rudder-server.
  • Steps may declare timeoutMs; steps without it keep the 120s default.

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

buildRouterTransformBody (live harness) now sets DestinationDefinition; covered by the existing runPipelineStep.test.ts.

Any technical or performance related pointers to consider with the change?

  • Needs LIVE_SECRET_INTERCOM in Vault, single-line: {"authType":"apiKey","config":{"apiKey":"<intercom-access-token>"}} (add "apiServer":"eu"|"au" for non-US workspaces). The token's app needs read + write on users (contacts) and write on data events.

Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • Is the PR limited to 10 file changes?

  • Is the PR limited to one linear task?

  • Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

Testing

  • Live harness unit tests: 24/24 pass; type-check (tsconfig.test.json) clean.
  • All 7 scenarios pass locally against a real Intercom test workspace.

🤖 Generated with Claude Code

@krishna2020
krishna2020 requested review from a team as code owners October 26, 2026 15:51
Copilot AI balanced review requested due to automatic review settings October 26, 2026 15:51
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a14b42ae-7eb5-4141-b2ef-67bcca02e1e2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The group scenario replays suppressed writes, and its retry strategy cannot recover a successful company-only result after a contact-search miss.

2 open issues
What changed in this PR

Adds live Intercom API v2 coverage, including the rETL external_id regression addressed by #5730, and updates the shared live harness to route CDK v2 destinations correctly.

Changes:

  • Adds six scenarios covering identify create/update, rETL identifiers, track, and company association.
  • Adds Intercom setup, read-back, and cleanup helpers.
  • Includes DestinationDefinition.Name in router requests, with matching types and unit coverage.
File Description
test/​integrations/​live/​types.ts Requires destination definition metadata in router inputs.
test/​integrations/​live/​runPipelineStep.test.ts Checks the destination name in generated requests.
test/​integrations/​live/​routerTransformRequest.ts Supplies the uppercase destination name for routing.
test/​integrations/​destinations/​intercom/​live/​spec.ts Defines six live scenarios and verification checks.
test/​integrations/​destinations/​intercom/​live/​api.ts Provides Intercom API helpers and resource cleanup.
test/​integrations/​destinations/​intercom/​live.ts Exposes the suite for registry discovery.

Review effort: Balanced

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.42%. Comparing base (3ee605e) to head (496e4d1).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5732   +/-   ##
========================================
  Coverage    92.42%   92.42%           
========================================
  Files          741      741           
  Lines        41048    41048           
  Branches      9636     9553   -83     
========================================
  Hits         37938    37938           
- Misses        2848     2926   +78     
+ Partials       262      184   -78     

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 11:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The group scenario proxies an already-suppressed transform result, potentially duplicating writes and masking association regressions.

2 open issues

Review effort: Balanced

@krishna2020
krishna2020 force-pushed the chore/intercom-live-integration-tests branch from 823d872 to 303c735 Compare October 29, 2026 07:40
Copilot AI balanced review requested due to automatic review settings October 29, 2026 07:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The live harness incorrectly proxies suppressed group outputs, duplicating attachments and masking transform regressions, while missed contact lookups can leave companies permanently unattached without triggering retries.

2 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 10:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The Intercom live-test setup can exceed the 120-second step timeout, preventing the intended diagnostic and leaving uncancelled work running during teardown.

3 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 11:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The live harness incorrectly proxies suppressed Intercom group outputs, potentially masking attachment regressions, while polling exceeds the action timeout and can continue into cleanup.

3 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no outstanding review issues for the Intercom live-test coverage and shared harness updates.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the Intercom live-integration coverage and shared-harness updates.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The live suite omits the intercom-v2-group scenario and association read-back, leaving Intercom’s transform-side company attachment untested.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 2, 2026 06:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the Intercom live-suite additions and shared harness updates.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

krishna2020 and others added 7 commits November 2, 2026 11:59
Enroll Intercom (API v2) in the live integration suite with six scenarios:
identify create, identify update, rETL identify mapped by user_id, rETL
identify mapped by external_id without email (INT-7442), track, and group.
Create/update/rETL/group scenarios read the contact or company back from
Intercom, and every scenario deletes what it created.

Also fix the live harness for CDK v2 destinations: the router transform body
now sends destination.DestinationDefinition.Name, which the service selector
uses to route to CDK v2. Without it, CDK v2 destinations fell back to the
native path and failed with "Cannot find module .../transform".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Make Intercom processor test descriptions match what each case covers:
- describe the rETL identify/track cases by identifier and email presence
  instead of "Identify rEtl test" / "Track rEtl test"
- label the external_id lookup-field case as V2 (it runs on the v2 destination)
- distinguish the v1 identify and group cases by the traits they exercise
  rather than repeating "create user" / "update user"
- fix the "indentifier" typo and the unsupported-message-type success criteria
  (the case sends a page event, not alias)

No test inputs or expectations change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fix the Intercom live suite against a real workspace:
- setup waits until the contact is found by the same email OR external_id
  search the transform sends; Intercom indexes a new contact by external_id
  within seconds but the OR query can take ~30-50s, so the transform routed
  the update to a create and got a 409
- steps right after setup wait longer and retry more
- read the contact's attached companies from either `companies` or `data`

Add two scenarios:
- event-stream identify with email and anonymousId (no userId) and
  sendAnonymousId on: the contact gets anonymousId as external_id
- rETL identify with identifierType email: the contact is created by email
  without external_id

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ddress review comments

Live harness: only proxy router outputs with statusCode 200, matching
rudder-server's router (router/worker.go). A 298 (filtered) or 299 (handled by
the transformer) output is its jobs' final status and is no longer delivered;
previously the harness replayed it, duplicating writes such as Intercom's group
attach and masking whether the transform-side write happened.

Intercom live spec:
- group expects no proxy request; the read-back proves the transform attached
  the company, and its delivery retries are removed (a search miss succeeds on
  the company-only branch, so they never fired)
- setup waits only until the contact is searchable by external_id, the search
  the following steps send; the update event carries no email, so the
  transform avoids the email OR external_id search that can take over a minute
  and pushed setup past the 120s step timeout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- drop SEARCH_RACE: track does not search, and identify update searches by
  external_id, which setup already waits for; keep a small retries: 2 on
  identify update for replica lag
- let setup's pollUntil fail on exhaustion instead of soft polling plus a
  hand-built throw
- read attached companies from `companies` only, the shape Intercom 2.10
  returns
- import the API hosts from the destination config instead of copying them
- drop unused IntercomContact.phone and IntercomCompany.plan

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…p group scenario

The transform's searchContact always sends a compound query, even for a single
external_id lookup. Intercom returns a new contact to a simple single-field
query within seconds but to the compound form only after ~30-100s, so setup
that polled the simple form handed over too early and identify update was
routed to a create (409).

- identify update setup now polls the transform's exact query shape (compound
  AND on external_id) until two consecutive hits, with a 240s step timeout
- live harness: steps can set their own timeoutMs (default stays 120s)
- track setup only creates the contact; its transform does not search
- remove the intercom-v2-group scenario and its company helpers; it stayed
  flaky against the real workspace

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The shared agent uses keepAlive: false with unlimited maxSockets, so Node
already sends `Connection: close` on every request; the explicit header
added nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@krishna2020
krishna2020 force-pushed the chore/intercom-live-integration-tests branch from 665b1c0 to 496e4d1 Compare November 2, 2026 06:29
Copilot AI balanced review requested due to automatic review settings November 2, 2026 06:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block approval of the Intercom live-suite additions and shared harness updates.

No open issues 🎉

Review effort: Balanced

@krishna2020
krishna2020 enabled auto-merge (squash) November 2, 2026 06:33
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@krishna2020
krishna2020 merged commit 5da55b5 into develop Nov 2, 2026
48 checks passed
@krishna2020
krishna2020 deleted the chore/intercom-live-integration-tests branch November 2, 2026 06:43
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.

4 participants