E2E core code types and helper functions - #3903
Open
joe-ayoub-segment wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds shared E2E TypeScript primitives to packages/core so destination authors and an external E2E runner can construct strongly-typed events and fixtures with consistent payloads.
Changes:
- Added
e2e-types.tsdefining fixture/expectation/config and audience event types for the E2E framework - Added
e2e-helpers.tswith event-construction helpers for standard events and multiple audience systems (Engage/Journeys/RETL) - Re-exported the new helpers/types from the
corepackage root
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/core/src/index.ts | Re-exports the new E2E helper functions and types from the package entrypoint |
| packages/core/src/e2e-types.ts | Introduces E2E fixture/expectation/config types and typed audience-event shapes |
| packages/core/src/e2e-helpers.ts | Adds helper functions to build typed Segment events and audience events for E2E fixtures |
Comment on lines
+31
to
+56
| export function createE2EEvent(type: SegmentEvent['type'], name?: string, overrides?: E2EEventOverrides): SegmentEvent { | ||
| if (type === 'track') { | ||
| return { | ||
| type, | ||
| event: name, | ||
| messageId: '$guid', | ||
| timestamp: '$now', | ||
| ...overrides | ||
| } | ||
| } | ||
|
|
||
| if (type === 'page' || type === 'screen') { | ||
| return { | ||
| type, | ||
| name, | ||
| messageId: '$guid', | ||
| timestamp: '$now', | ||
| ...overrides | ||
| } | ||
| } | ||
|
|
||
| if (name) { | ||
| throw new Error( | ||
| `createE2EEvent: "name" is not supported for "${type}" events. Only track, page, and screen accept a name.` | ||
| ) | ||
| } |
Comment on lines
+9
to
+27
| export interface E2ESuccessExpectation { | ||
| status: 'success' | ||
| httpStatus?: E2EHttpSuccessCode | ||
| bodyContains?: string | ||
| /** Partial deep match against the JSON response body. Arrays must match length and each item is partial-matched. */ | ||
| jsonContains?: unknown | ||
| } | ||
|
|
||
| /** | ||
| * The HTTP request was sent and the destination API returned a non-2xx response. | ||
| * Use this to verify that the destination rejects specific inputs (e.g., bad auth, invalid payload). | ||
| */ | ||
| export interface E2EFailureExpectation { | ||
| status: 'failure' | ||
| httpStatus: E2EHttpFailureCode | ||
| bodyContains?: string | ||
| /** Partial deep match against the JSON response body. Arrays must match length and each item is partial-matched. */ | ||
| jsonContains?: unknown | ||
| } |
Comment on lines
+148
to
+168
| const event = { | ||
| messageId: '$guid', | ||
| timestamp: '$now', | ||
| ...(userId && { userId }), | ||
| ...(anonymousId && { anonymousId }), | ||
| type: 'track', | ||
| event: 'Audience Entered', | ||
| properties: { | ||
| ...enrichedTraits | ||
| }, | ||
| context: { | ||
| personas: { | ||
| computation_class: 'journey_step', | ||
| computation_key: computationKey, | ||
| computation_id: computationId, | ||
| ...(externalAudienceId && { external_audience_id: externalAudienceId }) | ||
| }, | ||
| ...(audienceFields && { audienceFields }), | ||
| ...(email && { traits: { email } }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a set of shared TypeScript types and event-construction helpers to packages/core that support the end-to-end (E2E) test framework for Action Destinations. These primitives let destination authors write E2E fixtures — real HTTP calls against a running serve server - with strong typing and consistent event payloads.
What's included
packages/core/src/e2e-types.ts — Type definitions for the E2E framework:
secrets).
packages/core/src/e2e-helpers.ts — Event builders:
packages/core/src/index.ts — Re-exports the helpers and types from the package root.
Impact
Testing
Security Review
Please ensure sensitive data is properly protected in your integration.
type: 'password'New Destination Checklist
verioning-info.tsfile. example