Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3651dc4
feat: add e2e test types and Iterable fixtures
joe-ayoub-segment May 28, 2026
9cbda9c
refactor: prefix HTTP status code types with E2E
joe-ayoub-segment May 28, 2026
ae166ac
refactor: consolidate e2e fixtures to one file per action
joe-ayoub-segment May 28, 2026
6f472fe
refactor: remove fixture registry from e2e index
joe-ayoub-segment May 28, 2026
36f6d0c
feat: add dynamic value markers ($now, $guid) for e2e fixtures
joe-ayoub-segment May 28, 2026
d9657c3
refactor: use defaultValues() for e2e fixture mappings
joe-ayoub-segment May 28, 2026
43b8504
feat: add createE2EEvent helper for fixture event generation
joe-ayoub-segment May 28, 2026
729b957
refactor: separate e2e types from helper functions
joe-ayoub-segment May 28, 2026
79e483e
fix: omit email/userId from mapping instead of setting undefined
joe-ayoub-segment May 28, 2026
e28b1e4
feat: add e2e fixtures for Amplitude logEventV2 and identifyUser
joe-ayoub-segment May 28, 2026
f17604c
feat: add createE2EEngageAudienceEvent helper
joe-ayoub-segment May 29, 2026
8ef2426
refactor: improve createE2EEngageAudienceEvent
joe-ayoub-segment May 29, 2026
d25fb33
feat: add generic K to audience event types
joe-ayoub-segment May 29, 2026
1179102
refactor: rename generic K to ComputationKey for clarity
joe-ayoub-segment May 29, 2026
279ff90
feat: add audience fixture types and Amplitude Cohorts e2e fixtures
joe-ayoub-segment May 29, 2026
d9fa0d2
feat: add subscribe and mapping fields to E2EAudienceFixture
joe-ayoub-segment May 29, 2026
9471c9d
feat: add E2ETeardownAudienceStep type
joe-ayoub-segment May 29, 2026
c376880
refactor: move audience fixtures to syncAudience/__e2e__/fixtures.ts
joe-ayoub-segment May 29, 2026
552c737
feat: add description field to audience step types
joe-ayoub-segment May 29, 2026
34a6694
feat: add E2EExecutionMode type for single/batch step mode
joe-ayoub-segment May 29, 2026
6055ef2
refactor: use full SegmentEvent in audience sync steps
joe-ayoub-segment May 29, 2026
06454ac
fix: use E2EEngageAudienceEvent type in audience sync steps
joe-ayoub-segment May 29, 2026
16a6d8c
feat: add $externalAudienceId dynamic value marker
joe-ayoub-segment May 29, 2026
b05c06a
refactor: simplify audience testing to config + regular fixtures
joe-ayoub-segment May 29, 2026
c2d3ca1
docs: add JSDoc comments to E2EAudienceConfig fields
joe-ayoub-segment May 29, 2026
8615cce
feat: split E2EFixture into discriminated union with mode field
joe-ayoub-segment May 29, 2026
dfe3906
adding latest amplitude cohorts
joe-ayoub-segment May 29, 2026
f2e5498
fix: restore amplitude-cohorts e2e fixtures
joe-ayoub-segment May 29, 2026
cd7771a
fix: restore amplitude-cohorts e2e config
joe-ayoub-segment May 29, 2026
0d03939
feat: add verboseFailureHint to fixture types
joe-ayoub-segment May 29, 2026
df6746e
feat: add jsonContains to E2EExpectation types
joe-ayoub-segment May 29, 2026
d63b198
refactor: replace responseType with 3 execution modes + BaseFixture
joe-ayoub-segment May 29, 2026
f74927e
feat: add jsonContains assertion to batch fixture
joe-ayoub-segment May 29, 2026
5e1163e
feat: add e2e fixtures for Iterable Audiences destination
joe-ayoub-segment Jun 2, 2026
5da9316
feat: add sent/body assertions to Iterable Audiences batch fixture
joe-ayoub-segment Jun 2, 2026
8dccb65
fix: fix Iterable Audiences batch assertion and disable getAudience
joe-ayoub-segment Jun 2, 2026
672ba45
iterable fixture
joe-ayoub-segment Jun 2, 2026
a04f9f2
feat: add e2e fixtures for Google Enhanced Conversions userList
joe-ayoub-segment Jun 2, 2026
41b7363
feat: add batch test for Google Enhanced Conversions userList
joe-ayoub-segment Jun 2, 2026
b01b5fc
feat: assert sent/body objects in Google userList batch multistatus
joe-ayoub-segment Jun 2, 2026
3ff0efb
adding google enhanced conversions example test
joe-ayoub-segment Jun 2, 2026
a4135c0
adding comment to e2e test
joe-ayoub-segment Jun 2, 2026
c59590a
adding JourneysV1 helpers
joe-ayoub-segment Jun 2, 2026
01365f6
new file convention for e2e tests
joe-ayoub-segment Jun 2, 2026
d050fab
adding retl initial tests
joe-ayoub-segment Jun 2, 2026
59e8bbc
types
joe-ayoub-segment Jun 2, 2026
835dc74
refactor: extract shared builder in e2e helpers, remove unused action…
joe-ayoub-segment Jun 3, 2026
b59c9dd
refactor: move AudienceEventBase to e2e-types.ts
joe-ayoub-segment Jun 3, 2026
fd57a5b
rename fixture file
joe-ayoub-segment Jun 3, 2026
65c3ad4
add Pinterest e2e tests, fix createE2EEvent for page/identify types
joe-ayoub-segment Jun 4, 2026
3dfc67d
fix e2e fixture expectations for validation errors and timestamp
joe-ayoub-segment Jun 4, 2026
22fd0db
pinterest tests passing
joe-ayoub-segment Jun 4, 2026
183bada
adding teardown for google enhanced conversions
joe-ayoub-segment Jun 4, 2026
cc77ba7
updating e2e for iterable audiences
joe-ayoub-segment Jun 4, 2026
1c1e698
Merge remote-tracking branch 'origin/main' into feat/e2e-test-types-a…
joe-ayoub-segment Jun 9, 2026
7c7250c
adding facebook conversions api e2e - untested
joe-ayoub-segment Jun 9, 2026
88b32ba
facebook custom audiences - update e2e
joe-ayoub-segment Jun 9, 2026
feae745
updating tests
joe-ayoub-segment Jun 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions packages/core/src/e2e-helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import type { SegmentEvent } from './segment-event'
import type { JSONValue } from './json-object'
import type {
E2EAudienceEventBase,
E2EEngageAudienceEventOptions,
E2EEngageAudienceEvent,
E2EJourneysV1AudienceEventOptions,
E2EJourneysV1AudienceTrackEvent,
E2ERetlAudienceEventOptions,
E2ERetlAudienceTrackEvent
} from './e2e-types'

/*
* Regular Segment Connections event
*/
export function createE2EEvent(
type: SegmentEvent['type'],
name?: string,
overrides?: Partial<Omit<SegmentEvent, 'type' | 'event' | 'name' | 'messageId' | 'timestamp'>>
): 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.`
)
}

return {
type,
messageId: '$guid',
timestamp: '$now',
...overrides
}
Comment on lines +47 to +52
Comment on lines +16 to +52
Comment on lines +16 to +52
}

function buildAudienceEventBase(options: E2EAudienceEventBase) {
const {
computationKey,
computationId,
externalAudienceId,
userId,
anonymousId,
email,
audienceFields,
includeContextTraits = true
} = options
return {
messageId: '$guid',
timestamp: '$now',
...(userId && { userId }),
...(anonymousId && { anonymousId }),
context: {
personas: {
computation_class: 'audience',
computation_key: computationKey,
computation_id: computationId,
...(externalAudienceId && { external_audience_id: externalAudienceId })
},
...(audienceFields && { audienceFields }),
...(includeContextTraits && email && { traits: { email } })
}
}
}

/*
* Engage Audience event
* Supports identify and track events
*/
export function createE2EEngageAudienceEvent<ComputationKey extends string>(
options: E2EEngageAudienceEventOptions<ComputationKey>
): E2EEngageAudienceEvent<ComputationKey> {
const { type, action, computationKey, eventName, email, enrichedTraits } = options

if (type === 'identify' && eventName) {
throw new Error('createE2EEngageAudienceEvent: "eventName" is not supported for identify events.')
}

const membership = action === 'add'
const base = buildAudienceEventBase({ ...options, includeContextTraits: type === 'track' })

const event = {
...base,
...(type === 'track' && {
type: 'track',
event: eventName ?? 'Test Engage Audience Membership Event',
properties: {
[computationKey]: membership,
...(enrichedTraits as { [k: string]: JSONValue })
}
}),
...(type === 'identify' && {
type: 'identify',
traits: {
[computationKey]: membership,
...(enrichedTraits as { [k: string]: JSONValue }),
...(email && { email })
}
})
}

return event as E2EEngageAudienceEvent<ComputationKey>
}

/*
* Journeys V1 events (preset journeys_step_entered_track) do not have properties[<computation_key>] value.
* All Journeys V1 events enter the user to the audience, never remove them.
* Only track events supported
*/
export function createE2EJourneysV1AudienceEvent<ComputationKey extends string>(
options: E2EJourneysV1AudienceEventOptions<ComputationKey>
): E2EJourneysV1AudienceTrackEvent<ComputationKey> {
const { eventName, enrichedTraits } = options
const base = buildAudienceEventBase(options)

const event = {
...base,
type: 'track',
event: eventName ?? 'Test Journeys V1 Audience Membership Event',
properties: {
...(enrichedTraits as { [k: string]: JSONValue })
}
}

return event as E2EJourneysV1AudienceTrackEvent<ComputationKey>
}

/*
* Reverse ETL Audience event
* Same payload structure as Engage track events but uses RETL-specific event names: 'new', 'updated', 'deleted'
* Only track events supported
*/
export function createE2ERetlAudienceEvent<ComputationKey extends string>(
options: E2ERetlAudienceEventOptions<ComputationKey>
): E2ERetlAudienceTrackEvent<ComputationKey> {
const { eventName, computationKey, enrichedTraits } = options
const membership = eventName !== 'deleted'
const base = buildAudienceEventBase(options)

const event = {
...base,
type: 'track',
event: eventName,
properties: {
[computationKey]: membership,
...(enrichedTraits as { [k: string]: JSONValue })
}
}

return event as E2ERetlAudienceTrackEvent<ComputationKey>
}
Loading