From ddd099935f220ddbed075e91d2c19f18bdc3ce1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20St=C3=A9phane=20T=C3=BCrkben?= Date: Thu, 15 Feb 2024 11:03:36 +0100 Subject: [PATCH 1/7] MWPW-142130: update the source of merch card name --- libs/blocks/merch-card/merch-card.js | 106 +----------------- libs/blocks/merch-cards/merch-cards.js | 24 ++-- libs/blocks/merch/merch.js | 4 +- libs/deps/merch-card.js | 2 +- test/blocks/merch-card/merch-card.test.js | 1 + test/blocks/merch-card/mocks/catalog.html | 1 + .../blocks/merch-cards/mocks/merch-cards.html | 11 +- 7 files changed, 29 insertions(+), 120 deletions(-) diff --git a/libs/blocks/merch-card/merch-card.js b/libs/blocks/merch-card/merch-card.js index e4baa646fa..133b4b33d2 100644 --- a/libs/blocks/merch-card/merch-card.js +++ b/libs/blocks/merch-card/merch-card.js @@ -5,102 +5,6 @@ import { processTrackingLabels } from '../../martech/attributes.js'; import { replaceKey } from '../../features/placeholders.js'; import '../../deps/merch-card.js'; -const PRODUCT_NAMES = [ - 'acrobat-pdf-pack', - 'acrobat-pro-2020', - 'acrobat-reader-dc-mobile', - 'acrobat-reader-dc', - 'acrobat-sign-solutions-mobile', - 'acrobat-sign-solutions', - 'acrobat-standard-2020', - 'acrobat-standard-dc', - 'acrobat', - 'adobe-connect', - 'adobe-export-pdf', - 'adobe-firefly', - 'adobe-scan', - 'advertising-cloud', - 'aero', - 'aftereffects', - 'analytics', - 'animate', - 'audience-manager', - 'audition', - 'behance', - 'bridge', - 'campaign', - 'captivate-prime', - 'captivate', - 'capture', - 'all-apps', - 'express', - 'character-animator', - 'cloud-service', - 'coldfusion-aws', - 'coldfusion-builder', - 'coldfusion-enterprise', - 'coldfusion', - 'color', - 'commerce-cloud', - 'content-server', - 'customer-journey-analytics', - 'design-to-print', - 'digital-editions', - 'dreamweaver', - 'embedded-print-engine', - 'experience-manager-assets', - 'experience-manager-forms', - 'experience-manager-sites', - 'experience-manager', - 'experience-platform', - 'fill-sign', - 'fonts', - 'frame', - 'framemaker-publishing-server', - 'framemaker', - 'fresco', - 'http-dynamic-streaming', - 'illustrator', - 'incopy', - 'indesign-server', - 'indesign', - 'intelligent-services', - 'journey-orchestration', - 'lightroom-classic', - 'lightroom', - 'magento', - 'marketo', - 'media-encoder', - 'media-server-aws', - 'media-server-extended', - 'media-server-professional', - 'media-server-standard', - 'mixamo', - 'pdf-print-engine', - 'pepe', - 'photoshop-elements', - 'photoshop-express', - 'photoshop', - 'portfolio', - 'postscript', - 'premiere-elements', - 'premierepro', - 'presenter-video-express', - 'real-time-customer-data-platform', - 'robohelp-server', - 'robohelp', - 'stock', - 'substance-3d-designer', - 'substance-3d-modeler', - 'substance-3d-painter', - 'substance-3d-sampler', - 'substance-3d-stager', - 'target', - 'technical-communication-suite', - 'type', - 'xml-documentation', -]; - const TAG_PATTERN = /^[a-zA-Z0-9_-]+:[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-].*$/; const CARD_TYPES = ['segment', 'special-offers', 'plans', 'catalog', 'product', 'inline-heading', 'image', 'mini-compare-chart']; @@ -335,8 +239,6 @@ const setMiniCompareOfferSlot = (merchCard, offers) => { const init = async (el) => { const styles = [...el.classList]; - const lastClass = styles[styles.length - 1]; - const name = PRODUCT_NAMES.includes(lastClass) ? lastClass : undefined; const cardType = getPodType(styles) || 'product'; if (!styles.includes(cardType)) { styles.push(cardType); @@ -363,11 +265,13 @@ const init = async (el) => { if (el.dataset.removedManifestId) { merchCard.dataset.removedManifestId = el.dataset.removedManifestId; } - if (name) { - merchCard.setAttribute('name', name); - } let tags = {}; if (el.lastElementChild) { + const nameEl = el.lastElementChild.querySelector('h3, h4, h5, h6'); + if (nameEl) { + merchCard.setAttribute('name', nameEl.textContent?.trim()); + nameEl.remove(); + } tags = extractTags(el.lastElementChild); if (tags.categories?.length > 1 || tags.types?.length > 0) { // this div contains tags, remove it from further processing. diff --git a/libs/blocks/merch-cards/merch-cards.js b/libs/blocks/merch-cards/merch-cards.js index 8dcab92d92..f7995c1a8e 100644 --- a/libs/blocks/merch-cards/merch-cards.js +++ b/libs/blocks/merch-cards/merch-cards.js @@ -39,7 +39,7 @@ const fail = (el, err = '') => { }; /** - * Removes merch cards from the DOM if they are not meant to be displayed in this merch cards block. + * Removes merch cards from the DOM if they are not meant to be displayed for the given filter. * @param {*} merchCards merch-cards element */ export function filterMerchCards(merchCards, filtered) { @@ -113,8 +113,8 @@ async function initMerchCards(config, type, filtered, el, preferences) { const preference = preferences[key]; if (!preference) return; preference - .forEach(([cardTitle, cardSize], index) => { - if (merchCard.title === cardTitle) { + .forEach(([sortKey, cardSize], index) => { + if (merchCard.name === sortKey || merchCard.title === sortKey) { filters[key] = { order: index, size: cardSize }; } }); @@ -134,12 +134,12 @@ export default async function init(el) { return fail(el, 'Missing queryIndexCardPath config'); } - const { miloLibs } = getConfig(); + const { base } = getConfig(); const merchStyles = new Promise((resolve) => { - loadStyle(`${miloLibs}/blocks/merch/merch.css`, resolve); + loadStyle(`${base}/blocks/merch/merch.css`, resolve); }); const merchCardStyles = new Promise((resolve) => { - loadStyle(`${miloLibs}/blocks/merch-card/merch-card.css`, resolve); + loadStyle(`${base}/blocks/merch-card/merch-card.css`, resolve); }); const allStyles = Promise.all([merchStyles, merchCardStyles]); @@ -150,12 +150,12 @@ export default async function init(el) { if (!filtered) { await Promise.all([ - import(`${miloLibs}/features/spectrum-web-components/dist/theme.js`), - import(`${miloLibs}/features/spectrum-web-components/dist/button.js`), - import(`${miloLibs}/features/spectrum-web-components/dist/search.js`), - import(`${miloLibs}/features/spectrum-web-components/dist/overlay.js`), - import(`${miloLibs}/features/spectrum-web-components/dist/menu.js`), - import(`${miloLibs}/features/spectrum-web-components/dist/popover.js`), + import(`${base}/features/spectrum-web-components/dist/theme.js`), + import(`${base}/features/spectrum-web-components/dist/button.js`), + import(`${base}/features/spectrum-web-components/dist/search.js`), + import(`${base}/features/spectrum-web-components/dist/overlay.js`), + import(`${base}/features/spectrum-web-components/dist/menu.js`), + import(`${base}/features/spectrum-web-components/dist/popover.js`), ]); } diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index 5ba7c692a3..ff82630a43 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -165,7 +165,7 @@ export async function getUpgradeAction(options, imsSignedInPromise, productFamil return undefined; } -async function openModalExternalModal(url, getModal, offerType) { +async function openExternalModal(url, getModal, offerType) { const iframe = createTag('iframe', { src: url, frameborder: '0', @@ -187,7 +187,7 @@ export async function openModal(e, url, offerType) { e.preventDefault(); const { getModal } = await import('../modal/modal.js'); if (/^https?:/.test(url)) { - openModalExternalModal(url, getModal, offerType); + openExternalModal(url, getModal, offerType); } } diff --git a/libs/deps/merch-card.js b/libs/deps/merch-card.js index aeb79e4f1e..13c83e03ae 100644 --- a/libs/deps/merch-card.js +++ b/libs/deps/merch-card.js @@ -1059,7 +1059,7 @@ merch-card .footer-row-cell:nth-child(8) { > ${this.badgeText} - `}getContainer(){return this.closest('[class*="-merch-cards"]')??this.parentElement}get headingmMSlot(){return this.shadowRoot.querySelector('slot[name="heading-m"]').assignedElements()[0]}get footerSlot(){return this.shadowRoot.querySelector('slot[name="footer"]')?.assignedElements()[0]}get price(){return this.headingmMSlot?.querySelector('span[is="inline-price"]')}get checkoutLinks(){return[...this.footerSlot?.querySelectorAll('a[is="checkout-link"]')??[]]}get isMobileOrTablet(){return window.matchMedia("(max-width: 1024px)").matches}async toggleStockOffer({target:e}){if(!this.stockOfferOsis)return;let r=this.checkoutLinks;if(r.length!==0)for(let t of r){await t.onceSettled();let a=t.value?.[0]?.planType;if(!a)return;let o=this.stockOfferOsis[a];if(!o)return;let d=t.dataset.wcsOsi.split(",").filter(p=>p!==o);e.checked&&d.push(o),t.dataset.wcsOsi=d.join(",")}}toggleActionMenu(e){let r=e?.type==="mouseleave"?!0:void 0,t=this.shadowRoot.querySelector('slot[name="action-menu-content"]');t&&t.classList.toggle("hidden",r)}handleQuantitySelection(e){let r=this.checkoutLinks;for(let t of r)t.dataset.quantity=e.detail.option}get title(){return(this.variant==="special-offers"?this.querySelector('[slot="detail-m"]'):this.querySelector('[slot="heading-xs"]')).textContent.trim()}updateFilters(e){let r={...this.filters};Object.keys(r).forEach(t=>{if(e){r[t].order=Math.min(r[t].order,2);return}let a=r[t].order;a===1||isNaN(a)||(r[t].order=Number(a)+1)}),this.filters=r}includes(e){return this.textContent.match(new RegExp(e,"i"))!==null}render(){switch(this.variant){case"special-offers":return this.renderSpecialOffer();case"segment":return this.renderSegment();case"plans":return this.renderPlans();case"catalog":return this.renderCatalog();case"image":return this.renderImage();case"product":return this.renderProduct();case"inline-heading":return this.renderInlineHeading();case A:return this.renderMiniCompareChart();default:return this.renderProduct()}}renderSpecialOffer(){return n`${this.cardImage} + `}getContainer(){return this.closest('[class*="-merch-cards"]')??this.parentElement}get headingmMSlot(){return this.shadowRoot.querySelector('slot[name="heading-m"]').assignedElements()[0]}get footerSlot(){return this.shadowRoot.querySelector('slot[name="footer"]')?.assignedElements()[0]}get price(){return this.headingmMSlot?.querySelector('span[is="inline-price"]')}get checkoutLinks(){return[...this.footerSlot?.querySelectorAll('a[is="checkout-link"]')??[]]}get isMobileOrTablet(){return window.matchMedia("(max-width: 1024px)").matches}async toggleStockOffer({target:e}){if(!this.stockOfferOsis)return;let r=this.checkoutLinks;if(r.length!==0)for(let t of r){await t.onceSettled();let a=t.value?.[0]?.planType;if(!a)return;let o=this.stockOfferOsis[a];if(!o)return;let d=t.dataset.wcsOsi.split(",").filter(p=>p!==o);e.checked&&d.push(o),t.dataset.wcsOsi=d.join(",")}}toggleActionMenu(e){let r=e?.type==="mouseleave"?!0:void 0,t=this.shadowRoot.querySelector('slot[name="action-menu-content"]');t&&t.classList.toggle("hidden",r)}handleQuantitySelection(e){let r=this.checkoutLinks;for(let t of r)t.dataset.quantity=e.detail.option}get title(){return(this.variant==="special-offers"?this.querySelector('[slot="detail-m"]'):this.querySelector('[slot="heading-xs"]'))?.textContent?.trim()}updateFilters(e){let r={...this.filters};Object.keys(r).forEach(t=>{if(e){r[t].order=Math.min(r[t].order,2);return}let a=r[t].order;a===1||isNaN(a)||(r[t].order=Number(a)+1)}),this.filters=r}includes(e){return this.textContent.match(new RegExp(e,"i"))!==null}render(){switch(this.variant){case"special-offers":return this.renderSpecialOffer();case"segment":return this.renderSegment();case"plans":return this.renderPlans();case"catalog":return this.renderCatalog();case"image":return this.renderImage();case"product":return this.renderProduct();case"inline-heading":return this.renderInlineHeading();case A:return this.renderMiniCompareChart();default:return this.renderProduct()}}renderSpecialOffer(){return n`${this.cardImage}
diff --git a/test/blocks/merch-card/merch-card.test.js b/test/blocks/merch-card/merch-card.test.js index 32fab5333b..275b791935 100644 --- a/test/blocks/merch-card/merch-card.test.js +++ b/test/blocks/merch-card/merch-card.test.js @@ -258,6 +258,7 @@ describe('Catalog Card', () => { it('Parses the filters and types', async () => { document.body.innerHTML = await readFile({ path: './mocks/catalog.html' }); const merchCard = await init(document.querySelector('.merch-card.catalog.tags')); + expect(merchCard.name).equal('photoshop'); expect(merchCard.filters).to.be.deep.equal({ all: { order: undefined, size: undefined }, 'creativity-design': { order: undefined, size: undefined }, diff --git a/test/blocks/merch-card/mocks/catalog.html b/test/blocks/merch-card/mocks/catalog.html index 3dc6820f12..b3387652a1 100644 --- a/test/blocks/merch-card/mocks/catalog.html +++ b/test/blocks/merch-card/mocks/catalog.html @@ -125,6 +125,7 @@
Desktop + Mobile
+

photoshop

catalog:categories/creativity-design

catalog:categories/creativity-design/graphic-design

catalog:categories/creativity-design/photo

diff --git a/test/blocks/merch-cards/mocks/merch-cards.html b/test/blocks/merch-cards/mocks/merch-cards.html index be5501a9d8..ab28b4a0d5 100644 --- a/test/blocks/merch-cards/mocks/merch-cards.html +++ b/test/blocks/merch-cards/mocks/merch-cards.html @@ -31,7 +31,7 @@

Photoshop

-

Creative Cloud All Apps

+

all-apps

Express

@@ -132,27 +132,30 @@
-
+

Adobe Express

+

express

catalog:categories/creativity-design/photo

-
+

Photoshop

+

photoshop

catalog:categories/creativity-design/photo

-
+

Creative Cloud All Apps

+

all-apps

catalog:categories/creativity-design/photo

catalog:categories/creativity-design/video

From 3e1978c001d1b0ea2346c7e5ba92e0af67df9523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20St=C3=A9phane=20T=C3=BCrkben?= Date: Thu, 15 Feb 2024 13:41:03 +0100 Subject: [PATCH 2/7] fix single_app order --- libs/blocks/merch-cards/merch-cards.js | 2 +- libs/deps/merch-card.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/blocks/merch-cards/merch-cards.js b/libs/blocks/merch-cards/merch-cards.js index f7995c1a8e..9c82703bcd 100644 --- a/libs/blocks/merch-cards/merch-cards.js +++ b/libs/blocks/merch-cards/merch-cards.js @@ -115,7 +115,7 @@ async function initMerchCards(config, type, filtered, el, preferences) { preference .forEach(([sortKey, cardSize], index) => { if (merchCard.name === sortKey || merchCard.title === sortKey) { - filters[key] = { order: index, size: cardSize }; + filters[key] = { order: index + 1, size: cardSize }; } }); }); diff --git a/libs/deps/merch-card.js b/libs/deps/merch-card.js index 13c83e03ae..835e92bd19 100644 --- a/libs/deps/merch-card.js +++ b/libs/deps/merch-card.js @@ -1059,7 +1059,7 @@ merch-card .footer-row-cell:nth-child(8) { > ${this.badgeText}
- `}getContainer(){return this.closest('[class*="-merch-cards"]')??this.parentElement}get headingmMSlot(){return this.shadowRoot.querySelector('slot[name="heading-m"]').assignedElements()[0]}get footerSlot(){return this.shadowRoot.querySelector('slot[name="footer"]')?.assignedElements()[0]}get price(){return this.headingmMSlot?.querySelector('span[is="inline-price"]')}get checkoutLinks(){return[...this.footerSlot?.querySelectorAll('a[is="checkout-link"]')??[]]}get isMobileOrTablet(){return window.matchMedia("(max-width: 1024px)").matches}async toggleStockOffer({target:e}){if(!this.stockOfferOsis)return;let r=this.checkoutLinks;if(r.length!==0)for(let t of r){await t.onceSettled();let a=t.value?.[0]?.planType;if(!a)return;let o=this.stockOfferOsis[a];if(!o)return;let d=t.dataset.wcsOsi.split(",").filter(p=>p!==o);e.checked&&d.push(o),t.dataset.wcsOsi=d.join(",")}}toggleActionMenu(e){let r=e?.type==="mouseleave"?!0:void 0,t=this.shadowRoot.querySelector('slot[name="action-menu-content"]');t&&t.classList.toggle("hidden",r)}handleQuantitySelection(e){let r=this.checkoutLinks;for(let t of r)t.dataset.quantity=e.detail.option}get title(){return(this.variant==="special-offers"?this.querySelector('[slot="detail-m"]'):this.querySelector('[slot="heading-xs"]'))?.textContent?.trim()}updateFilters(e){let r={...this.filters};Object.keys(r).forEach(t=>{if(e){r[t].order=Math.min(r[t].order,2);return}let a=r[t].order;a===1||isNaN(a)||(r[t].order=Number(a)+1)}),this.filters=r}includes(e){return this.textContent.match(new RegExp(e,"i"))!==null}render(){switch(this.variant){case"special-offers":return this.renderSpecialOffer();case"segment":return this.renderSegment();case"plans":return this.renderPlans();case"catalog":return this.renderCatalog();case"image":return this.renderImage();case"product":return this.renderProduct();case"inline-heading":return this.renderInlineHeading();case A:return this.renderMiniCompareChart();default:return this.renderProduct()}}renderSpecialOffer(){return n`${this.cardImage} + `}getContainer(){return this.closest('[class*="-merch-cards"]')??this.parentElement}get headingmMSlot(){return this.shadowRoot.querySelector('slot[name="heading-m"]').assignedElements()[0]}get footerSlot(){return this.shadowRoot.querySelector('slot[name="footer"]')?.assignedElements()[0]}get price(){return this.headingmMSlot?.querySelector('span[is="inline-price"]')}get checkoutLinks(){return[...this.footerSlot?.querySelectorAll('a[is="checkout-link"]')??[]]}get isMobileOrTablet(){return window.matchMedia("(max-width: 1024px)").matches}async toggleStockOffer({target:e}){if(!this.stockOfferOsis)return;let r=this.checkoutLinks;if(r.length!==0)for(let t of r){await t.onceSettled();let a=t.value?.[0]?.planType;if(!a)return;let o=this.stockOfferOsis[a];if(!o)return;let d=t.dataset.wcsOsi.split(",").filter(p=>p!==o);e.checked&&d.push(o),t.dataset.wcsOsi=d.join(",")}}toggleActionMenu(e){let r=e?.type==="mouseleave"?!0:void 0,t=this.shadowRoot.querySelector('slot[name="action-menu-content"]');t&&t.classList.toggle("hidden",r)}handleQuantitySelection(e){let r=this.checkoutLinks;for(let t of r)t.dataset.quantity=e.detail.option}get title(){return(this.variant==="special-offers"?this.querySelector('[slot="detail-m"]'):this.querySelector('[slot="heading-xs"]'))?.textContent?.trim()}updateFilters(e){let r={...this.filters};Object.keys(r).forEach(t=>{if(e){r[t].order=Math.min(r[t].order||2,2);return}let a=r[t].order;a===1||isNaN(a)||(r[t].order=Number(a)+1)}),this.filters=r}includes(e){return this.textContent.match(new RegExp(e,"i"))!==null}render(){switch(this.variant){case"special-offers":return this.renderSpecialOffer();case"segment":return this.renderSegment();case"plans":return this.renderPlans();case"catalog":return this.renderCatalog();case"image":return this.renderImage();case"product":return this.renderProduct();case"inline-heading":return this.renderInlineHeading();case A:return this.renderMiniCompareChart();default:return this.renderProduct()}}renderSpecialOffer(){return n`${this.cardImage}
From ad84e8642b3402dbc804e7df0f84f04dea4e8cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20St=C3=A9phane=20T=C3=BCrkben?= Date: Thu, 15 Feb 2024 15:20:27 +0100 Subject: [PATCH 3/7] fix failing tests --- libs/blocks/merch-card/merch-card.js | 6 ++++-- test/blocks/merch-card/merch-card.test.js | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/blocks/merch-card/merch-card.js b/libs/blocks/merch-card/merch-card.js index 133b4b33d2..691c5ba49b 100644 --- a/libs/blocks/merch-card/merch-card.js +++ b/libs/blocks/merch-card/merch-card.js @@ -266,8 +266,10 @@ const init = async (el) => { merchCard.dataset.removedManifestId = el.dataset.removedManifestId; } let tags = {}; - if (el.lastElementChild) { - const nameEl = el.lastElementChild.querySelector('h3, h4, h5, h6'); + if (el.lastElementChild.previousElementSibling?.querySelector('h2,h3,h4,h5,h6')) { + // tag section is available + const nameSelector = 'h3,h4,h5,h6'; + const nameEl = el.lastElementChild.querySelector(nameSelector); if (nameEl) { merchCard.setAttribute('name', nameEl.textContent?.trim()); nameEl.remove(); diff --git a/test/blocks/merch-card/merch-card.test.js b/test/blocks/merch-card/merch-card.test.js index 275b791935..132145a6a5 100644 --- a/test/blocks/merch-card/merch-card.test.js +++ b/test/blocks/merch-card/merch-card.test.js @@ -370,7 +370,8 @@ describe('Merch Card with Offer Selection', () => { const items = quantitySelect.shadowRoot.querySelectorAll('.item'); items[2].click(); const button = merchCard.querySelector('.con-button'); - expect(button.getAttribute('data-quantity')).to.equal('3'); + // TODO to be confirm with Vova. + expect(button.getAttribute('data-quantity')).to.equal('1'); }); it('Skip Change quantity select render ', async () => { From 9c70b15d9a6a18f8e86ef1bc1ff7c832bef4890a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20St=C3=A9phane=20T=C3=BCrkben?= Date: Thu, 15 Feb 2024 11:03:36 +0100 Subject: [PATCH 4/7] MWPW-142130: update the source of merch card name --- libs/deps/merch-card.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/deps/merch-card.js b/libs/deps/merch-card.js index 835e92bd19..304f075aad 100644 --- a/libs/deps/merch-card.js +++ b/libs/deps/merch-card.js @@ -1,4 +1,4 @@ -// Tue, 13 Feb 2024 15:45:03 GMT +// Thu, 15 Feb 2024 19:36:43 GMT import{html as n,LitElement as T}from"/libs/deps/lit-all.min.js";import{css as x,unsafeCSS as f}from"/libs/deps/lit-all.min.js";var l="(max-width: 767px)";var i="(min-width: 768px)",c="(min-width: 1200px)",s="(min-width: 1600px)";var y=x` :host { position: relative; From 5e72ce43411d32db4a5e634f693fa6bcac961ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20St=C3=A9phane=20T=C3=BCrkben?= Date: Thu, 15 Feb 2024 20:58:23 +0100 Subject: [PATCH 5/7] MWPW-142130: update deps and fix test --- test/blocks/merch-card/merch-card.test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/blocks/merch-card/merch-card.test.js b/test/blocks/merch-card/merch-card.test.js index 132145a6a5..275b791935 100644 --- a/test/blocks/merch-card/merch-card.test.js +++ b/test/blocks/merch-card/merch-card.test.js @@ -370,8 +370,7 @@ describe('Merch Card with Offer Selection', () => { const items = quantitySelect.shadowRoot.querySelectorAll('.item'); items[2].click(); const button = merchCard.querySelector('.con-button'); - // TODO to be confirm with Vova. - expect(button.getAttribute('data-quantity')).to.equal('1'); + expect(button.getAttribute('data-quantity')).to.equal('3'); }); it('Skip Change quantity select render ', async () => { From 12e0e3c703b31dec2f1e90f81326b2dea5b40893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20St=C3=A9phane=20T=C3=BCrkben?= Date: Thu, 15 Feb 2024 21:11:08 +0100 Subject: [PATCH 6/7] npe check --- libs/blocks/merch-card/merch-card.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/blocks/merch-card/merch-card.js b/libs/blocks/merch-card/merch-card.js index 691c5ba49b..562af4453c 100644 --- a/libs/blocks/merch-card/merch-card.js +++ b/libs/blocks/merch-card/merch-card.js @@ -266,7 +266,7 @@ const init = async (el) => { merchCard.dataset.removedManifestId = el.dataset.removedManifestId; } let tags = {}; - if (el.lastElementChild.previousElementSibling?.querySelector('h2,h3,h4,h5,h6')) { + if (el.lastElementChild?.previousElementSibling?.querySelector('h3,h3,h4,h5,h6')) { // tag section is available const nameSelector = 'h3,h4,h5,h6'; const nameEl = el.lastElementChild.querySelector(nameSelector); From 35a18c658cd23828d2a1f7dfff95e74c0488e13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilyas=20St=C3=A9phane=20T=C3=BCrkben?= Date: Fri, 16 Feb 2024 11:00:09 +0100 Subject: [PATCH 7/7] revert name change. to be addressed in a diff PR --- libs/blocks/merch/merch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/blocks/merch/merch.js b/libs/blocks/merch/merch.js index ff82630a43..5ba7c692a3 100644 --- a/libs/blocks/merch/merch.js +++ b/libs/blocks/merch/merch.js @@ -165,7 +165,7 @@ export async function getUpgradeAction(options, imsSignedInPromise, productFamil return undefined; } -async function openExternalModal(url, getModal, offerType) { +async function openModalExternalModal(url, getModal, offerType) { const iframe = createTag('iframe', { src: url, frameborder: '0', @@ -187,7 +187,7 @@ export async function openModal(e, url, offerType) { e.preventDefault(); const { getModal } = await import('../modal/modal.js'); if (/^https?:/.test(url)) { - openExternalModal(url, getModal, offerType); + openModalExternalModal(url, getModal, offerType); } }