From 10d18d0cdca42219769c2fafc5d3774afd75c754 Mon Sep 17 00:00:00 2001 From: dante01yoon Date: Fri, 2 Oct 2026 17:49:57 -0400 Subject: [PATCH] test: move billing payload-helper suites into account-core The suites in src/platform/telemetry tested only helpers that now live in @comfyorg/account-core/billing. Move them next to the code, import package relative, and drop the two cases payload.test.ts and checkoutJourney.test.ts already prove. --- .../telemetry/billingTelemetryEvent.test.ts | 17 ++ .../billing/telemetry/checkoutJourney.test.ts | 115 +++++++- .../core/billing/telemetry/payload.test.ts | 213 +++++++++++++++ .../telemetry/webHandoffEvent.test.ts | 5 +- .../telemetry/billingTelemetryEvent.test.ts | 250 ------------------ .../telemetry/checkoutJourneyEvent.test.ts | 127 --------- 6 files changed, 347 insertions(+), 380 deletions(-) create mode 100644 packages/account-core/src/core/billing/telemetry/billingTelemetryEvent.test.ts rename {src/platform => packages/account-core/src/core/billing}/telemetry/webHandoffEvent.test.ts (97%) delete mode 100644 src/platform/telemetry/billingTelemetryEvent.test.ts delete mode 100644 src/platform/telemetry/checkoutJourneyEvent.test.ts diff --git a/packages/account-core/src/core/billing/telemetry/billingTelemetryEvent.test.ts b/packages/account-core/src/core/billing/telemetry/billingTelemetryEvent.test.ts new file mode 100644 index 00000000000..c7c6378b951 --- /dev/null +++ b/packages/account-core/src/core/billing/telemetry/billingTelemetryEvent.test.ts @@ -0,0 +1,17 @@ +import { describe, expectTypeOf, it } from 'vitest' + +import type { BillingTelemetryEvent } from './billingTelemetryEvent.js' + +type LateSuccessEvent = Extract< + BillingTelemetryEvent, + { recovery_outcome?: 'late_success' } +> + +describe('BillingTelemetryEvent', () => { + it('allows late success only on succeeded recovery terminals', () => { + expectTypeOf().toEqualTypeOf<'succeeded'>() + expectTypeOf().toEqualTypeOf< + 'subscription_checkout' | 'resubscribe' + >() + }) +}) diff --git a/packages/account-core/src/core/billing/telemetry/checkoutJourney.test.ts b/packages/account-core/src/core/billing/telemetry/checkoutJourney.test.ts index 8813927270d..2da00fd277c 100644 --- a/packages/account-core/src/core/billing/telemetry/checkoutJourney.test.ts +++ b/packages/account-core/src/core/billing/telemetry/checkoutJourney.test.ts @@ -1,7 +1,12 @@ import { describe, expect, it } from 'vitest' import type { CheckoutJourneyTelemetryEvent } from './checkoutJourney.js' -import { getCheckoutJourneyTelemetryEventPayload } from './checkoutJourney.js' +import { + CHECKOUT_JOURNEY_EVENT_NAME_BY_PHASE, + CHECKOUT_JOURNEY_SCHEMA_VERSION, + getCheckoutJourneyTelemetryEventName, + getCheckoutJourneyTelemetryEventPayload +} from './checkoutJourney.js' const CONTEXT = { checkout_journey_id: 'journey-1', @@ -152,3 +157,111 @@ describe('the checkout journey payload', () => { ) }) }) + +const baseContext = { + checkout_journey_id: 'journey-1', + checkout_entered_at: '2026-09-09T00:00:00.000Z', + entry_flow: 'initial_subscription', + entry_source: 'pricing' +} as const + +describe('getCheckoutJourneyTelemetryEventName', () => { + it('derives the wire name from the phase', () => { + const event: CheckoutJourneyTelemetryEvent = { + ...baseContext, + phase: 'preview_ready', + assignment_status: 'resolved', + assigned_arm: 'treatment' + } + expect(getCheckoutJourneyTelemetryEventName(event)).toBe( + 'billing.checkout.preview_ready' + ) + }) + + // The table is a total Record, so a missing phase fails to compile — but a + // swapped value (entered -> 'billing.checkout.submitted') would not. Comparing + // each key against its own value restores what the template literal proved. + it.for(Object.entries(CHECKOUT_JOURNEY_EVENT_NAME_BY_PHASE))( + 'names %s after its own phase', + ([phase, name]) => { + expect(name).toBe(`billing.checkout.${phase}`) + + const event = { + ...baseContext, + phase, + assignment_status: 'unavailable' + } as CheckoutJourneyTelemetryEvent + expect(getCheckoutJourneyTelemetryEventName(event)).toBe(name) + } + ) +}) + +describe('getCheckoutJourneyTelemetryEventPayload', () => { + it('stamps schema version and carries the resolved arm', () => { + const event: CheckoutJourneyTelemetryEvent = { + ...baseContext, + phase: 'entered', + assignment_status: 'resolved', + assigned_arm: 'control' + } + const payload = getCheckoutJourneyTelemetryEventPayload(event) + expect(payload.schema_version).toBe(CHECKOUT_JOURNEY_SCHEMA_VERSION) + expect(payload.assigned_arm).toBe('control') + }) + + it('omits absent optional context rather than emitting undefined keys', () => { + const event: CheckoutJourneyTelemetryEvent = { + ...baseContext, + phase: 'entered', + assignment_status: 'unavailable' + } + const payload = getCheckoutJourneyTelemetryEventPayload(event) + expect('billing_op_id' in payload).toBe(false) + expect('ui_mode' in payload).toBe(false) + }) + + it('carries the ui_mode the user actually saw', () => { + const event: CheckoutJourneyTelemetryEvent = { + ...baseContext, + phase: 'entered', + assignment_status: 'resolved', + assigned_arm: 'treatment', + ui_mode: 'embedded' + } + const payload = getCheckoutJourneyTelemetryEventPayload(event) + expect(payload.ui_mode).toBe('embedded') + }) + + it('carries phase-specific fields for a failed preview', () => { + const event: CheckoutJourneyTelemetryEvent = { + ...baseContext, + phase: 'preview_failed', + assignment_status: 'resolved', + assigned_arm: 'treatment', + failure_category: 'network', + preview_revision: 'rev-7' + } + const payload = getCheckoutJourneyTelemetryEventPayload(event) + expect(payload).toMatchObject({ + phase: 'preview_failed', + failure_category: 'network', + preview_revision: 'rev-7' + }) + }) + + it('distinguishes the failing element from the failure phase', () => { + const event: CheckoutJourneyTelemetryEvent = { + ...baseContext, + phase: 'payment_element_failed', + assignment_status: 'resolved', + assigned_arm: 'treatment', + element: 'address', + element_phase: 'mount' + } + const payload = getCheckoutJourneyTelemetryEventPayload(event) + expect(payload).toMatchObject({ + element: 'address', + element_phase: 'mount' + }) + }) +}) diff --git a/packages/account-core/src/core/billing/telemetry/payload.test.ts b/packages/account-core/src/core/billing/telemetry/payload.test.ts index be3619159a5..8f2ec929021 100644 --- a/packages/account-core/src/core/billing/telemetry/payload.test.ts +++ b/packages/account-core/src/core/billing/telemetry/payload.test.ts @@ -3,10 +3,12 @@ import { describe, expect, it } from 'vitest' import type { BillingTelemetryEvent } from './billingTelemetryEvent.js' import { BILLING_PAYLOAD_FIELD_HANDLING, + getBillingTelemetryEventPayload, getBillingWebTelemetryEventPayload, getCloudAppBillingTelemetryEventPayload } from './payload.js' import type { BillingPayloadFieldHandling } from './payload.js' +import { toBillingTelemetryEvent } from './operationLifecycleEvent.js' const SURFACES = [ { @@ -143,3 +145,214 @@ describe('the billing payload allowlist', () => { expect(refused).not.toHaveProperty('unlisted_field') }) }) + +describe('getBillingTelemetryEventPayload', () => { + it.for<{ + name: string + event: BillingTelemetryEvent + claim: { billing_client?: 'sdk' | 'legacy' } + }>([ + { + name: 'the SDK lifecycle starts a subscription operation', + event: toBillingTelemetryEvent({ + name: 'billing.operation.started', + billing_op_id: 'op-subscribe', + operation_type: 'subscription', + presentation: 'hosted', + resumed: false + }), + claim: { billing_client: 'sdk' } + }, + { + name: 'the SDK lifecycle settles a top-up operation', + event: toBillingTelemetryEvent({ + name: 'billing.operation.succeeded', + billing_op_id: 'op-topup', + operation_type: 'topup', + presentation: 'embedded', + resumed: true, + duration_ms: 1200 + }), + claim: { billing_client: 'sdk' } + }, + { + name: 'the SDK lifecycle times out a cancel operation', + event: toBillingTelemetryEvent({ + name: 'billing.operation.timeout', + billing_op_id: 'op-cancel', + operation_type: 'cancel', + presentation: 'hosted', + resumed: false, + failure_category: 'poll_timeout', + duration_ms: 600_000 + }), + claim: { billing_client: 'sdk' } + }, + { + name: 'the legacy poller fails a subscription operation', + event: { + operation: 'operation', + stage: 'failed', + outcome: 'failure', + operation_type: 'subscription', + billing_op_id: 'op-polled', + failure_category: 'provider_decline', + billing_client: 'legacy' + }, + claim: { billing_client: 'legacy' } + }, + { + name: 'shared workspace code starts a cancel before choosing a rail', + event: { + operation: 'operation', + stage: 'started', + outcome: 'pending', + operation_type: 'cancel' + }, + claim: {} + }, + { + name: 'shared workspace code reports a subscription checkout intent', + event: { + operation: 'subscription_checkout', + stage: 'intent', + outcome: 'pending', + tier: 'pro', + cycle: 'monthly' + }, + claim: {} + }, + { + name: 'shared workspace code starts a top-up', + event: { + operation: 'topup', + stage: 'started', + outcome: 'pending' + }, + claim: {} + }, + { + name: 'shared workspace code fails a resubscribe', + event: { + operation: 'resubscribe', + stage: 'failed', + outcome: 'failure', + source: 'settings_billing_panel', + failure_category: 'network' + }, + claim: {} + }, + { + name: 'shared workspace code starts a downgrade to personal', + event: { + operation: 'downgrade_to_personal', + stage: 'started', + outcome: 'pending', + member_removal_count: 1, + member_removal_failures: 0 + }, + claim: {} + }, + { + name: 'shared workspace code fails a capability read', + event: { + operation: 'capability_read', + stage: 'failed', + outcome: 'failure' + }, + claim: {} + } + ])( + 'carries only the client the emitter knows when $name', + ({ event, claim }) => { + const payload = getBillingTelemetryEventPayload(event) + expect( + Object.fromEntries( + Object.entries(payload).filter(([key]) => key === 'billing_client') + ) + ).toStrictEqual(claim) + } + ) + + it("keeps every field of the SDK lifecycle's event", () => { + const sdkFailure = toBillingTelemetryEvent({ + name: 'billing.operation.failed', + billing_op_id: 'op-declined', + operation_type: 'topup', + presentation: 'embedded', + resumed: false, + failure_category: 'provider_decline', + decline_reason: 'card_declined', + duration_ms: 2300 + }) + + expect(getBillingTelemetryEventPayload(sdkFailure)).toStrictEqual({ + operation: 'operation', + stage: 'failed', + outcome: 'failure', + operation_type: 'topup', + billing_op_id: 'op-declined', + presentation: 'embedded', + resumed: false, + failure_category: 'provider_decline', + decline_reason: 'card_declined', + duration_ms: 2300, + billing_client: 'sdk' + }) + }) + + it("keeps every field of the poller's event, which has no SDK fields", () => { + expect( + getBillingTelemetryEventPayload({ + operation: 'operation', + stage: 'failed', + outcome: 'failure', + operation_type: 'subscription', + billing_op_id: 'op-polled', + tier: 'pro', + cycle: 'monthly', + checkout_type: 'new', + payment_intent_source: 'subscribe_now_button', + failure_category: 'provider_decline', + duration_ms: 4200, + billing_client: 'legacy' + }) + ).toStrictEqual({ + operation: 'operation', + stage: 'failed', + outcome: 'failure', + operation_type: 'subscription', + billing_op_id: 'op-polled', + tier: 'pro', + cycle: 'monthly', + checkout_type: 'new', + payment_intent_source: 'subscribe_now_button', + failure_category: 'provider_decline', + duration_ms: 4200, + billing_client: 'legacy' + }) + }) + + it('drops fields outside the contract and claims no surface', () => { + const event = { + operation: 'topup', + stage: 'failed', + outcome: 'failure', + billing_op_id: 'opaque-op-id', + failure_category: 'unknown', + email: 'user@example.com', + billing_surface: 'billing_web' + } satisfies BillingTelemetryEvent & { + email: string + billing_surface: string + } + + expect(getBillingTelemetryEventPayload(event)).toStrictEqual({ + operation: 'topup', + stage: 'failed', + outcome: 'failure', + billing_op_id: 'opaque-op-id', + failure_category: 'unknown' + }) + }) +}) diff --git a/src/platform/telemetry/webHandoffEvent.test.ts b/packages/account-core/src/core/billing/telemetry/webHandoffEvent.test.ts similarity index 97% rename from src/platform/telemetry/webHandoffEvent.test.ts rename to packages/account-core/src/core/billing/telemetry/webHandoffEvent.test.ts index 6bc13d18f64..5fce144adad 100644 --- a/src/platform/telemetry/webHandoffEvent.test.ts +++ b/packages/account-core/src/core/billing/telemetry/webHandoffEvent.test.ts @@ -1,8 +1,9 @@ +import { describe, expect, it } from 'vitest' + import { getBillingTelemetryEventPayload, getCloudAppBillingTelemetryEventPayload -} from '@comfyorg/account-core/billing' -import { describe, expect, it } from 'vitest' +} from './payload.js' describe('the web handoff event payload', () => { it.for([ diff --git a/src/platform/telemetry/billingTelemetryEvent.test.ts b/src/platform/telemetry/billingTelemetryEvent.test.ts deleted file mode 100644 index b84dca812a3..00000000000 --- a/src/platform/telemetry/billingTelemetryEvent.test.ts +++ /dev/null @@ -1,250 +0,0 @@ -import { - getBillingTelemetryEventPayload, - getCloudAppBillingTelemetryEventPayload, - toBillingTelemetryEvent -} from '@comfyorg/account-core/billing' -import type { BillingTelemetryEvent } from '@comfyorg/account-core/billing' -import { pick } from 'es-toolkit' -import { describe, expect, expectTypeOf, it } from 'vitest' - -type LateSuccessEvent = Extract< - BillingTelemetryEvent, - { recovery_outcome?: 'late_success' } -> - -describe('BillingTelemetryEvent', () => { - it('allows late success only on succeeded recovery terminals', () => { - expectTypeOf().toEqualTypeOf<'succeeded'>() - expectTypeOf().toEqualTypeOf< - 'subscription_checkout' | 'resubscribe' - >() - }) -}) - -describe('getBillingTelemetryEventPayload', () => { - it.for<{ - name: string - event: BillingTelemetryEvent - claim: { billing_client?: 'sdk' | 'legacy' } - }>([ - { - name: 'the SDK lifecycle starts a subscription operation', - event: toBillingTelemetryEvent({ - name: 'billing.operation.started', - billing_op_id: 'op-subscribe', - operation_type: 'subscription', - presentation: 'hosted', - resumed: false - }), - claim: { billing_client: 'sdk' } - }, - { - name: 'the SDK lifecycle settles a top-up operation', - event: toBillingTelemetryEvent({ - name: 'billing.operation.succeeded', - billing_op_id: 'op-topup', - operation_type: 'topup', - presentation: 'embedded', - resumed: true, - duration_ms: 1200 - }), - claim: { billing_client: 'sdk' } - }, - { - name: 'the SDK lifecycle times out a cancel operation', - event: toBillingTelemetryEvent({ - name: 'billing.operation.timeout', - billing_op_id: 'op-cancel', - operation_type: 'cancel', - presentation: 'hosted', - resumed: false, - failure_category: 'poll_timeout', - duration_ms: 600_000 - }), - claim: { billing_client: 'sdk' } - }, - { - name: 'the legacy poller fails a subscription operation', - event: { - operation: 'operation', - stage: 'failed', - outcome: 'failure', - operation_type: 'subscription', - billing_op_id: 'op-polled', - failure_category: 'provider_decline', - billing_client: 'legacy' - }, - claim: { billing_client: 'legacy' } - }, - { - name: 'shared workspace code starts a cancel before choosing a rail', - event: { - operation: 'operation', - stage: 'started', - outcome: 'pending', - operation_type: 'cancel' - }, - claim: {} - }, - { - name: 'shared workspace code reports a subscription checkout intent', - event: { - operation: 'subscription_checkout', - stage: 'intent', - outcome: 'pending', - tier: 'pro', - cycle: 'monthly' - }, - claim: {} - }, - { - name: 'shared workspace code starts a top-up', - event: { - operation: 'topup', - stage: 'started', - outcome: 'pending' - }, - claim: {} - }, - { - name: 'shared workspace code fails a resubscribe', - event: { - operation: 'resubscribe', - stage: 'failed', - outcome: 'failure', - source: 'settings_billing_panel', - failure_category: 'network' - }, - claim: {} - }, - { - name: 'shared workspace code starts a downgrade to personal', - event: { - operation: 'downgrade_to_personal', - stage: 'started', - outcome: 'pending', - member_removal_count: 1, - member_removal_failures: 0 - }, - claim: {} - }, - { - name: 'shared workspace code fails a capability read', - event: { - operation: 'capability_read', - stage: 'failed', - outcome: 'failure' - }, - claim: {} - } - ])( - 'carries only the client the emitter knows when $name', - ({ event, claim }) => { - expect( - pick(getBillingTelemetryEventPayload(event), ['billing_client']) - ).toStrictEqual(claim) - } - ) - - it("keeps every field of the SDK lifecycle's event", () => { - const sdkFailure = toBillingTelemetryEvent({ - name: 'billing.operation.failed', - billing_op_id: 'op-declined', - operation_type: 'topup', - presentation: 'embedded', - resumed: false, - failure_category: 'provider_decline', - decline_reason: 'card_declined', - duration_ms: 2300 - }) - - expect(getBillingTelemetryEventPayload(sdkFailure)).toStrictEqual({ - operation: 'operation', - stage: 'failed', - outcome: 'failure', - operation_type: 'topup', - billing_op_id: 'op-declined', - presentation: 'embedded', - resumed: false, - failure_category: 'provider_decline', - decline_reason: 'card_declined', - duration_ms: 2300, - billing_client: 'sdk' - }) - }) - - it("keeps every field of the poller's event, which has no SDK fields", () => { - expect( - getBillingTelemetryEventPayload({ - operation: 'operation', - stage: 'failed', - outcome: 'failure', - operation_type: 'subscription', - billing_op_id: 'op-polled', - tier: 'pro', - cycle: 'monthly', - checkout_type: 'new', - payment_intent_source: 'subscribe_now_button', - failure_category: 'provider_decline', - duration_ms: 4200, - billing_client: 'legacy' - }) - ).toStrictEqual({ - operation: 'operation', - stage: 'failed', - outcome: 'failure', - operation_type: 'subscription', - billing_op_id: 'op-polled', - tier: 'pro', - cycle: 'monthly', - checkout_type: 'new', - payment_intent_source: 'subscribe_now_button', - failure_category: 'provider_decline', - duration_ms: 4200, - billing_client: 'legacy' - }) - }) - - it('drops fields outside the contract and claims no surface', () => { - const event = { - operation: 'topup', - stage: 'failed', - outcome: 'failure', - billing_op_id: 'opaque-op-id', - failure_category: 'unknown', - email: 'user@example.com', - billing_surface: 'billing_web' - } satisfies BillingTelemetryEvent & { - email: string - billing_surface: string - } - - expect(getBillingTelemetryEventPayload(event)).toStrictEqual({ - operation: 'topup', - stage: 'failed', - outcome: 'failure', - billing_op_id: 'opaque-op-id', - failure_category: 'unknown' - }) - }) -}) - -describe('getCloudAppBillingTelemetryEventPayload', () => { - it('names the cloud app surface over any surface the event carries', () => { - const event = { - operation: 'resubscribe', - stage: 'started', - outcome: 'pending', - source: 'settings_billing_panel', - billing_surface: 'billing_web' - } satisfies BillingTelemetryEvent & { billing_surface: string } - - expect(getCloudAppBillingTelemetryEventPayload(event)).toStrictEqual({ - operation: 'resubscribe', - stage: 'started', - outcome: 'pending', - source: 'settings_billing_panel', - billing_surface: 'cloud_app' - }) - }) -}) diff --git a/src/platform/telemetry/checkoutJourneyEvent.test.ts b/src/platform/telemetry/checkoutJourneyEvent.test.ts deleted file mode 100644 index 2672fd07839..00000000000 --- a/src/platform/telemetry/checkoutJourneyEvent.test.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { - CHECKOUT_JOURNEY_EVENT_NAME_BY_PHASE, - CHECKOUT_JOURNEY_SCHEMA_VERSION, - getCheckoutJourneyTelemetryEventName, - getCheckoutJourneyTelemetryEventPayload -} from '@comfyorg/account-core/billing' -import type { CheckoutJourneyTelemetryEvent } from '@comfyorg/account-core/billing' -import { describe, expect, it } from 'vitest' - -const baseContext = { - checkout_journey_id: 'journey-1', - checkout_entered_at: '2026-09-09T00:00:00.000Z', - entry_flow: 'initial_subscription', - entry_source: 'pricing' -} as const - -describe('getCheckoutJourneyTelemetryEventName', () => { - it('derives the wire name from the phase', () => { - const event: CheckoutJourneyTelemetryEvent = { - ...baseContext, - phase: 'preview_ready', - assignment_status: 'resolved', - assigned_arm: 'treatment' - } - expect(getCheckoutJourneyTelemetryEventName(event)).toBe( - 'billing.checkout.preview_ready' - ) - }) - - // The table is a total Record, so a missing phase fails to compile — but a - // swapped value (entered -> 'billing.checkout.submitted') would not. Comparing - // each key against its own value restores what the template literal proved. - it.for(Object.entries(CHECKOUT_JOURNEY_EVENT_NAME_BY_PHASE))( - 'names %s after its own phase', - ([phase, name]) => { - expect(name).toBe(`billing.checkout.${phase}`) - - const event = { - ...baseContext, - phase, - assignment_status: 'unavailable' - } as CheckoutJourneyTelemetryEvent - expect(getCheckoutJourneyTelemetryEventName(event)).toBe(name) - } - ) -}) - -describe('getCheckoutJourneyTelemetryEventPayload', () => { - it('stamps schema version and carries the resolved arm', () => { - const event: CheckoutJourneyTelemetryEvent = { - ...baseContext, - phase: 'entered', - assignment_status: 'resolved', - assigned_arm: 'control' - } - const payload = getCheckoutJourneyTelemetryEventPayload(event) - expect(payload.schema_version).toBe(CHECKOUT_JOURNEY_SCHEMA_VERSION) - expect(payload.assigned_arm).toBe('control') - }) - - it('omits assigned_arm when assignment is unavailable', () => { - const event: CheckoutJourneyTelemetryEvent = { - ...baseContext, - phase: 'entered', - assignment_status: 'unavailable' - } - const payload = getCheckoutJourneyTelemetryEventPayload(event) - expect(payload.assignment_status).toBe('unavailable') - expect('assigned_arm' in payload).toBe(false) - }) - - it('omits absent optional context rather than emitting undefined keys', () => { - const event: CheckoutJourneyTelemetryEvent = { - ...baseContext, - phase: 'entered', - assignment_status: 'unavailable' - } - const payload = getCheckoutJourneyTelemetryEventPayload(event) - expect('billing_op_id' in payload).toBe(false) - expect('ui_mode' in payload).toBe(false) - }) - - it('carries the ui_mode the user actually saw', () => { - const event: CheckoutJourneyTelemetryEvent = { - ...baseContext, - phase: 'entered', - assignment_status: 'resolved', - assigned_arm: 'treatment', - ui_mode: 'embedded' - } - const payload = getCheckoutJourneyTelemetryEventPayload(event) - expect(payload.ui_mode).toBe('embedded') - }) - - it('carries phase-specific fields for a failed preview', () => { - const event: CheckoutJourneyTelemetryEvent = { - ...baseContext, - phase: 'preview_failed', - assignment_status: 'resolved', - assigned_arm: 'treatment', - failure_category: 'network', - preview_revision: 'rev-7' - } - const payload = getCheckoutJourneyTelemetryEventPayload(event) - expect(payload).toMatchObject({ - phase: 'preview_failed', - failure_category: 'network', - preview_revision: 'rev-7' - }) - }) - - it('distinguishes the failing element from the failure phase', () => { - const event: CheckoutJourneyTelemetryEvent = { - ...baseContext, - phase: 'payment_element_failed', - assignment_status: 'resolved', - assigned_arm: 'treatment', - element: 'address', - element_phase: 'mount' - } - const payload = getCheckoutJourneyTelemetryEventPayload(event) - expect(payload).toMatchObject({ - element: 'address', - element_phase: 'mount' - }) - }) -})