diff --git a/libs/blocks/merch/merch.css b/libs/blocks/merch/merch.css index b129034c6db..ede2d35e176 100644 --- a/libs/blocks/merch/merch.css +++ b/libs/blocks/merch/merch.css @@ -7,7 +7,9 @@ span[data-wcs-osi] { display: inline-block; } -span.placeholder-resolved[data-template="strikethrough"], span.price.price-strikethrough { +span.placeholder-resolved[data-template="strikethrough"], +span.price.price-strikethrough, +span.price.price-promo-strikethrough { text-decoration: line-through; } diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index 9285adc92d9..7e6d270789c 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -22,6 +22,7 @@ export const PRICE_TEMPLATE_DISCOUNT = 'discount'; export const PRICE_TEMPLATE_OPTICAL = 'optical'; export const PRICE_TEMPLATE_REGULAR = 'price'; export const PRICE_TEMPLATE_STRIKETHROUGH = 'strikethrough'; +export const PRICE_TEMPLATE_PROMO_STRIKETHROUGH = 'promo-strikethrough'; export const PRICE_TEMPLATE_ANNUAL = 'annual'; export const PRICE_TEMPLATE_LEGAL = 'legal'; @@ -35,6 +36,7 @@ const PRICE_TEMPLATE_MAPPING = new Map([ ['priceAnnual', PRICE_TEMPLATE_ANNUAL], [PRICE_TEMPLATE_ANNUAL, PRICE_TEMPLATE_ANNUAL], [PRICE_TEMPLATE_LEGAL, PRICE_TEMPLATE_LEGAL], + [PRICE_TEMPLATE_PROMO_STRIKETHROUGH, PRICE_TEMPLATE_PROMO_STRIKETHROUGH], ]); export const PLACEHOLDER_KEY_DOWNLOAD = 'download'; diff --git a/libs/blocks/ost/ost.js b/libs/blocks/ost/ost.js index 9121fdc29f6..b120b1379d8 100644 --- a/libs/blocks/ost/ost.js +++ b/libs/blocks/ost/ost.js @@ -8,8 +8,8 @@ const IMS_COMMERCE_CLIENT_ID = 'aos_milo_commerce'; const IMS_SCOPE = 'AdobeID,openid'; const IMS_ENV = 'prod'; const IMS_PROD_URL = 'https://auth.services.adobe.com/imslib/imslib.min.js'; -const OST_SCRIPT_URL = 'https://mas.adobe.com/studio/ost/index.js'; -const OST_STYLE_URL = 'https://mas.adobe.com/studio/ost/index.css'; +const OST_SCRIPT_URL = '/studio/ost/index.js'; +const OST_STYLE_URL = '/studio/ost/index.css'; /** @see https://git.corp.adobe.com/PandoraUI/core/blob/master/packages/react-env-provider/src/component.tsx#L49 */ export const WCS_ENV = 'PROD'; export const WCS_API_KEY = 'wcms-commerce-ims-ro-user-cc'; @@ -39,6 +39,38 @@ const updateParams = (params, key, value) => { document.body.classList.add('tool', 'tool-ost'); +/** + * Gets the base URL for loading Tacocat OST build file based on maslibs parameter + * @returns {string} Base URL for OST index.js + */ +export function getMasLibsBase(windowObj) { + const urlParams = new URLSearchParams(windowObj.location.search); + const masLibs = urlParams.get('maslibs'); + + if (!masLibs || masLibs.trim() === '') return 'https://mas.adobe.com'; + + const sanitizedMasLibs = masLibs.trim().toLowerCase(); + + if (sanitizedMasLibs === 'local') { + return 'http://localhost:3030'; + } + if (sanitizedMasLibs === 'main') { + return 'https://mas.adobe.com'; + } + + // Detect current domain extension (.page or .live) + const { hostname } = windowObj.location; + const extension = hostname.endsWith('.page') ? 'page' : 'live'; + + if (sanitizedMasLibs.includes('--mas--')) { + return `https://${sanitizedMasLibs}.aem.${extension}`; + } + if (sanitizedMasLibs.includes('--')) { + return `https://${sanitizedMasLibs}.aem.${extension}`; + } + return `https://${sanitizedMasLibs}--mas--adobecom.aem.${extension}`; +} + /** * @param {Commerce.Defaults} defaults */ @@ -268,12 +300,12 @@ export async function loadOstEnv() { export default async function init(el) { el.innerHTML = '
'; - loadStyle(OST_STYLE_URL); + loadStyle(`${getMasLibsBase(window)}${OST_STYLE_URL}`); loadStyle('https://use.typekit.net/pps7abe.css'); const [ostEnv] = await Promise.all([ loadOstEnv(), - loadScript(OST_SCRIPT_URL), + loadScript(`${getMasLibsBase(window)}${OST_SCRIPT_URL}`), ]); function openOst() { diff --git a/test/blocks/ost/ost.test.html.js b/test/blocks/ost/ost.test.html.js index cfe743f9d81..cf5f487b029 100644 --- a/test/blocks/ost/ost.test.html.js +++ b/test/blocks/ost/ost.test.html.js @@ -1,7 +1,7 @@ import { expect } from '@esm-bundle/chai'; import { mockOstDeps, unmockOstDeps } from './mocks/ost-utils.js'; -import { DEFAULT_CTA_TEXT, createLinkMarkup } from '../../../libs/blocks/ost/ost.js'; +import { DEFAULT_CTA_TEXT, createLinkMarkup, getMasLibsBase } from '../../../libs/blocks/ost/ost.js'; const perpM2M = { offer_id: 'aeb0bf53517d46e89a1b039f859cf573', @@ -306,3 +306,28 @@ describe('OST: merch link creation', () => { }); }); }); +describe('OST: getMasLibsBase', () => { + it('test different mas libs bases', () => { + const windowObj = { + location: { + search: '?maslibs=TEST', + hostname: 'main--milo--adobecom.aem.page', + }, + }; + expect(getMasLibsBase(windowObj)).to.equal('https://test--mas--adobecom.aem.page'); + windowObj.location.search = null; + expect(getMasLibsBase(windowObj)).to.equal('https://mas.adobe.com'); + windowObj.location.search = '?maslibs=local'; + expect(getMasLibsBase(windowObj)).to.equal('http://localhost:3030'); + windowObj.location.search = '?maslibs=main'; + expect(getMasLibsBase(windowObj)).to.equal('https://mas.adobe.com'); + windowObj.location.search = '?maslibs=TEST--mas--adobecom'; + expect(getMasLibsBase(windowObj)).to.equal('https://test--mas--adobecom.aem.page'); + windowObj.location.search = '?maslibs=TEST--sam--adobecom'; + expect(getMasLibsBase(windowObj)).to.equal('https://test--sam--adobecom.aem.page'); + windowObj.location.search = '?maslibs=TEST--mas--user1'; + expect(getMasLibsBase(windowObj)).to.equal('https://test--mas--user1.aem.page'); + windowObj.location.search = '?maslibs=TEST--sam--user1'; + expect(getMasLibsBase(windowObj)).to.equal('https://test--sam--user1.aem.page'); + }); +});