Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions libs/deps/mas/commerce.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions libs/deps/mas/merch-card-collection.js

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions libs/features/mas/dist/mas.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions libs/features/mas/src/buildCheckoutUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ export function buildCheckoutUrl(checkoutData) {
url = add3in1Parameters({
url,
modal,
customerSegment: customerSegment ?? items?.[0]?.customerSegment,
marketSegment: marketSegment ?? items?.[0]?.marketSegment,
customerSegment: customerSegment,
marketSegment: marketSegment,
cs,
ms,
quantity: items?.[0]?.quantity > 1 && items?.[0]?.quantity,
productArrangementCode: productArrangementCode ?? items?.[0]?.productArrangementCode,
productArrangementCode: productArrangementCode,
addonProductArrangementCode: productArrangementCode
? items?.find((item) => item.productArrangementCode !== productArrangementCode)?.productArrangementCode
: items?.[1]?.productArrangementCode,
Expand Down
27 changes: 12 additions & 15 deletions libs/features/mas/src/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function Checkout({ providers, settings }) {
const { env, landscape } = settings;
const {
checkoutClientId: clientId,
checkoutMarketSegment: marketSegment,
checkoutMarketSegment,
checkoutWorkflow: workflow,
checkoutWorkflowStep: workflowStep,
country,
Expand All @@ -107,23 +107,21 @@ export function Checkout({ providers, settings }) {
country,
env,
items: [],
marketSegment,
marketSegment: checkoutMarketSegment,
workflowStep,
landscape,
...rest,
};
// even if CTA has multiple offers, they should have same ms, cs, ot values
const [{ productArrangementCode, marketSegments: [marketSegment], customerSegment, offerType, }] = offers;
Object.assign(data, {
productArrangementCode,
marketSegment,
customerSegment,
offerType,
});
if (offers.length === 1) {
const [{ offerId, offerType, productArrangementCode }] = offers;
const {
marketSegments: [marketSegment],
customerSegment,
} = offers[0];
Object.assign(data, {
marketSegment,
customerSegment,
offerType,
productArrangementCode,
});
const { offerId } = offers[0];
data.items.push(
quantity[0] === 1
? { id: offerId }
Expand All @@ -132,10 +130,9 @@ export function Checkout({ providers, settings }) {
} else {
/* c8 ignore next 7 */
data.items.push(
...offers.map(({ offerId, productArrangementCode, marketSegments, customerSegment }, index) => ({
...offers.map(({ offerId }, index) => ({
id: offerId,
quantity: quantity[index] ?? Defaults.quantity,
...(is3in1 ? { productArrangementCode, marketSegment: marketSegments[0], customerSegment } : {}),
})),
);
}
Expand Down
16 changes: 0 additions & 16 deletions libs/features/mas/test/build-checkout-url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,6 @@ describe('buildCheckoutUrl', () => {
expect(parsedUrl.searchParams.has('q')).to.be.false;
});

it('should handle product arrangement code from items when not provided in root', () => {
const checkoutData = {
env: PROVIDER_ENVIRONMENT.PRODUCTION,
workflowStep: CheckoutWorkflowStep.SEGMENTATION,
clientId: 'testClient',
country: 'US',
items: [{ productArrangementCode: 'PAC123' }],
modal: 'twp',
customerSegment: 'INDIVIDUAL',
marketSegment: 'EDU'
};
const url = buildCheckoutUrl(checkoutData);
const parsedUrl = new URL(url);
expect(parsedUrl.searchParams.get('pa')).to.equal('PAC123');
});

it('should handle addon product arrangement code when root pa is provided', () => {
const checkoutData = {
env: PROVIDER_ENVIRONMENT.PRODUCTION,
Expand Down