From 60fec59cda287e0437d588a13fae16636bedcd6c Mon Sep 17 00:00:00 2001 From: "daniel.bento" Date: Thu, 8 Feb 2024 12:57:01 +0000 Subject: [PATCH 1/2] feat: add advanced mode gcm in --- .../src/analytics/integrations/GA4/GA4.ts | 19 ++++++++++ .../integrations/GA4/__tests__/GA4.test.ts | 36 +++++++++++++++---- .../GoogleConsentMode/GoogleConsentMode.ts | 16 +++++---- .../shared/GoogleConsentMode/types.ts | 1 + 4 files changed, 58 insertions(+), 14 deletions(-) diff --git a/packages/react/src/analytics/integrations/GA4/GA4.ts b/packages/react/src/analytics/integrations/GA4/GA4.ts index 2cf194e71..cce3d7b31 100644 --- a/packages/react/src/analytics/integrations/GA4/GA4.ts +++ b/packages/react/src/analytics/integrations/GA4/GA4.ts @@ -183,6 +183,25 @@ class GA4 extends integrations.Integration { return this; } + /** + * Method to check if the integration is ready to be loaded. + * + * @param consent - User consent data. + * @param options - Options passed for the GA4 integration. + * + * @returns If the integration is ready to be loaded. + */ + static override shouldLoad( + consent: ConsentData, + options: GA4IntegrationOptions, + ) { + if (get(options, `${OPTION_GOOGLE_CONSENT_CONFIG}.mode`) === 'Advanced') { + return true; + } + + return super.shouldLoad(consent, options); + } + /** * Send page events to GA4. * diff --git a/packages/react/src/analytics/integrations/GA4/__tests__/GA4.test.ts b/packages/react/src/analytics/integrations/GA4/__tests__/GA4.test.ts index e8b1b591c..2dcce0681 100644 --- a/packages/react/src/analytics/integrations/GA4/__tests__/GA4.test.ts +++ b/packages/react/src/analytics/integrations/GA4/__tests__/GA4.test.ts @@ -90,6 +90,10 @@ function getWindowGa4Spy() { } describe('GA4 Integration', () => { + const validOptions = { + measurementId: 'GA-123456-12', + }; + beforeEach(() => { jest.clearAllMocks(); }); @@ -99,21 +103,39 @@ describe('GA4 Integration', () => { }); it('`shouldLoad` should return false if there is no user consent', () => { - expect(GA4.shouldLoad({ statistics: false }, {})).toBe(false); - expect(GA4.shouldLoad({}, {})).toBe(false); + expect(GA4.shouldLoad({ statistics: false }, { ...validOptions })).toBe( + false, + ); + expect(GA4.shouldLoad({}, { ...validOptions })).toBe(false); }); it('`shouldLoad` should return true if there is user consent', () => { - expect(GA4.shouldLoad({ statistics: true }, {})).toBe(true); + expect(GA4.shouldLoad({ statistics: true }, { ...validOptions })).toBe( + true, + ); + }); + + it('`shouldLoad` should return true if google consent mode option was passed as `Advanced`', () => { + expect( + GA4.shouldLoad( + {}, + { + ...validOptions, + googleConsentConfig: { + ad_personalization: {}, + ad_storage: {}, + ad_user_data: {}, + analytics_storage: {}, + mode: 'Advanced', + }, + }, + ), + ).toBe(true); }); describe('GA4 instance', () => { let ga4Instance; - const validOptions = { - measurementId: 'GA-123456-12', - }; - const loadData: LoadIntegrationEventData = { ...loadIntegrationData, user: { diff --git a/packages/react/src/analytics/integrations/shared/GoogleConsentMode/GoogleConsentMode.ts b/packages/react/src/analytics/integrations/shared/GoogleConsentMode/GoogleConsentMode.ts index 1a41c7b8f..4e14b5c75 100644 --- a/packages/react/src/analytics/integrations/shared/GoogleConsentMode/GoogleConsentMode.ts +++ b/packages/react/src/analytics/integrations/shared/GoogleConsentMode/GoogleConsentMode.ts @@ -12,7 +12,7 @@ import { isEqual, omit } from 'lodash-es'; export class GoogleConsentMode { private dataLayer!: string; // Stores different data layer names private config?: GoogleConsentModeConfig; // Stores default or customized consent category mappings - private configExcludingRegionsAndWaitForUpdate!: Record< + private configExcludingModeRegionsAndWaitForUpdate!: Record< string, GoogleConsentCategoryConfig >; // exclude not consent properties from config @@ -30,9 +30,10 @@ export class GoogleConsentMode { this.config = config; // select only the Google Consent Elements - this.configExcludingRegionsAndWaitForUpdate = omit(this.config || {}, [ + this.configExcludingModeRegionsAndWaitForUpdate = omit(this.config || {}, [ 'waitForUpdate', 'regions', + 'mode', ]); this.loadDefaults(initConsent); @@ -52,13 +53,13 @@ export class GoogleConsentMode { // Obtain default google consent registry const consentRegistry = Object.keys( - this.configExcludingRegionsAndWaitForUpdate, + this.configExcludingModeRegionsAndWaitForUpdate, ).reduce( (result, consentKey) => ({ ...result, [consentKey]: - this.configExcludingRegionsAndWaitForUpdate[consentKey]?.default || - GoogleConsentType.Denied, + this.configExcludingModeRegionsAndWaitForUpdate[consentKey] + ?.default || GoogleConsentType.Denied, }), initialValue, ); @@ -87,10 +88,11 @@ export class GoogleConsentMode { // Fill consent value into consent element, using analytics consent categories const consentRegistry = Object.keys( - this.configExcludingRegionsAndWaitForUpdate, + this.configExcludingModeRegionsAndWaitForUpdate, ).reduce((result, consentKey) => { let consentValue = GoogleConsentType.Denied; - const consent = this.configExcludingRegionsAndWaitForUpdate[consentKey]; + const consent = + this.configExcludingModeRegionsAndWaitForUpdate[consentKey]; if (consent) { // has consent config key diff --git a/packages/react/src/analytics/integrations/shared/GoogleConsentMode/types.ts b/packages/react/src/analytics/integrations/shared/GoogleConsentMode/types.ts index b9e5ac1b4..adbc06f1b 100644 --- a/packages/react/src/analytics/integrations/shared/GoogleConsentMode/types.ts +++ b/packages/react/src/analytics/integrations/shared/GoogleConsentMode/types.ts @@ -26,4 +26,5 @@ export type GoogleConsentModeConfig = GoogleConsentMappingsBase & { regions?: Array; waitForUpdate?: number; + mode?: 'Basic' | 'Advanced'; }; From 8616eb7939eea57ba80ba1390d7c5495a0609a3e Mon Sep 17 00:00:00 2001 From: Ana Pimentel Date: Fri, 9 Feb 2024 15:39:34 +0000 Subject: [PATCH 2/2] feat(client): add packaging options client This adds the client for packaging options for an order. It also updates missing types for the checkout order such as metadata. --- .../__snapshots__/index.test.ts.snap | 1 + .../getPackagingOptions.fixtures.ts | 17 +++++++++ .../getPackagingOptions.test.ts.snap | 11 ++++++ .../__tests__/getCheckoutOrderDetails.test.ts | 1 + .../__tests__/getPackagingOptions.test.ts | 38 +++++++++++++++++++ .../src/checkout/getPackagingOptions.ts | 22 +++++++++++ packages/client/src/checkout/index.ts | 1 + .../src/checkout/types/checkoutOrder.types.ts | 3 ++ .../checkout/types/checkoutOrderItem.types.ts | 2 + .../types/getPackagingOptions.types.ts | 11 ++++++ packages/client/src/checkout/types/index.ts | 2 + .../checkout/types/packagingOption.types.ts | 1 + .../types/patchCheckoutOrder.types.ts | 3 +- .../checkout/types/postCheckoutOrder.types.ts | 4 +- .../createCheckoutOrder.test.ts.snap | 2 + .../fetchCheckoutOrder.test.ts.snap | 2 + ...removeCheckoutOrderPromocodes.test.ts.snap | 2 + .../setCheckoutOrderItemTags.test.ts.snap | 2 + .../setCheckoutOrderPromocodes.test.ts.snap | 2 + .../setCheckoutOrderTags.test.ts.snap | 2 + .../updateCheckoutOrder.test.ts.snap | 6 +++ .../checkout/checkout.fixtures.mts | 10 ++--- tests/__fixtures__/checkout/index.mts | 1 + .../checkout/packagingOptions.fixtures.mts | 3 ++ 24 files changed, 141 insertions(+), 8 deletions(-) create mode 100644 packages/client/src/checkout/__fixtures__/getPackagingOptions.fixtures.ts create mode 100644 packages/client/src/checkout/__tests__/__snapshots__/getPackagingOptions.test.ts.snap create mode 100644 packages/client/src/checkout/__tests__/getPackagingOptions.test.ts create mode 100644 packages/client/src/checkout/getPackagingOptions.ts create mode 100644 packages/client/src/checkout/types/getPackagingOptions.types.ts create mode 100644 packages/client/src/checkout/types/packagingOption.types.ts create mode 100644 tests/__fixtures__/checkout/packagingOptions.fixtures.mts diff --git a/packages/client/src/__tests__/__snapshots__/index.test.ts.snap b/packages/client/src/__tests__/__snapshots__/index.test.ts.snap index 524d5f1c0..5e2ff59ab 100644 --- a/packages/client/src/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/client/src/__tests__/__snapshots__/index.test.ts.snap @@ -1139,6 +1139,7 @@ Object { "getOrderItemAvailableActivities": [Function], "getOrderReturnOptions": [Function], "getOrderShippingAddressChangeRequests": [Function], + "getPackagingOptions": [Function], "getPaymentIntent": [Function], "getPaymentIntentCharge": [Function], "getPaymentIntentInstrument": [Function], diff --git a/packages/client/src/checkout/__fixtures__/getPackagingOptions.fixtures.ts b/packages/client/src/checkout/__fixtures__/getPackagingOptions.fixtures.ts new file mode 100644 index 000000000..c6f3a6644 --- /dev/null +++ b/packages/client/src/checkout/__fixtures__/getPackagingOptions.fixtures.ts @@ -0,0 +1,17 @@ +import { rest, type RestHandler } from 'msw'; +import type { PackagingOption } from '../types/index.js'; + +const path = '/api/checkout/v1/packagingOptions'; + +const fixtures = { + success: (response: PackagingOption[]): RestHandler => + rest.get(path, (_req, res, ctx) => + res(ctx.status(200), ctx.json(response)), + ), + failure: (): RestHandler => + rest.get(path, (_req, res, ctx) => + res(ctx.status(404), ctx.json({ message: 'stub error' })), + ), +}; + +export default fixtures; diff --git a/packages/client/src/checkout/__tests__/__snapshots__/getPackagingOptions.test.ts.snap b/packages/client/src/checkout/__tests__/__snapshots__/getPackagingOptions.test.ts.snap new file mode 100644 index 000000000..021d3fc14 --- /dev/null +++ b/packages/client/src/checkout/__tests__/__snapshots__/getPackagingOptions.test.ts.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`checkout client getPackagingOptions should receive a client request error 1`] = ` +Object { + "code": "-1", + "message": "stub error", + "name": "AxiosError", + "status": 404, + "transportLayerErrorCode": "ERR_BAD_REQUEST", +} +`; diff --git a/packages/client/src/checkout/__tests__/getCheckoutOrderDetails.test.ts b/packages/client/src/checkout/__tests__/getCheckoutOrderDetails.test.ts index 5554abf01..142c923bf 100644 --- a/packages/client/src/checkout/__tests__/getCheckoutOrderDetails.test.ts +++ b/packages/client/src/checkout/__tests__/getCheckoutOrderDetails.test.ts @@ -350,6 +350,7 @@ describe('checkout client', () => { hadUnavailableItems: true, isGuestUser: true, shippingMode: ShippingMode.ByMerchant, + customerId: 123, }, shippingOptions: [ { diff --git a/packages/client/src/checkout/__tests__/getPackagingOptions.test.ts b/packages/client/src/checkout/__tests__/getPackagingOptions.test.ts new file mode 100644 index 000000000..04a45bcb0 --- /dev/null +++ b/packages/client/src/checkout/__tests__/getPackagingOptions.test.ts @@ -0,0 +1,38 @@ +import * as checkoutClient from '../index.js'; +import { mockPackagingOptionsResponse } from 'tests/__fixtures__/checkout/packagingOptions.fixtures.mjs'; +import { type PackagingOption } from '../types/index.js'; +import client from '../../helpers/client/index.js'; +import fixtures from '../__fixtures__/getPackagingOptions.fixtures.js'; +import mswServer from '../../../tests/mswServer.js'; + +describe('checkout client', () => { + const expectedConfig = undefined; + + beforeEach(() => jest.clearAllMocks()); + + describe('getPackagingOptions', () => { + const spy = jest.spyOn(client, 'get'); + const query = { channelCode: 'code' }; + const urlToBeCalled = `/checkout/v1/packagingOptions?channelCode=${query.channelCode}`; + + it('should handle a client request successfully', async () => { + const response: PackagingOption[] = mockPackagingOptionsResponse; + + mswServer.use(fixtures.success(response)); + + await expect( + checkoutClient.getPackagingOptions(query), + ).resolves.toStrictEqual(response); + expect(spy).toHaveBeenCalledWith(urlToBeCalled, expectedConfig); + }); + + it('should receive a client request error', async () => { + mswServer.use(fixtures.failure()); + + await expect( + checkoutClient.getPackagingOptions(query), + ).rejects.toMatchSnapshot(); + expect(spy).toHaveBeenCalledWith(urlToBeCalled, expectedConfig); + }); + }); +}); diff --git a/packages/client/src/checkout/getPackagingOptions.ts b/packages/client/src/checkout/getPackagingOptions.ts new file mode 100644 index 000000000..2f3187165 --- /dev/null +++ b/packages/client/src/checkout/getPackagingOptions.ts @@ -0,0 +1,22 @@ +import { adaptError } from '../helpers/client/formatError.js'; +import client from '../helpers/client/index.js'; +import join from 'proper-url-join'; +import type { GetPackagingOptions } from './types/index.js'; + +/** + * Method responsible for loading the packaging options. + * + * @param query - Query params. + * @param config - Custom configurations to send to the client instance (axios). + * + * @returns Promise that will resolve when the call to the endpoint finishes. + */ +const getPackagingOptions: GetPackagingOptions = (query, config) => + client + .get(join('/checkout/v1/packagingOptions', { query }), config) + .then(response => response.data) + .catch(error => { + throw adaptError(error); + }); + +export default getPackagingOptions; diff --git a/packages/client/src/checkout/index.ts b/packages/client/src/checkout/index.ts index be32ee7f2..2ee91f2b1 100644 --- a/packages/client/src/checkout/index.ts +++ b/packages/client/src/checkout/index.ts @@ -20,6 +20,7 @@ export { default as getCheckoutSession } from './getCheckoutSession.js'; export { default as getCheckoutSessionCharge } from './getCheckoutSessionCharge.js'; export { default as getCheckoutSessionTags } from './getCheckoutSessionTags.js'; export { default as getCollectPoints } from './getCollectPoints.js'; +export { default as getPackagingOptions } from './getPackagingOptions.js'; export { default as patchCheckoutOrder } from './patchCheckoutOrder.js'; export { default as patchCheckoutOrderDeliveryBundles } from './patchCheckoutOrderDeliveryBundles.js'; export { default as patchCheckoutOrderDeliveryBundleUpgrades } from './patchCheckoutOrderDeliveryBundleUpgrades.js'; diff --git a/packages/client/src/checkout/types/checkoutOrder.types.ts b/packages/client/src/checkout/types/checkoutOrder.types.ts index bf701aae4..54d3f64fd 100644 --- a/packages/client/src/checkout/types/checkoutOrder.types.ts +++ b/packages/client/src/checkout/types/checkoutOrder.types.ts @@ -5,6 +5,7 @@ import type { import type { CheckoutOrderItem, CheckoutOrderMerchant } from './index.js'; import type { CustomerTypeLegacy } from '../../orders/types/order.types.js'; import type { MerchantLocation } from '../../merchantsLocations/types/merchantLocation.types.js'; +import type { Metadata } from '../../types/index.js'; import type { PaymentIntent } from '../../payments/index.js'; import type { PromotionEvaluationId } from '../../promotionEvaluations/index.js'; @@ -78,4 +79,6 @@ export type CheckoutOrder = { shippingMode: ShippingMode; paymentIntentId?: PaymentIntent['id']; promotionEvaluationId?: PromotionEvaluationId; + customerId: number; + metadata?: Metadata; }; diff --git a/packages/client/src/checkout/types/checkoutOrderItem.types.ts b/packages/client/src/checkout/types/checkoutOrderItem.types.ts index c17e57913..b65085572 100644 --- a/packages/client/src/checkout/types/checkoutOrderItem.types.ts +++ b/packages/client/src/checkout/types/checkoutOrderItem.types.ts @@ -2,6 +2,7 @@ import type { Brand, CheckoutOrderItemStatus, Color, + Metadata, OrderItemCreationChannelLegacy, Price, Product, @@ -77,4 +78,5 @@ export type CheckoutOrderItem = { subTotalOriginalAmount: number; }; selectedSaleIntent?: SaleIntent & string; + metadata?: Metadata; }; diff --git a/packages/client/src/checkout/types/getPackagingOptions.types.ts b/packages/client/src/checkout/types/getPackagingOptions.types.ts new file mode 100644 index 000000000..e0ca1e0d3 --- /dev/null +++ b/packages/client/src/checkout/types/getPackagingOptions.types.ts @@ -0,0 +1,11 @@ +import type { Config } from '../../types/index.js'; +import type { PackagingOption } from './index.js'; + +export type GetPackagingOptionsQuery = { + channelCode: string; +}; + +export type GetPackagingOptions = ( + query?: GetPackagingOptionsQuery, + config?: Config, +) => Promise; diff --git a/packages/client/src/checkout/types/index.ts b/packages/client/src/checkout/types/index.ts index f0effd78e..67cc92a29 100644 --- a/packages/client/src/checkout/types/index.ts +++ b/packages/client/src/checkout/types/index.ts @@ -31,7 +31,9 @@ export * from './getCheckoutSession.types.js'; export * from './getCheckoutSessionCharge.types.js'; export * from './getCheckoutSessionTags.types.js'; export * from './getCollectPoints.types.js'; +export * from './getPackagingOptions.types.js'; export * from './itemDeliveryProvisioning.types.js'; +export * from './packagingOption.types.js'; export * from './patchCheckoutOrder.types.js'; export * from './patchCheckoutOrderDeliveryBundles.types.js'; export * from './patchCheckoutOrderDeliveryBundleUpgrades.types.js'; diff --git a/packages/client/src/checkout/types/packagingOption.types.ts b/packages/client/src/checkout/types/packagingOption.types.ts new file mode 100644 index 000000000..a47619c7d --- /dev/null +++ b/packages/client/src/checkout/types/packagingOption.types.ts @@ -0,0 +1 @@ +export type PackagingOption = string; diff --git a/packages/client/src/checkout/types/patchCheckoutOrder.types.ts b/packages/client/src/checkout/types/patchCheckoutOrder.types.ts index f84caa924..3eb875644 100644 --- a/packages/client/src/checkout/types/patchCheckoutOrder.types.ts +++ b/packages/client/src/checkout/types/patchCheckoutOrder.types.ts @@ -1,4 +1,4 @@ -import type { CheckoutAddress, Config } from '../../types/index.js'; +import type { CheckoutAddress, Config, Metadata } from '../../types/index.js'; import type { CheckoutOrder, CheckoutOrderShippingOption, @@ -18,6 +18,7 @@ export type PatchCheckoutOrderData = { shippingOption?: CheckoutOrderShippingOption; deliveryBundleUpdate?: CheckoutOrderDeliveryBundleUpdate; email?: string; + metadata?: Metadata; }; export type PatchCheckoutOrder = ( diff --git a/packages/client/src/checkout/types/postCheckoutOrder.types.ts b/packages/client/src/checkout/types/postCheckoutOrder.types.ts index d323655cd..132a53bdc 100644 --- a/packages/client/src/checkout/types/postCheckoutOrder.types.ts +++ b/packages/client/src/checkout/types/postCheckoutOrder.types.ts @@ -1,5 +1,5 @@ import type { Bag } from '../../bags/index.js'; -import type { Config } from '../../types/index.js'; +import type { Config, Metadata } from '../../types/index.js'; import type { GetCheckoutOrderResponse, ShippingMode } from './index.js'; import type { Product } from '../../products/types/index.js'; @@ -22,11 +22,13 @@ export type PostCheckoutOrderItem = { export type PostCheckoutOrderDataWithItems = PostCheckoutOrderData & { items: PostCheckoutOrderItem[]; + metadata?: Metadata; }; export type PostCheckoutOrderDataWithBag = PostCheckoutOrderData & { bagId: Bag['id']; removePurchasedItemsFromBag?: boolean; + metadata?: Metadata; }; export type PostCheckoutOrderDataWithDraftOrder = { diff --git a/packages/redux/src/checkout/actions/__tests__/__snapshots__/createCheckoutOrder.test.ts.snap b/packages/redux/src/checkout/actions/__tests__/__snapshots__/createCheckoutOrder.test.ts.snap index cee9f82a3..8fc143b46 100644 --- a/packages/redux/src/checkout/actions/__tests__/__snapshots__/createCheckoutOrder.test.ts.snap +++ b/packages/redux/src/checkout/actions/__tests__/__snapshots__/createCheckoutOrder.test.ts.snap @@ -293,6 +293,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -310,6 +311,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "shippingAddress": Object { diff --git a/packages/redux/src/checkout/actions/__tests__/__snapshots__/fetchCheckoutOrder.test.ts.snap b/packages/redux/src/checkout/actions/__tests__/__snapshots__/fetchCheckoutOrder.test.ts.snap index 7fa9691af..a01a419d7 100644 --- a/packages/redux/src/checkout/actions/__tests__/__snapshots__/fetchCheckoutOrder.test.ts.snap +++ b/packages/redux/src/checkout/actions/__tests__/__snapshots__/fetchCheckoutOrder.test.ts.snap @@ -293,6 +293,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -310,6 +311,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "shippingAddress": Object { diff --git a/packages/redux/src/checkout/actions/__tests__/__snapshots__/removeCheckoutOrderPromocodes.test.ts.snap b/packages/redux/src/checkout/actions/__tests__/__snapshots__/removeCheckoutOrderPromocodes.test.ts.snap index b8f9a43b1..4df8fd4cf 100644 --- a/packages/redux/src/checkout/actions/__tests__/__snapshots__/removeCheckoutOrderPromocodes.test.ts.snap +++ b/packages/redux/src/checkout/actions/__tests__/__snapshots__/removeCheckoutOrderPromocodes.test.ts.snap @@ -293,6 +293,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -310,6 +311,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "shippingAddress": Object { diff --git a/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderItemTags.test.ts.snap b/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderItemTags.test.ts.snap index 6dc7a4a9f..9419aa061 100644 --- a/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderItemTags.test.ts.snap +++ b/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderItemTags.test.ts.snap @@ -293,6 +293,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -310,6 +311,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "shippingAddress": Object { diff --git a/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderPromocodes.test.ts.snap b/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderPromocodes.test.ts.snap index 2c18cb130..206aeceea 100644 --- a/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderPromocodes.test.ts.snap +++ b/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderPromocodes.test.ts.snap @@ -293,6 +293,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -310,6 +311,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "promocode": "123", diff --git a/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderTags.test.ts.snap b/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderTags.test.ts.snap index fddbc3e7d..51d365a51 100644 --- a/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderTags.test.ts.snap +++ b/packages/redux/src/checkout/actions/__tests__/__snapshots__/setCheckoutOrderTags.test.ts.snap @@ -293,6 +293,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -310,6 +311,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "shippingAddress": Object { diff --git a/packages/redux/src/checkout/actions/__tests__/__snapshots__/updateCheckoutOrder.test.ts.snap b/packages/redux/src/checkout/actions/__tests__/__snapshots__/updateCheckoutOrder.test.ts.snap index 930230998..7cd155202 100644 --- a/packages/redux/src/checkout/actions/__tests__/__snapshots__/updateCheckoutOrder.test.ts.snap +++ b/packages/redux/src/checkout/actions/__tests__/__snapshots__/updateCheckoutOrder.test.ts.snap @@ -293,6 +293,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -310,6 +311,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "shippingAddress": Object { @@ -739,6 +741,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -756,6 +759,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "shippingAddress": Object { @@ -1185,6 +1189,7 @@ Object { }, ], "currency": "EUR", + "customerId": 123, "customerType": 0, "formattedGrandTotal": "102 €", "formattedSubTotalAmount": "100 €", @@ -1202,6 +1207,7 @@ Object { 30380051, ], "locale": "en-US", + "metadata": Object {}, "orderId": "D7XM6Y", "paymentIntentId": "123", "shippingAddress": Object { diff --git a/tests/__fixtures__/checkout/checkout.fixtures.mts b/tests/__fixtures__/checkout/checkout.fixtures.mts index b8f4376c7..2105d42c4 100644 --- a/tests/__fixtures__/checkout/checkout.fixtures.mts +++ b/tests/__fixtures__/checkout/checkout.fixtures.mts @@ -428,6 +428,8 @@ export const mockResponse = { isGuestUser: true, shippingMode: ShippingMode.ByMerchant, status: CheckoutOrderStatus.Opened, + metadata: {}, + customerId: 123, }, deliveryBundles: mockDeliveryBundlesResponse, shippingOptions: [], @@ -791,12 +793,6 @@ export const mockCheckoutDetailsEntity = { shippingOptions: [], }; -// export const checkoutOrderItemEntity = { -// id: checkoutOrderItemId, -// product: productId, -// tags: ['GIFT'], -// }; - export const mockCheckoutOrderItemEntity = { // Since a lot of properties are ommited for the CheckoutOrderItemEntity type, // we didn't spread the properties from the original mockCheckoutOrderItem (...mockCheckoutOrderItem) @@ -937,6 +933,8 @@ export const mockUpdateCheckoutResponse = { }, orderStatus: OrderStatusError.NoError, id: 123, + customerId: 123, + metadata: {}, }, }, }; diff --git a/tests/__fixtures__/checkout/index.mts b/tests/__fixtures__/checkout/index.mts index b3c368b39..78ef9b1cb 100644 --- a/tests/__fixtures__/checkout/index.mts +++ b/tests/__fixtures__/checkout/index.mts @@ -1,3 +1,4 @@ export * from './checkout.fixtures.mjs'; export * from './checkoutSessions.fixtures.mjs'; export * from './draftOrders.fixtures.mjs'; +export * from './packagingOptions.fixtures.mjs'; diff --git a/tests/__fixtures__/checkout/packagingOptions.fixtures.mts b/tests/__fixtures__/checkout/packagingOptions.fixtures.mts new file mode 100644 index 000000000..e28adcc0b --- /dev/null +++ b/tests/__fixtures__/checkout/packagingOptions.fixtures.mts @@ -0,0 +1,3 @@ +export const mockPackagingOption = 'Basic'; + +export const mockPackagingOptionsResponse = [mockPackagingOption, 'Signature'];