From fa3f858e6f748f21456432d7f7215bad8ef4525b Mon Sep 17 00:00:00 2001 From: Bozo Jovicic Date: Thu, 28 Nov 2024 12:47:04 +0100 Subject: [PATCH 1/4] MWPW-157864 [Catalog] Localise external modals --- libs/blocks/merch/merch.js | 10 ++++++++- test/blocks/merch/merch.test.js | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index 73afd8b8eb..a4c1af6a63 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -512,6 +512,14 @@ export function setCtaHash(el, checkoutLinkConfig, offerType) { return hash; } +const isProdModal = (url) => { + try { + return (new URL(url)).hostname.endsWith('adobe.com'); + } catch (e) { + return false; + } +} + export async function getModalAction(offers, options, el) { const [{ offerType, @@ -529,7 +537,7 @@ export async function getModalAction(offers, options, el) { const hash = setCtaHash(el, checkoutLinkConfig, offerType); let url = checkoutLinkConfig[columnName]; if (!url) return undefined; - url = isInternalModal(url) + url = isInternalModal(url) || isProdModal(url) ? localizeLink(checkoutLinkConfig[columnName]) : checkoutLinkConfig[columnName]; return { url, handler: (e) => openModal(e, url, offerType, hash, options.extraOptions) }; } diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index c9ced0e16e..660e83201c 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -76,6 +76,14 @@ const CHECKOUT_LINK_CONFIGS = { PRODUCT_FAMILY: 'testProductCode', DOWNLOAD_TEXT: 'productCode', }, + { + "PRODUCT_FAMILY": "AUDITION", + "DOWNLOAD_TEXT": "Download", + "DOWNLOAD_URL": "https://creativecloud.adobe.com/apps/download/audition", + "FREE_TRIAL_PATH": "https://www.adobe.com/mini-plans/audition.html?mid=ft&web=1", + "BUY_NOW_PATH": "www.adobe.com/will/not/be/localized.html", + "LOCALE": "", + }, ], }; @@ -707,6 +715,34 @@ describe('Merch Block', () => { expect(action).to.be.undefined; }); + it('getModalAction: localize buy now path if it comes from us/en production', async () => { + setConfig({ + ...config, + pathname: '/fr/test.html', + locales: { fr: { ietf: 'fr-FR' } }, + prodDomains: PROD_DOMAINS, + placeholders: { download: 'Télécharger' }, + }); + fetchCheckoutLinkConfigs.promise = undefined; + setCheckoutLinkConfigs(CHECKOUT_LINK_CONFIGS); + const action = await getModalAction([{ productArrangement: { productFamily: 'ILLUSTRATOR' } }], { modal: true }); + expect(action.url).to.equal('https://www.adobe.com/fr/plans-fragments/modals/individual/modals-content-rich/illustrator/master.modal.html') + }); + + it('getModalAction: skip modal url localization if url is invalid', async () => { + setConfig({ + ...config, + pathname: '/fr/test.html', + locales: { fr: { ietf: 'fr-FR' } }, + prodDomains: PROD_DOMAINS, + placeholders: { download: 'Télécharger' }, + }); + fetchCheckoutLinkConfigs.promise = undefined; + setCheckoutLinkConfigs(CHECKOUT_LINK_CONFIGS); + const action = await getModalAction([{ productArrangement: { productFamily: 'AUDITION' } }], { modal: true }); + expect(action.url).to.equal('www.adobe.com/will/not/be/localized.html') + }); + it('getModalAction: returns undefined if checkout-link config is not found', async () => { fetchCheckoutLinkConfigs.promise = undefined; setCheckoutLinkConfigs(CHECKOUT_LINK_CONFIGS); From e4c049920f0a39bef1a52ab6bffc35a8ea7a3253 Mon Sep 17 00:00:00 2001 From: Bozo Jovicic Date: Thu, 28 Nov 2024 12:57:26 +0100 Subject: [PATCH 2/4] MWPW-157864 [Catalog] Localise external modals --- libs/blocks/merch/merch.js | 2 +- test/blocks/merch/merch.test.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index a4c1af6a63..220a8d0a0e 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -518,7 +518,7 @@ const isProdModal = (url) => { } catch (e) { return false; } -} +}; export async function getModalAction(offers, options, el) { const [{ diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index 660e83201c..98bff656a4 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -77,12 +77,12 @@ const CHECKOUT_LINK_CONFIGS = { DOWNLOAD_TEXT: 'productCode', }, { - "PRODUCT_FAMILY": "AUDITION", - "DOWNLOAD_TEXT": "Download", - "DOWNLOAD_URL": "https://creativecloud.adobe.com/apps/download/audition", - "FREE_TRIAL_PATH": "https://www.adobe.com/mini-plans/audition.html?mid=ft&web=1", - "BUY_NOW_PATH": "www.adobe.com/will/not/be/localized.html", - "LOCALE": "", + PRODUCT_FAMILY: 'AUDITION', + DOWNLOAD_TEXT: 'Download', + DOWNLOAD_URL: 'https://creativecloud.adobe.com/apps/download/audition', + FREE_TRIAL_PATH: 'https://www.adobe.com/mini-plans/audition.html?mid=ft&web=1', + BUY_NOW_PATH: 'www.adobe.com/will/not/be/localized.html', + LOCALE: '', }, ], }; @@ -726,7 +726,7 @@ describe('Merch Block', () => { fetchCheckoutLinkConfigs.promise = undefined; setCheckoutLinkConfigs(CHECKOUT_LINK_CONFIGS); const action = await getModalAction([{ productArrangement: { productFamily: 'ILLUSTRATOR' } }], { modal: true }); - expect(action.url).to.equal('https://www.adobe.com/fr/plans-fragments/modals/individual/modals-content-rich/illustrator/master.modal.html') + expect(action.url).to.equal('https://www.adobe.com/fr/plans-fragments/modals/individual/modals-content-rich/illustrator/master.modal.html'); }); it('getModalAction: skip modal url localization if url is invalid', async () => { @@ -740,7 +740,7 @@ describe('Merch Block', () => { fetchCheckoutLinkConfigs.promise = undefined; setCheckoutLinkConfigs(CHECKOUT_LINK_CONFIGS); const action = await getModalAction([{ productArrangement: { productFamily: 'AUDITION' } }], { modal: true }); - expect(action.url).to.equal('www.adobe.com/will/not/be/localized.html') + expect(action.url).to.equal('www.adobe.com/will/not/be/localized.html'); }); it('getModalAction: returns undefined if checkout-link config is not found', async () => { From 08c6f97b2dd262935df2c97d56fadc6598a3849e Mon Sep 17 00:00:00 2001 From: Bozo Jovicic Date: Thu, 5 Dec 2024 13:52:47 +0100 Subject: [PATCH 3/4] MWPW-157864 [Catalog] Localise external modals --- libs/blocks/merch/merch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index 220a8d0a0e..744e1825a9 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -514,7 +514,7 @@ export function setCtaHash(el, checkoutLinkConfig, offerType) { const isProdModal = (url) => { try { - return (new URL(url)).hostname.endsWith('adobe.com'); + return (new URL(url)).hostname.endsWith('.adobe.com'); } catch (e) { return false; } From 849aa1518294955329ce08d8be1592faf8bc668c Mon Sep 17 00:00:00 2001 From: Bozo Jovicic Date: Mon, 9 Dec 2024 11:15:27 +0100 Subject: [PATCH 4/4] Trigger Build