From dbf15b0a137b0b86d2f8502732a6292b30065fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Mon, 8 Jul 2024 17:05:19 +0200 Subject: [PATCH 01/14] MWPW-153962: Introduce maslibs query parameter Similar to milolibs query parameter, when present, it will load commerce.js from the external M@S repository. --- head.html | 2 +- libs/blocks/merch/merch.js | 41 ++++++++++++++++++++++++++++++--- test/blocks/merch/merch.test.js | 36 +++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/head.html b/head.html index 3bead19732..0b7209238b 100644 --- a/head.html +++ b/head.html @@ -1,4 +1,4 @@ - + diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index 8cce3dfed0..af34832d13 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -122,6 +122,34 @@ const LOADING_ENTITLEMENTS = 'loading-entitlements'; let log; let upgradeOffer = null; +/** + * Given a url, calculates the hostname of MAS platform. + * Supports, www prod, stage, local and feature branches. + * @param {string} hostname + * @param {string} maslibs + * @returns base hostname for mas platform + */ +export function getMasBase(hostname, maslibs) { + let { baseUrl } = getMasBase; + if (baseUrl) return baseUrl; + baseUrl = 'https://www.adobe.com/mas'; + if (!maslibs) return baseUrl; + if (maslibs === 'stage') { + baseUrl = 'https://www.stage.adobe.com/mas'; + } else if (maslibs === 'local') { + baseUrl = 'http://localhost:8000'; + } else { + const extension = /.live$/.test(hostname) ? 'live' : 'page'; + if (/--/.test(maslibs)) { + baseUrl = `https://${maslibs}.hlx.${extension}`; + } else { + baseUrl = `https://${maslibs}--mas--adobecom.hlx.${extension}`; + } + } + getMasBase.baseUrl = baseUrl; + return baseUrl; +} + export async function polyfills() { if (polyfills.promise) return polyfills.promise; let isSupported = false; @@ -349,7 +377,13 @@ export async function initService(force = false) { const { env, commerce = {}, locale } = getConfig(); commerce.priceLiteralsPromise = fetchLiterals(PRICE_LITERALS_URL); initService.promise = initService.promise ?? polyfills().then(async () => { - const commerceLib = await import('../../deps/commerce.js'); + const { hostname, searchParams } = new URL(window.location.href); + const maslibs = searchParams.get('maslibs'); + let commerceLibPath = '../../deps/commerce.js'; + if (maslibs) { + commerceLibPath = `${getMasBase(hostname, maslibs)}/lib/commerce.js`; + } + const commerceLib = await import(commerceLibPath); const service = await commerceLib.init(() => ({ env, commerce, @@ -376,8 +410,9 @@ export async function getCommerceContext(el, params) { } /** - * Checkout parameter can be set Merch link, code config (scripts.js) or be a default from tacocat. - * To get the default, 'undefinded' should be passed, empty string will trigger an error! + * Checkout parameter can be set on the merch link, + * code config (scripts.js) or be a default from tacocat. + * To get the default, 'undefined' should be passed, empty string will trigger an error! * * clientId - code config -> default (adobe_com) * workflow - merch link -> metadata -> default (UCv3) diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index 991134d7c5..ee51dd4350 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -21,6 +21,7 @@ import merch, { getCheckoutAction, PRICE_LITERALS_URL, PRICE_TEMPLATE_REGULAR, + getMasBase, } from '../../../libs/blocks/merch/merch.js'; import { mockFetch, unmockFetch, readMockText } from './mocks/fetch.js'; @@ -668,4 +669,39 @@ describe('Merch Block', () => { }); }); }); + + describe.only('M@S consumption', () => { + describe('maslibs parameter', () => { + beforeEach(() => { + getMasBase.baseUrl = undefined; + }); + it('should return the default Adobe URL if no maslibs parameter is present', () => { + expect(getMasBase()).to.equal('https://www.adobe.com/mas'); + }); + + it('should return the stage Adobe URL if maslibs=stage', () => { + expect(getMasBase('https://www.adobe.com', 'stage')).to.equal('https://www.stage.adobe.com/mas'); + }); + + it('should return the local URL if maslibs=local', () => { + expect(getMasBase('https://www.adobe.com', 'local')).to.equal('http://localhost:8000'); + }); + + it('should return the adobecom hlx live URL if maslibs is branch name', () => { + expect(getMasBase('https://main--milo--adobecom-hlx.live', 'test')).to.equal('https://test--mas--adobecom.hlx.live'); + }); + + it('should return the hlx live URL from the fork if maslibs contains double dashes', () => { + expect(getMasBase('https://main--milo--adobecom-hlx.live', 'test--mas--user')).to.equal('https://test--mas--user.hlx.live'); + }); + + it('should return the adobecom hlx page URL if maslibs is branch name', () => { + expect(getMasBase('https://main--milo--adobecom-hlx.page', 'test')).to.equal('https://test--mas--adobecom.hlx.page'); + }); + + it('should return the hlx page URL from the fork if maslibs contains double dashes', () => { + expect(getMasBase('https://main--milo--adobecom-hlx.page', 'test--mas--user')).to.equal('https://test--mas--user.hlx.page'); + }); + }); + }); }); From 6e5d64f94f76d8d1b192adc7405a4378cef17db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Mon, 8 Jul 2024 17:14:18 +0200 Subject: [PATCH 02/14] update comment --- 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 af34832d13..1cc87afc35 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -127,7 +127,7 @@ let upgradeOffer = null; * Supports, www prod, stage, local and feature branches. * @param {string} hostname * @param {string} maslibs - * @returns base hostname for mas platform + * @returns base url for mas platform */ export function getMasBase(hostname, maslibs) { let { baseUrl } = getMasBase; From ee41ef36284687c0c0efe4d9c1cb85bd319670c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Mon, 8 Jul 2024 17:54:09 +0200 Subject: [PATCH 03/14] remove only --- test/blocks/merch/merch.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index ee51dd4350..a0232c3e44 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -670,7 +670,7 @@ describe('Merch Block', () => { }); }); - describe.only('M@S consumption', () => { + describe('M@S consumption', () => { describe('maslibs parameter', () => { beforeEach(() => { getMasBase.baseUrl = undefined; From 06733c0ad2a777e8b9bf1a41c353e27f592bca43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Mon, 8 Jul 2024 19:22:45 +0200 Subject: [PATCH 04/14] improve cov + fix promise issue --- libs/blocks/merch/merch.js | 17 +++++++----- test/blocks/merch/mas/lib/commerce.js | 4 +++ test/blocks/merch/merch.test.js | 39 ++++++++++++++++++++++++--- 3 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 test/blocks/merch/mas/lib/commerce.js diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index 1cc87afc35..2290c3f97f 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -354,15 +354,18 @@ export async function getModalAction(offers, options) { } export async function getCheckoutAction(offers, options, imsSignedInPromise) { - const [downloadAction, upgradeAction, modalAction] = await Promise.all([ - getDownloadAction(options, imsSignedInPromise, offers), - getUpgradeAction(options, imsSignedInPromise, offers), - getModalAction(offers, options), - ]).catch((e) => { + try { + await imsSignedInPromise; + const [downloadAction, upgradeAction, modalAction] = await Promise.all([ + getDownloadAction(options, imsSignedInPromise, offers), + getUpgradeAction(options, imsSignedInPromise, offers), + getModalAction(offers, options), + ]); + return downloadAction || upgradeAction || modalAction; + } catch (e) { log?.error('Failed to resolve checkout action', e); return []; - }); - return downloadAction || upgradeAction || modalAction; + } } /** diff --git a/test/blocks/merch/mas/lib/commerce.js b/test/blocks/merch/mas/lib/commerce.js new file mode 100644 index 0000000000..eb3940aee3 --- /dev/null +++ b/test/blocks/merch/mas/lib/commerce.js @@ -0,0 +1,4 @@ +const mock = true; +const init = () => ({ imsSignedInPromise: Promise.resolve(), mock }); +// eslint-disable-next-line import/prefer-default-export +export { init }; diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index a0232c3e44..c2f1a401c5 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -73,6 +73,16 @@ const config = { placeholders: { 'upgrade-now': 'Upgrade Now', download: 'Download' }, }; +const updateSearch = ({ maslibs } = {}) => { + const url = new URL(window.location); + if (!maslibs) { + url.searchParams.delete('maslibs'); + } else { + url.searchParams.set('maslibs', maslibs); + } + window.history.pushState({}, '', url); +}; + /** * utility function that tests Price spans against mock HTML * @@ -148,6 +158,7 @@ describe('Merch Block', () => { afterEach(() => { setSubscriptionsData(); + updateSearch(); }); it('does not decorate merch with bad content', async () => { @@ -532,12 +543,22 @@ describe('Merch Block', () => { }); it('getCheckoutAction: handles errors gracefully', async () => { - const action = await getCheckoutAction([{ productArrangement: {} }], {}, Promise.reject(new Error('error'))); - expect(action).to.be.undefined; + const imsSignedInPromise = new Promise((resolve, reject) => { + setTimeout(() => { + reject(new Error('error')); + }, 1); + }); + const action = await getCheckoutAction([{ productArrangement: {} }], {}, imsSignedInPromise); + expect(action).to.be.empty; }); }); describe('Upgrade Flow', () => { + beforeEach(() => { + getMasBase.baseUrl = undefined; + updateSearch({}); + }); + it('updates CTA text to Upgrade Now', async () => { mockIms(); getUserEntitlements(); @@ -670,11 +691,23 @@ describe('Merch Block', () => { }); }); - describe('M@S consumption', () => { + describe.skip('M@S consumption', () => { describe('maslibs parameter', () => { beforeEach(() => { getMasBase.baseUrl = undefined; + updateSearch({}); + }); + + it('should load commerce.js via maslibs', async () => { + initService.promise = undefined; + getMasBase.baseUrl = 'http://localhost:2000/test/blocks/merch/mas'; + updateSearch({ maslibs: 'test' }); + setConfig(config); + await mockIms(); + const commerce = await initService(true); + expect(commerce.mock).to.be.true; }); + it('should return the default Adobe URL if no maslibs parameter is present', () => { expect(getMasBase()).to.equal('https://www.adobe.com/mas'); }); From a2f0a033f37f44ce2adead40f59dd84060f37157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 09:44:16 +0200 Subject: [PATCH 05/14] retore tests --- test/blocks/merch/merch.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index c2f1a401c5..045c7f4f25 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -691,7 +691,7 @@ describe('Merch Block', () => { }); }); - describe.skip('M@S consumption', () => { + describe('M@S consumption', () => { describe('maslibs parameter', () => { beforeEach(() => { getMasBase.baseUrl = undefined; From b7656eb466abaece01fd9a95eeaf46143f790cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 10:34:26 +0200 Subject: [PATCH 06/14] revert change in head.html will raise a second PR only for this change --- head.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/head.html b/head.html index 0b7209238b..3bead19732 100644 --- a/head.html +++ b/head.html @@ -1,4 +1,4 @@ - + From 5230f70a68cb7004d345015cc1b067ecd3cc3b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 13:49:07 +0200 Subject: [PATCH 07/14] update port to avoid conflicts --- 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 2290c3f97f..416d399405 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -137,7 +137,7 @@ export function getMasBase(hostname, maslibs) { if (maslibs === 'stage') { baseUrl = 'https://www.stage.adobe.com/mas'; } else if (maslibs === 'local') { - baseUrl = 'http://localhost:8000'; + baseUrl = 'http://localhost:9001'; } else { const extension = /.live$/.test(hostname) ? 'live' : 'page'; if (/--/.test(maslibs)) { From 8e265fbe2558c68ade9046e94b12f946c339384b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 13:52:42 +0200 Subject: [PATCH 08/14] fix test --- test/blocks/merch/merch.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index 045c7f4f25..0ccf791df6 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -717,7 +717,7 @@ describe('Merch Block', () => { }); it('should return the local URL if maslibs=local', () => { - expect(getMasBase('https://www.adobe.com', 'local')).to.equal('http://localhost:8000'); + expect(getMasBase('https://www.adobe.com', 'local')).to.equal('http://localhost:9001'); }); it('should return the adobecom hlx live URL if maslibs is branch name', () => { From 0396a8a428a7ed115c62e30cea75d2f585fe34ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 14:33:07 +0200 Subject: [PATCH 09/14] update tests --- libs/blocks/merch/merch.js | 8 +++++--- test/blocks/merch/merch.test.js | 12 ++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index 416d399405..df38134bb9 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -381,10 +381,12 @@ export async function initService(force = false) { commerce.priceLiteralsPromise = fetchLiterals(PRICE_LITERALS_URL); initService.promise = initService.promise ?? polyfills().then(async () => { const { hostname, searchParams } = new URL(window.location.href); - const maslibs = searchParams.get('maslibs'); let commerceLibPath = '../../deps/commerce.js'; - if (maslibs) { - commerceLibPath = `${getMasBase(hostname, maslibs)}/lib/commerce.js`; + if (!/www\.adobe\.com$/.test(hostname)) { + const maslibs = searchParams.get('maslibs'); + if (maslibs) { + commerceLibPath = `${getMasBase(hostname, maslibs)}/lib/commerce.js`; + } } const commerceLib = await import(commerceLibPath); const service = await commerceLib.init(() => ({ diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index 0ccf791df6..4a7ce4796f 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -713,27 +713,27 @@ describe('Merch Block', () => { }); it('should return the stage Adobe URL if maslibs=stage', () => { - expect(getMasBase('https://www.adobe.com', 'stage')).to.equal('https://www.stage.adobe.com/mas'); + expect(getMasBase('https://main--milo--adobecom.hlx.live', 'stage')).to.equal('https://www.stage.adobe.com/mas'); }); it('should return the local URL if maslibs=local', () => { - expect(getMasBase('https://www.adobe.com', 'local')).to.equal('http://localhost:9001'); + expect(getMasBase('https://main--milo--adobecom.hlx.live', 'local')).to.equal('http://localhost:9001'); }); it('should return the adobecom hlx live URL if maslibs is branch name', () => { - expect(getMasBase('https://main--milo--adobecom-hlx.live', 'test')).to.equal('https://test--mas--adobecom.hlx.live'); + expect(getMasBase('https://main--milo--adobecom.hlx.live', 'test')).to.equal('https://test--mas--adobecom.hlx.live'); }); it('should return the hlx live URL from the fork if maslibs contains double dashes', () => { - expect(getMasBase('https://main--milo--adobecom-hlx.live', 'test--mas--user')).to.equal('https://test--mas--user.hlx.live'); + expect(getMasBase('https://main--milo--adobecom.hlx.live', 'test--mas--user')).to.equal('https://test--mas--user.hlx.live'); }); it('should return the adobecom hlx page URL if maslibs is branch name', () => { - expect(getMasBase('https://main--milo--adobecom-hlx.page', 'test')).to.equal('https://test--mas--adobecom.hlx.page'); + expect(getMasBase('https://main--milo--adobecom.hlx.page', 'test')).to.equal('https://test--mas--adobecom.hlx.page'); }); it('should return the hlx page URL from the fork if maslibs contains double dashes', () => { - expect(getMasBase('https://main--milo--adobecom-hlx.page', 'test--mas--user')).to.equal('https://test--mas--user.hlx.page'); + expect(getMasBase('https://main--milo--adobecom.hlx.page', 'test--mas--user')).to.equal('https://test--mas--user.hlx.page'); }); }); }); From 58d71c09164712d2892ce9e20e19dc3ccbe5a444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 14:56:31 +0200 Subject: [PATCH 10/14] restrict maslibs to lower envs + stage --- 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 df38134bb9..a37cb28f6e 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -382,7 +382,7 @@ export async function initService(force = false) { initService.promise = initService.promise ?? polyfills().then(async () => { const { hostname, searchParams } = new URL(window.location.href); let commerceLibPath = '../../deps/commerce.js'; - if (!/www\.adobe\.com$/.test(hostname)) { + if (/hlx\.(page|live)$|localhost$|www\.stage\.adobe\.com$/.test(hostname)) { const maslibs = searchParams.get('maslibs'); if (maslibs) { commerceLibPath = `${getMasBase(hostname, maslibs)}/lib/commerce.js`; From f6da6034d4c7223ef333641402fbc0fcaf0f33e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 15:11:04 +0200 Subject: [PATCH 11/14] restrict maslibs to lower envs + stage --- libs/blocks/merch/merch.js | 21 +++++++++------------ test/blocks/merch/merch.test.js | 8 -------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index a37cb28f6e..19e1cf5ab9 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -131,22 +131,19 @@ let upgradeOffer = null; */ export function getMasBase(hostname, maslibs) { let { baseUrl } = getMasBase; - if (baseUrl) return baseUrl; - baseUrl = 'https://www.adobe.com/mas'; - if (!maslibs) return baseUrl; - if (maslibs === 'stage') { - baseUrl = 'https://www.stage.adobe.com/mas'; - } else if (maslibs === 'local') { - baseUrl = 'http://localhost:9001'; - } else { - const extension = /.live$/.test(hostname) ? 'live' : 'page'; - if (/--/.test(maslibs)) { + if (!baseUrl) { + if (maslibs === 'stage') { + baseUrl = 'https://www.stage.adobe.com/mas'; + } else if (maslibs === 'local') { + baseUrl = 'http://localhost:9001'; + } else if (maslibs) { + const extension = /.page$/.test(hostname) ? 'page' : 'live'; baseUrl = `https://${maslibs}.hlx.${extension}`; } else { - baseUrl = `https://${maslibs}--mas--adobecom.hlx.${extension}`; + baseUrl = 'https://www.adobe.com/mas'; } + getMasBase.baseUrl = baseUrl; } - getMasBase.baseUrl = baseUrl; return baseUrl; } diff --git a/test/blocks/merch/merch.test.js b/test/blocks/merch/merch.test.js index 4a7ce4796f..1340d2d64b 100644 --- a/test/blocks/merch/merch.test.js +++ b/test/blocks/merch/merch.test.js @@ -720,18 +720,10 @@ describe('Merch Block', () => { expect(getMasBase('https://main--milo--adobecom.hlx.live', 'local')).to.equal('http://localhost:9001'); }); - it('should return the adobecom hlx live URL if maslibs is branch name', () => { - expect(getMasBase('https://main--milo--adobecom.hlx.live', 'test')).to.equal('https://test--mas--adobecom.hlx.live'); - }); - it('should return the hlx live URL from the fork if maslibs contains double dashes', () => { expect(getMasBase('https://main--milo--adobecom.hlx.live', 'test--mas--user')).to.equal('https://test--mas--user.hlx.live'); }); - it('should return the adobecom hlx page URL if maslibs is branch name', () => { - expect(getMasBase('https://main--milo--adobecom.hlx.page', 'test')).to.equal('https://test--mas--adobecom.hlx.page'); - }); - it('should return the hlx page URL from the fork if maslibs contains double dashes', () => { expect(getMasBase('https://main--milo--adobecom.hlx.page', 'test--mas--user')).to.equal('https://test--mas--user.hlx.page'); }); From 9f125838fe015d330c20185772f1d38112889484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 15:25:10 +0200 Subject: [PATCH 12/14] update /lib to /libs --- 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 19e1cf5ab9..f34055de8d 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -382,7 +382,7 @@ export async function initService(force = false) { if (/hlx\.(page|live)$|localhost$|www\.stage\.adobe\.com$/.test(hostname)) { const maslibs = searchParams.get('maslibs'); if (maslibs) { - commerceLibPath = `${getMasBase(hostname, maslibs)}/lib/commerce.js`; + commerceLibPath = `${getMasBase(hostname, maslibs)}/libs/commerce.js`; } } const commerceLib = await import(commerceLibPath); From 8d6dc0b4f45f91237b77b16f2550874e7e3e9cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 15:29:22 +0200 Subject: [PATCH 13/14] update /lib to /libs --- test/blocks/merch/mas/{lib => libs}/commerce.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/blocks/merch/mas/{lib => libs}/commerce.js (100%) diff --git a/test/blocks/merch/mas/lib/commerce.js b/test/blocks/merch/mas/libs/commerce.js similarity index 100% rename from test/blocks/merch/mas/lib/commerce.js rename to test/blocks/merch/mas/libs/commerce.js From 8492f903464bbe79afebec56d9f77bb3a45f2fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20T=C3=BCrkben?= Date: Tue, 9 Jul 2024 16:28:12 +0200 Subject: [PATCH 14/14] update comments --- libs/blocks/merch/merch.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index f34055de8d..58aa5afada 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -125,8 +125,9 @@ let upgradeOffer = null; /** * Given a url, calculates the hostname of MAS platform. * Supports, www prod, stage, local and feature branches. - * @param {string} hostname - * @param {string} maslibs + * if params are missing, it will return the latest calculated or default value. + * @param {string} hostname optional + * @param {string} maslibs optional * @returns base url for mas platform */ export function getMasBase(hostname, maslibs) {