From a234e2b61d3b69271f933678d41b8011b3d79c70 Mon Sep 17 00:00:00 2001
From: Mira Fedas <30750556+mirafedas@users.noreply.github.com>
Date: Wed, 11 Sep 2024 11:16:06 +0200
Subject: [PATCH 01/22] MWPW-156788: Unable to scroll page with active Sort
filter (#2758)
* moved merch-card class toggling to other methods
* added unit test for merch card collection on phones & tablets
* added unit test for closing the filters modal
* corrected lit import for merch sidenav
---
libs/deps/mas/merch-sidenav.js | 10 +++---
libs/features/mas/web-components/build.mjs | 16 ++++++++-
.../src/sidenav/merch-sidenav.js | 9 ++---
.../test/merch-card-collection.test.html.js | 34 ++++++++++++++++---
4 files changed, 52 insertions(+), 17 deletions(-)
diff --git a/libs/deps/mas/merch-sidenav.js b/libs/deps/mas/merch-sidenav.js
index ec6cb670c6..09057e8ecc 100644
--- a/libs/deps/mas/merch-sidenav.js
+++ b/libs/deps/mas/merch-sidenav.js
@@ -1,4 +1,4 @@
-import{html as k,css as H,LitElement as P}from"../lit-all.min.js";var r=class{constructor(e,t){this.key=Symbol("match-media-key"),this.matches=!1,this.host=e,this.host.addController(this),this.media=window.matchMedia(t),this.matches=this.media.matches,this.onChange=this.onChange.bind(this),e.addController(this)}hostConnected(){var e;(e=this.media)==null||e.addEventListener("change",this.onChange)}hostDisconnected(){var e;(e=this.media)==null||e.removeEventListener("change",this.onChange)}onChange(e){this.matches!==e.matches&&(this.matches=e.matches,this.host.requestUpdate(this.key,!this.matches))}};import{css as L}from"../lit-all.min.js";var c=L`
+import{html as k,css as H,LitElement as P}from"/libs/deps/lit-all.min.js";var r=class{constructor(e,t){this.key=Symbol("match-media-key"),this.matches=!1,this.host=e,this.host.addController(this),this.media=window.matchMedia(t),this.matches=this.media.matches,this.onChange=this.onChange.bind(this),e.addController(this)}hostConnected(){var e;(e=this.media)==null||e.addEventListener("change",this.onChange)}hostDisconnected(){var e;(e=this.media)==null||e.removeEventListener("change",this.onChange)}onChange(e){this.matches!==e.matches&&(this.matches=e.matches,this.host.requestUpdate(this.key,!this.matches))}};import{css as L}from"/libs/deps/lit-all.min.js";var c=L`
h2 {
font-size: 11px;
font-style: normal;
@@ -9,7 +9,7 @@ import{html as k,css as H,LitElement as P}from"../lit-all.min.js";var r=class{co
line-height: 32px;
color: #747474;
}
-`;import{html as N,LitElement as R}from"../lit-all.min.js";function d(s,e){let t;return function(){let o=this,i=arguments;clearTimeout(t),t=setTimeout(()=>s.apply(o,i),e)}}var x="merch-search:change";var v="merch-sidenav:select";var g="hashchange";function n(s=window.location.hash){let e=[],t=s.replace(/^#/,"").split("&");for(let o of t){let[i,l=""]=o.split("=");i&&e.push([i,decodeURIComponent(l.replace(/\+/g," "))])}return Object.fromEntries(e)}function a(s,e){if(s.deeplink){let t={};t[s.deeplink]=e,A(t)}}function A(s){let e=new URLSearchParams(window.location.hash.slice(1));Object.entries(s).forEach(([i,l])=>{l?e.set(i,l):e.delete(i)}),e.sort();let t=e.toString();if(t===window.location.hash)return;let o=window.scrollY||document.documentElement.scrollTop;window.location.hash=t,window.scrollTo(0,o)}function b(s){let e=()=>{if(window.location.hash&&!window.location.hash.includes("="))return;let t=n(window.location.hash);s(t)};return e(),window.addEventListener(g,e),()=>{window.removeEventListener(g,e)}}var p=class extends R{static properties={deeplink:{type:String}};get search(){return this.querySelector("sp-search")}constructor(){super(),this.handleInput=()=>{a(this,this.search.value),this.search.value&&this.dispatchEvent(new CustomEvent(x,{bubbles:!0,composed:!0,detail:{type:"search",value:this.search.value}}))},this.handleInputDebounced=d(this.handleInput.bind(this))}connectedCallback(){super.connectedCallback(),this.search&&(this.search.addEventListener("input",this.handleInputDebounced),this.search.addEventListener("submit",this.handleInputSubmit),this.updateComplete.then(()=>{this.setStateFromURL()}),this.startDeeplink())}disconnectedCallback(){super.disconnectedCallback(),this.search.removeEventListener("input",this.handleInputDebounced),this.search.removeEventListener("submit",this.handleInputSubmit),this.stopDeeplink?.()}setStateFromURL(){let t=n()[this.deeplink];t&&(this.search.value=t)}startDeeplink(){this.stopDeeplink=b(({search:e})=>{this.search.value=e??""})}handleInputSubmit(e){e.preventDefault()}render(){return N``}};customElements.define("merch-search",p);import{html as C,LitElement as D,css as M}from"../lit-all.min.js";var m=class extends D{static properties={sidenavListTitle:{type:String},label:{type:String},deeplink:{type:String,attribute:"deeplink"},selectedText:{type:String,reflect:!0,attribute:"selected-text"},selectedValue:{type:String,reflect:!0,attribute:"selected-value"}};static styles=[M`
+`;import{html as N,LitElement as R}from"/libs/deps/lit-all.min.js";function d(s,e){let t;return function(){let o=this,i=arguments;clearTimeout(t),t=setTimeout(()=>s.apply(o,i),e)}}var x="merch-search:change";var v="merch-sidenav:select";var g="hashchange";function n(s=window.location.hash){let e=[],t=s.replace(/^#/,"").split("&");for(let o of t){let[i,l=""]=o.split("=");i&&e.push([i,decodeURIComponent(l.replace(/\+/g," "))])}return Object.fromEntries(e)}function a(s,e){if(s.deeplink){let t={};t[s.deeplink]=e,A(t)}}function A(s){let e=new URLSearchParams(window.location.hash.slice(1));Object.entries(s).forEach(([i,l])=>{l?e.set(i,l):e.delete(i)}),e.sort();let t=e.toString();if(t===window.location.hash)return;let o=window.scrollY||document.documentElement.scrollTop;window.location.hash=t,window.scrollTo(0,o)}function b(s){let e=()=>{if(window.location.hash&&!window.location.hash.includes("="))return;let t=n(window.location.hash);s(t)};return e(),window.addEventListener(g,e),()=>{window.removeEventListener(g,e)}}var p=class extends R{static properties={deeplink:{type:String}};get search(){return this.querySelector("sp-search")}constructor(){super(),this.handleInput=()=>{a(this,this.search.value),this.search.value&&this.dispatchEvent(new CustomEvent(x,{bubbles:!0,composed:!0,detail:{type:"search",value:this.search.value}}))},this.handleInputDebounced=d(this.handleInput.bind(this))}connectedCallback(){super.connectedCallback(),this.search&&(this.search.addEventListener("input",this.handleInputDebounced),this.search.addEventListener("submit",this.handleInputSubmit),this.updateComplete.then(()=>{this.setStateFromURL()}),this.startDeeplink())}disconnectedCallback(){super.disconnectedCallback(),this.search.removeEventListener("input",this.handleInputDebounced),this.search.removeEventListener("submit",this.handleInputSubmit),this.stopDeeplink?.()}setStateFromURL(){let t=n()[this.deeplink];t&&(this.search.value=t)}startDeeplink(){this.stopDeeplink=b(({search:e})=>{this.search.value=e??""})}handleInputSubmit(e){e.preventDefault()}render(){return N``}};customElements.define("merch-search",p);import{html as C,LitElement as D,css as M}from"/libs/deps/lit-all.min.js";var m=class extends D{static properties={sidenavListTitle:{type:String},label:{type:String},deeplink:{type:String,attribute:"deeplink"},selectedText:{type:String,reflect:!0,attribute:"selected-text"},selectedValue:{type:String,reflect:!0,attribute:"selected-value"}};static styles=[M`
:host {
display: block;
contain: content;
@@ -36,7 +36,7 @@ import{html as k,css as H,LitElement as P}from"../lit-all.min.js";var r=class{co
>
${this.sidenavListTitle?C`
${this.sidenavListTitle}
`:""}
- `}};customElements.define("merch-sidenav-list",m);import{html as V,LitElement as O,css as I}from"../lit-all.min.js";var u=class extends O{static properties={sidenavCheckboxTitle:{type:String},label:{type:String},deeplink:{type:String},selectedValues:{type:Array,reflect:!0},value:{type:String}};static styles=I`
+ `}};customElements.define("merch-sidenav-list",m);import{html as V,LitElement as O,css as I}from"/libs/deps/lit-all.min.js";var u=class extends O{static properties={sidenavCheckboxTitle:{type:String},label:{type:String},deeplink:{type:String},selectedValues:{type:Array,reflect:!0},value:{type:String}};static styles=I`
:host {
display: block;
contain: content;
@@ -66,7 +66,7 @@ import{html as k,css as H,LitElement as P}from"../lit-all.min.js";var r=class{co
>
- `}};customElements.define("merch-sidenav-checkbox-group",u);var y="(max-width: 700px)";var S="(max-width: 1199px)";var T=/iP(ad|hone|od)/.test(window?.navigator?.platform)||window?.navigator?.platform==="MacIntel"&&window.navigator.maxTouchPoints>1,E=!1,h,w=s=>{s&&(T?(document.body.style.position="fixed",s.ontouchmove=e=>{e.targetTouches.length===1&&e.stopPropagation()},E||(document.addEventListener("touchmove",e=>e.preventDefault()),E=!0)):(h=document.body.style.overflow,document.body.style.overflow="hidden"))},_=s=>{s&&(T?(s.ontouchstart=null,s.ontouchmove=null,document.body.style.position="",document.removeEventListener("touchmove",e=>e.preventDefault()),E=!1):h!==void 0&&(document.body.style.overflow=h,h=void 0))};document.addEventListener("sp-opened",()=>{document.body.classList.add("merch-modal")});document.addEventListener("sp-closed",()=>{document.body.classList.remove("merch-modal")});var f=class extends P{static properties={sidenavTitle:{type:String},closeText:{type:String,attribute:"close-text"},modal:{type:Boolean,attribute:"modal",reflect:!0}};#e;constructor(){super(),this.modal=!1}static styles=[H`
+ `}};customElements.define("merch-sidenav-checkbox-group",u);var y="(max-width: 700px)";var S="(max-width: 1199px)";var T=/iP(ad|hone|od)/.test(window?.navigator?.platform)||window?.navigator?.platform==="MacIntel"&&window.navigator.maxTouchPoints>1,E=!1,h,w=s=>{s&&(T?(document.body.style.position="fixed",s.ontouchmove=e=>{e.targetTouches.length===1&&e.stopPropagation()},E||(document.addEventListener("touchmove",e=>e.preventDefault()),E=!0)):(h=document.body.style.overflow,document.body.style.overflow="hidden"))},_=s=>{s&&(T?(s.ontouchstart=null,s.ontouchmove=null,document.body.style.position="",document.removeEventListener("touchmove",e=>e.preventDefault()),E=!1):h!==void 0&&(document.body.style.overflow=h,h=void 0))};var f=class extends P{static properties={sidenavTitle:{type:String},closeText:{type:String,attribute:"close-text"},modal:{type:Boolean,attribute:"modal",reflect:!0}};#e;constructor(){super(),this.modal=!1}static styles=[H`
:host {
display: block;
}
@@ -138,4 +138,4 @@ import{html as k,css as H,LitElement as P}from"../lit-all.min.js";var r=class{co
`}get asAside(){return k`${this.sidenavTitle}
`}get dialog(){return this.shadowRoot.querySelector("sp-dialog-base")}closeModal(e){e.preventDefault(),this.dialog?.close()}openModal(){this.updateComplete.then(async()=>{w(this.dialog);let e={trigger:this.#e,notImmediatelyClosable:!0,type:"auto"},t=await window.__merch__spectrum_Overlay.open(this.dialog,e);t.addEventListener("close",()=>{this.modal=!1,_(this.dialog)}),this.shadowRoot.querySelector("sp-theme").append(t)})}updated(){this.modal&&this.openModal()}showModal({target:e}){this.#e=e,this.modal=!0}};customElements.define("merch-sidenav",f);export{f as MerchSideNav};
+ >`}get dialog(){return this.shadowRoot.querySelector("sp-dialog-base")}closeModal(e){e.preventDefault(),this.dialog?.close(),document.body.classList.remove("merch-modal")}openModal(){this.updateComplete.then(async()=>{w(this.dialog),document.body.classList.add("merch-modal");let e={trigger:this.#e,notImmediatelyClosable:!0,type:"auto"},t=await window.__merch__spectrum_Overlay.open(this.dialog,e);t.addEventListener("close",()=>{this.modal=!1,_(this.dialog)}),this.shadowRoot.querySelector("sp-theme").append(t)})}updated(){this.modal&&this.openModal()}showModal({target:e}){this.#e=e,this.modal=!0}};customElements.define("merch-sidenav",f);export{f as MerchSideNav};
diff --git a/libs/features/mas/web-components/build.mjs b/libs/features/mas/web-components/build.mjs
index 3b21388f48..5283a4bc9a 100644
--- a/libs/features/mas/web-components/build.mjs
+++ b/libs/features/mas/web-components/build.mjs
@@ -57,7 +57,7 @@ Promise.all([
minify: true,
outfile: `${outfolder}/merch-sidenav.js`,
format: 'esm',
- plugins: [rewriteImports()],
+ plugins: [rewriteImportsToLibsFolder()],
external: ['lit'],
}),
buildLitComponent('merch-icon'),
@@ -84,3 +84,17 @@ function rewriteImports(rew) {
},
};
}
+
+function rewriteImportsToLibsFolder(rew) {
+ return {
+ name: 'rewrite-imports-to-libs-folder',
+ setup(build) {
+ build.onResolve({ filter: /^lit(\/.*)?$/ }, (args) => {
+ return {
+ path: '/libs/deps/lit-all.min.js',
+ external: true,
+ };
+ });
+ },
+ };
+}
diff --git a/libs/features/mas/web-components/src/sidenav/merch-sidenav.js b/libs/features/mas/web-components/src/sidenav/merch-sidenav.js
index 9fefd5033c..737c741e37 100644
--- a/libs/features/mas/web-components/src/sidenav/merch-sidenav.js
+++ b/libs/features/mas/web-components/src/sidenav/merch-sidenav.js
@@ -7,13 +7,6 @@ import './merch-sidenav-checkbox-group.js';
import { SPECTRUM_MOBILE_LANDSCAPE, TABLET_DOWN } from '../media.js';
import { disableBodyScroll, enableBodyScroll } from '../bodyScrollLock.js';
-document.addEventListener('sp-opened', () => {
- document.body.classList.add('merch-modal');
-});
-document.addEventListener('sp-closed', () => {
- document.body.classList.remove('merch-modal');
-});
-
export class MerchSideNav extends LitElement {
static properties = {
sidenavTitle: { type: String },
@@ -137,11 +130,13 @@ export class MerchSideNav extends LitElement {
closeModal(e) {
e.preventDefault();
this.dialog?.close();
+ document.body.classList.remove('merch-modal');
}
openModal() {
this.updateComplete.then(async () => {
disableBodyScroll(this.dialog);
+ document.body.classList.add('merch-modal');
const options = {
trigger: this.#target,
notImmediatelyClosable: true,
diff --git a/libs/features/mas/web-components/test/merch-card-collection.test.html.js b/libs/features/mas/web-components/test/merch-card-collection.test.html.js
index ee0dfcbfc5..5b7cd5a477 100644
--- a/libs/features/mas/web-components/test/merch-card-collection.test.html.js
+++ b/libs/features/mas/web-components/test/merch-card-collection.test.html.js
@@ -72,14 +72,40 @@ let merchCards;
const shouldSkipTests = sessionStorage.getItem('skipTests') ? 'true' : 'false';
runTests(async () => {
- await toggleLargeDesktop();
+ let render;
mockLana();
await mockFetch(withWcs);
await mas();
if (shouldSkipTests !== 'true') {
- describe('merch-card-collection web component', () => {
- let render;
- beforeEach(() => {
+ describe("merch-card-collection web component on phones and tablets", () => {
+ beforeEach(async () => {
+ [merchCards, render] = prepareTemplate('catalogCards', false);
+ });
+
+ it('sets the class for modal when opening filters in a modal', async () => {
+ render();
+ await delay(100);
+ expect(document.body.classList.contains('merch-modal')).to.be.false;
+ merchCards.shadowRoot.querySelector('#filtersButton').click();
+ await delay(100);
+ expect(document.body.classList.contains('merch-modal')).to.be.true;
+ });
+
+ it('removes the class for modal when closing the filters modal', async () => {
+ render();
+ await delay(100);
+ merchCards.shadowRoot.querySelector('#filtersButton').click();
+ await delay(100);
+ expect(document.body.classList.contains('merch-modal')).to.be.true;
+ document.querySelector('merch-sidenav').shadowRoot.querySelector('#sidenav').querySelector('sp-link').click();
+ await delay(100);
+ expect(document.body.classList.contains('merch-modal')).to.be.false;
+ });
+ });
+
+ describe('merch-card-collection web component on desktop', () => {
+ beforeEach(async () => {
+ await toggleLargeDesktop();
document.location.hash = '';
[merchCards, render] = prepareTemplate('catalogCards', false);
});
From 7921bf87c42491fbce899c8d850e323a342eea65 Mon Sep 17 00:00:00 2001
From: Bozo Jovicic <37440641+bozojovicic@users.noreply.github.com>
Date: Wed, 11 Sep 2024 11:16:14 +0200
Subject: [PATCH 02/22] MWPW-157210 STE Promo card not appearing (#2837)
* MWPW-157210 STE Promo card not appearing
* MWPW-157210 STE Promo card not appearing
* MWPW-157210 STE Promo card not appearing
* Trigger Build
---------
Co-authored-by: Bozo Jovicic
---
.../merch-card-collection.js | 3 ++-
libs/utils/helpers.js | 18 ++++++++++++++++++
test/utils/helpers.test.js | 14 ++++++++++++++
3 files changed, 34 insertions(+), 1 deletion(-)
create mode 100644 test/utils/helpers.test.js
diff --git a/libs/blocks/merch-card-collection/merch-card-collection.js b/libs/blocks/merch-card-collection/merch-card-collection.js
index 695f9da51e..dad54cb600 100644
--- a/libs/blocks/merch-card-collection/merch-card-collection.js
+++ b/libs/blocks/merch-card-collection/merch-card-collection.js
@@ -1,3 +1,4 @@
+import { overrideUrlOrigin } from '../../utils/helpers.js';
import {
createTag, decorateLinks, getConfig, loadBlock, loadStyle, localizeLink,
} from '../../utils/utils.js';
@@ -57,7 +58,7 @@ async function getCardsRoot(config, html) {
}
const fetchOverrideCard = (action, config) => new Promise((resolve, reject) => {
- fetch(`${localizeLink(action?.target, config)}.plain.html`).then((res) => {
+ fetch(`${localizeLink(overrideUrlOrigin(action?.target))}.plain.html`).then((res) => {
if (res.ok) {
res.text().then((cardContent) => {
const response = { path: action.target, cardContent: /^(.*)<\/div>$/.exec(cardContent.replaceAll('\n', ''))[1] };
diff --git a/libs/utils/helpers.js b/libs/utils/helpers.js
index 73274a4988..f461139f3e 100644
--- a/libs/utils/helpers.js
+++ b/libs/utils/helpers.js
@@ -19,3 +19,21 @@ export function updateLinkWithLangRoot(link) {
return link;
}
}
+
+/**
+ * Replaces the origin of the provided link with location.origin.
+ *
+ * @param link
+ * @returns {string|*}
+ */
+export function overrideUrlOrigin(link) {
+ try {
+ const url = new URL(link);
+ if (url.hostname !== window.location.hostname) {
+ return link.replace(url.origin, window.location.origin);
+ }
+ } catch (e) {
+ // ignore
+ }
+ return link;
+}
diff --git a/test/utils/helpers.test.js b/test/utils/helpers.test.js
new file mode 100644
index 0000000000..d49a0ec4b3
--- /dev/null
+++ b/test/utils/helpers.test.js
@@ -0,0 +1,14 @@
+import { expect } from '@esm-bundle/chai';
+import { overrideUrlOrigin } from '../../libs/utils/helpers.js';
+
+describe('overrideUrlOrigin', () => {
+ it('Change origin to http://localhost:2000', async () => {
+ const link = overrideUrlOrigin('http://www.qa.adobe.com/some/page.html?a=b#hash');
+ expect(link).to.equal('http://localhost:2000/some/page.html?a=b#hash');
+ });
+
+ it('Ignore relative URLs', async () => {
+ const link = overrideUrlOrigin('/some/page.html?a=b#hash');
+ expect(link).to.equal('/some/page.html?a=b#hash');
+ });
+});
From e03455463a5e69f612422863d9174f5116a30f55 Mon Sep 17 00:00:00 2001
From: Rares Munteanu
Date: Wed, 11 Sep 2024 11:16:21 +0200
Subject: [PATCH 03/22] [MWPW-157740] Table pricing gutter (#2851)
---
libs/blocks/table/table.css | 1 +
1 file changed, 1 insertion(+)
diff --git a/libs/blocks/table/table.css b/libs/blocks/table/table.css
index 391c70fb1a..fd95c0714b 100644
--- a/libs/blocks/table/table.css
+++ b/libs/blocks/table/table.css
@@ -264,6 +264,7 @@
.table .section-row .col {
padding: 16px 24px;
+ column-gap: 0.5ch;
}
.table .section-row .col:has(> p:nth-child(2)) {
From 4a4a12e70929d9464e409796abccbc42d7836c85 Mon Sep 17 00:00:00 2001
From: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com>
Date: Wed, 11 Sep 2024 03:16:28 -0600
Subject: [PATCH 04/22] MWPW-158148 [MEP] Can't use ul, ol or li in MEP
selectorsf (#2864)
* add ol, ul and li
* add unit test
---
libs/features/personalization/personalization.js | 1 +
.../personalization/modifyNonFragmentSelector.test.js | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js
index 71857e6c3b..091e6ad027 100644
--- a/libs/features/personalization/personalization.js
+++ b/libs/features/personalization/personalization.js
@@ -366,6 +366,7 @@ function modifySelectorTerm(termParam) {
const htmlEls = [
'html', 'body', 'header', 'footer', 'main',
'div', 'a', 'p', 'strong', 'em', 'picture', 'source', 'img', 'h',
+ 'ul', 'ol', 'li',
];
const startTextMatch = term.match(/^[a-zA-Z/./-]*/);
const startText = startTextMatch ? startTextMatch[0].toLowerCase() : '';
diff --git a/test/features/personalization/modifyNonFragmentSelector.test.js b/test/features/personalization/modifyNonFragmentSelector.test.js
index f9345c3eb1..fd3cdbf893 100644
--- a/test/features/personalization/modifyNonFragmentSelector.test.js
+++ b/test/features/personalization/modifyNonFragmentSelector.test.js
@@ -135,6 +135,14 @@ const values = [
b: 'custom-block3',
a: '.custom-block:nth-child(3 of .custom-block)',
},
+ {
+ b: 'any-marquee ol li:nth-child(2)',
+ a: '[class*="marquee"] ol li:nth-child(2)',
+ },
+ {
+ b: 'any-marquee ul li:nth-child(2)',
+ a: '[class*="marquee"] ul li:nth-child(2)',
+ },
];
describe('test different values', () => {
values.forEach((value) => {
From 9c32237bdedf6904fffe8abe83edd4ba4d7d2cf2 Mon Sep 17 00:00:00 2001
From: Robert Bogos <146744221+robert-bogos@users.noreply.github.com>
Date: Wed, 11 Sep 2024 15:18:36 +0300
Subject: [PATCH 05/22] [MWPW-157347] Environment relative URLs (#2834)
* environment aware urls
* added domains map entry for testing
* fixed unit tests
* hotfix
* moved the convert urls logic to a separate function
* added early returns
* hotfix
* relative urls unit tests
* removed fork domain
---------
Co-authored-by: milo-pr-merge[bot] <169241390+milo-pr-merge[bot]@users.noreply.github.com>
---
libs/scripts/scripts.js | 18 +++++---
libs/utils/utils.js | 21 +++++++--
test/utils/utils.test.js | 97 +++++++++++++++++++++++++++++++++++-----
3 files changed, 116 insertions(+), 20 deletions(-)
diff --git a/libs/scripts/scripts.js b/libs/scripts/scripts.js
index 4388eea325..7c97265400 100644
--- a/libs/scripts/scripts.js
+++ b/libs/scripts/scripts.js
@@ -22,11 +22,19 @@ import locales from '../utils/locales.js';
const prodDomains = ['milo.adobe.com'];
const stageDomainsMap = {
- 'www.adobe.com': 'www.stage.adobe.com',
- 'blog.adobe.com': 'blog.stage.adobe.com',
- 'business.adobe.com': 'business.stage.adobe.com',
- 'helpx.adobe.com': 'helpx.stage.adobe.com',
- 'news.adobe.com': 'news.stage.adobe.com',
+ 'www.stage.adobe.com': {
+ 'www.adobe.com': 'origin',
+ 'helpx.adobe.com': 'helpx.stage.adobe.com',
+ },
+ '--bacom--adobecom.hlx.live': {
+ 'business.adobe.com': 'origin',
+ 'news.adobe.com': 'main--news--adobecom.hlx.live',
+ },
+ '--blog--adobecom.hlx.page': {
+ 'blog.adobe.com': 'origin',
+ 'business.adobe.com': 'main--bacom--adobecom.hlx.page',
+ },
+ '.business-graybox.adobe.com': { 'business.adobe.com': 'origin' },
};
const config = {
diff --git a/libs/utils/utils.js b/libs/utils/utils.js
index 3b57b87e96..07fee41492 100644
--- a/libs/utils/utils.js
+++ b/libs/utils/utils.js
@@ -638,17 +638,32 @@ const decorateCopyLink = (a, evt) => {
});
};
+export function convertStageLinks({ anchors, config, hostname }) {
+ if (config.env?.name === 'prod' || !config.stageDomainsMap) return;
+ const matchedRules = Object.entries(config.stageDomainsMap)
+ .find(([domain]) => hostname.includes(domain));
+ if (!matchedRules) return;
+ const [, domainsMap] = matchedRules;
+ [...anchors].forEach((a) => {
+ const matchedDomain = Object.keys(domainsMap)
+ .find((domain) => a.href.includes(domain));
+ if (!matchedDomain) return;
+ a.href = a.href.replace(a.hostname, domainsMap[matchedDomain] === 'origin'
+ ? hostname
+ : domainsMap[matchedDomain]);
+ });
+}
+
export function decorateLinks(el) {
const config = getConfig();
decorateImageLinks(el);
const anchors = el.getElementsByTagName('a');
+ const { hostname } = window.location;
+ convertStageLinks({ anchors, config, hostname });
return [...anchors].reduce((rdx, a) => {
appendHtmlToLink(a);
a.href = localizeLink(a.href);
decorateSVG(a);
- if (config.env?.name === 'stage' && config.stageDomainsMap?.[a.hostname]) {
- a.href = a.href.replace(a.hostname, config.stageDomainsMap[a.hostname]);
- }
if (a.href.includes('#_blank')) {
a.setAttribute('target', '_blank');
a.href = a.href.replace('#_blank', '');
diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js
index d3132ea524..669817fe6b 100644
--- a/test/utils/utils.test.js
+++ b/test/utils/utils.test.js
@@ -10,6 +10,30 @@ const config = {
codeRoot: '/libs',
locales: { '': { ietf: 'en-US', tk: 'hah7vzn.css' } },
};
+const stageDomainsMap = {
+ 'www.stage.adobe.com': {
+ 'www.adobe.com': 'origin',
+ 'business.adobe.com': 'business.stage.adobe.com',
+ 'blog.adobe.com': 'blog.stage.adobe.com',
+ 'helpx.adobe.com': 'helpx.stage.adobe.com',
+ 'news.adobe.com': 'news.stage.adobe.com',
+ },
+ '--bacom--adobecom.hlx.live': {
+ 'business.adobe.com': 'origin',
+ 'blog.adobe.com': 'main--blog--adobecom.hlx.live',
+ 'helpx.adobe.com': 'main--helpx--adobecom.hlx.live',
+ 'news.adobe.com': 'main--news--adobecom.hlx.live',
+ },
+ '--blog--adobecom.hlx.page': {
+ 'blog.adobe.com': 'origin',
+ 'business.adobe.com': 'main--bacom--adobecom.hlx.page',
+ 'helpx.adobe.com': 'main--helpx--adobecom.hlx.page',
+ 'news.adobe.com': 'main--news--adobecom.hlx.page',
+ },
+ '.business-graybox.adobe.com': { 'business.adobe.com': 'origin' },
+};
+const prodDomains = ['www.adobe.com', 'business.adobe.com', 'blog.adobe.com', 'helpx.adobe.com', 'news.adobe.com'];
+const externalDomains = ['external1.com', 'external2.com'];
const ogFetch = window.fetch;
describe('Utils', () => {
@@ -114,7 +138,7 @@ describe('Utils', () => {
await waitForElement('.login-action');
const login = document.querySelector('.login-action');
utils.decorateLinks(login);
- expect(login.href).to.equal('https://www.stage.adobe.com/');
+ expect(login.href).to.equal('https://www.adobe.com/');
});
it('Implements a copy link action', async () => {
await waitForElement('.copy-action');
@@ -473,22 +497,71 @@ describe('Utils', () => {
expect(document.querySelector('.quote.hide-block')).to.be.null;
});
- it('should convert prod links to stage links on stage env', async () => {
- const stageDomainsMap = {
- 'www.adobe.com': 'www.stage.adobe.com',
- 'blog.adobe.com': 'blog.stage.adobe.com',
- 'business.adobe.com': 'business.stage.adobe.com',
- 'helpx.adobe.com': 'helpx.stage.adobe.com',
- 'news.adobe.com': 'news.stage.adobe.com',
+ it('should convert links on stage when stageDomainsMap provided', async () => {
+ const stageConfig = {
+ ...config,
+ env: { name: 'stage' },
+ stageDomainsMap,
};
- utils.setConfig({
+
+ Object.entries(stageDomainsMap).forEach(([hostname, domainsMap]) => {
+ const anchors = Object.keys(domainsMap).map((d) => utils.createTag('a', { href: `https://${d}` }));
+ const externalAnchors = externalDomains.map((url) => utils.createTag('a', { href: url }));
+
+ utils.convertStageLinks({
+ anchors: [...anchors, ...externalAnchors],
+ config: stageConfig,
+ hostname,
+ });
+
+ anchors.forEach((a, index) => {
+ const expectedDomain = Object.values(domainsMap)[index];
+ expect(a.href).to.contain(expectedDomain === 'origin' ? hostname : expectedDomain);
+ });
+
+ externalAnchors.forEach((a) => expect(a.href).to.equal(a.href));
+ });
+ });
+
+ it('should not convert links on stage when no stageDomainsMap provided', async () => {
+ const stageConfig = {
...config,
env: { name: 'stage' },
+ };
+
+ Object.entries(stageDomainsMap).forEach(([hostname, domainsMap]) => {
+ const anchors = Object.keys(domainsMap).map((d) => utils.createTag('a', { href: `https://${d}` }));
+ const externalAnchors = externalDomains.map((url) => utils.createTag('a', { href: url }));
+
+ utils.convertStageLinks({
+ anchors: [...anchors, ...externalAnchors],
+ config: stageConfig,
+ hostname,
+ });
+
+ [...anchors, ...externalAnchors].forEach((a) => expect(a.href).to.equal(a.href));
+ });
+ });
+
+ it('should not convert links on prod', async () => {
+ const prodConfig = {
+ ...config,
+ env: { name: 'prod' },
stageDomainsMap,
+ };
+
+ prodDomains.forEach((hostname) => {
+ const anchors = prodDomains.map((d) => utils.createTag('a', { href: `https://${d}` }));
+ const externalAnchors = externalDomains.map((url) => utils.createTag('a', { href: url }));
+
+ utils.convertStageLinks({
+ anchors: [...anchors, ...externalAnchors],
+ config: prodConfig,
+ hostname,
+ });
+
+ [...anchors, ...externalAnchors].forEach((a) => expect(a.href).to.equal(a.href));
});
- const links = Object.keys(stageDomainsMap).map((prodDom) => document.body.appendChild(createTag('a', { href: `https://${prodDom}`, 'data-prod-dom': prodDom })));
- await utils.decorateLinks(document.body);
- links.forEach((l) => expect(l.hostname === stageDomainsMap[l.dataset.prodDom]).to.be.true);
});
});
From c7107532b6a9f8860679aec89695ef4069491cf2 Mon Sep 17 00:00:00 2001
From: Raghav Sharma <118168183+sharmrj@users.noreply.github.com>
Date: Wed, 11 Sep 2024 17:48:43 +0530
Subject: [PATCH 06/22] MWPW-151534 [PEP Prompt] Dismissal action on close
button of prompt not seen in windows (#2866)
* Made the pep close button focus a consistent color
* update franklin cache with dummy change
* revert previous change
---
libs/features/webapp-prompt/webapp-prompt.css | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libs/features/webapp-prompt/webapp-prompt.css b/libs/features/webapp-prompt/webapp-prompt.css
index 39d012916a..dee60577b1 100644
--- a/libs/features/webapp-prompt/webapp-prompt.css
+++ b/libs/features/webapp-prompt/webapp-prompt.css
@@ -2,6 +2,7 @@
.appPrompt {
--pep-background-prompt: #ffffff;
--pep-background-progress: #e9e9e9;
+ --pep-dismiss-button-focus-border-color: #3b63fb;
display: none;
}
@@ -159,10 +160,7 @@
}
.appPrompt-close:focus {
- /* For Firefox */
- outline: auto;
- /* For Chrome, Edge, and Safari */
- outline: 2px solid -webkit-focus-ring-color;
+ outline: 2px solid var(--pep-dismiss-button-focus-border-color);
}
.appPrompt-progressWrapper {
From 3679fd07498889cb974f46602dace93b3c577445 Mon Sep 17 00:00:00 2001
From: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com>
Date: Wed, 11 Sep 2024 13:39:40 -0600
Subject: [PATCH 07/22] REVERT MWPW-157686 [MEP] Cannot spoof an experience
that exists in manifest but not in Target #2844 (#2870)
revert
---
libs/features/personalization/personalization.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js
index 091e6ad027..b51101f720 100644
--- a/libs/features/personalization/personalization.js
+++ b/libs/features/personalization/personalization.js
@@ -894,6 +894,8 @@ export function cleanAndSortManifestList(manifests) {
freshManifest = manifestObj[manifest.manifestPath];
}
freshManifest.name = fullManifest.name;
+ freshManifest.selectedVariantName = fullManifest.selectedVariantName;
+ freshManifest.selectedVariant = freshManifest.variants[freshManifest.selectedVariantName];
manifestObj[manifest.manifestPath] = freshManifest;
} else {
manifestObj[manifest.manifestPath] = manifest;
From a7c31b7acb30e0556b32252826e2ddcd56ec21ab Mon Sep 17 00:00:00 2001
From: sharathkannan <138484653+sharath-kannan@users.noreply.github.com>
Date: Thu, 12 Sep 2024 22:30:29 +0530
Subject: [PATCH 08/22] fix(MWPW-155964):Lana log error type changed to info.
(#2818)
* lana log error type changed
* modified lana logs
* added a few unit tests for lana logs
* Updated tag in utils.js
* linting error fixed
* linting error fix 2
* unit test fix
* added unit test for vimeo
---
libs/blocks/article-feed/article-helpers.js | 2 +-
.../event-rich-results/event-rich-results.js | 2 +-
libs/blocks/faas/utils.js | 2 +-
libs/blocks/library-config/lists/templates.js | 2 +-
.../mobile-app-banner/mobile-app-banner.js | 2 +-
libs/blocks/path-finder/path-finder.js | 2 +-
libs/blocks/preflight/panels/seo.js | 4 +--
libs/blocks/quiz-entry/mlField.js | 2 +-
libs/blocks/quiz-entry/quiz-entry.js | 2 +-
libs/blocks/quiz-entry/quizPopover.js | 2 +-
libs/blocks/quiz-results/quiz-results.js | 4 +--
libs/blocks/tag-selector/tag-selector.js | 2 +-
libs/blocks/video-metadata/video-metadata.js | 8 +++---
libs/blocks/vimeo/vimeo.js | 2 +-
libs/features/footer-promo.js | 2 +-
libs/martech/martech.js | 4 +--
.../article-header/article-header.test.js | 28 +++++++++++++------
.../global-footer/global-footer.test.js | 6 ++--
test/blocks/quiz-results/mocks/body.html | 10 +++++++
test/blocks/quiz-results/quiz-results.test.js | 7 +++++
test/blocks/vimeo/vimeo.test.html | 12 +++++++-
.../webapp-prompt/webapp-prompt.test.js | 4 +--
22 files changed, 74 insertions(+), 37 deletions(-)
diff --git a/libs/blocks/article-feed/article-helpers.js b/libs/blocks/article-feed/article-helpers.js
index 779099e8f1..e9cfe1d59b 100644
--- a/libs/blocks/article-feed/article-helpers.js
+++ b/libs/blocks/article-feed/article-helpers.js
@@ -129,7 +129,7 @@ export async function loadTaxonomy() {
a.href = tax.link;
} else {
// eslint-disable-next-line no-console
- window.lana.log(`Trying to get a link for an unknown topic: ${topic} (current page)`, { tags: 'errorType=warn,module=article-feed' });
+ window.lana.log(`Trying to get a link for an unknown topic: ${topic} (current page)`, { tags: 'article-feed' });
a.href = '#';
}
delete a.dataset.topicLink;
diff --git a/libs/blocks/event-rich-results/event-rich-results.js b/libs/blocks/event-rich-results/event-rich-results.js
index e0df0551d6..78f69ff15b 100644
--- a/libs/blocks/event-rich-results/event-rich-results.js
+++ b/libs/blocks/event-rich-results/event-rich-results.js
@@ -16,7 +16,7 @@ function logNullValues(obj) {
Object.keys(obj).forEach((key) => {
const value = obj[key];
if (!value || value === '') {
- window.lana.log(`Event property ${key} is not defined`, { tags: 'errorType=warn,module=event-rich-results' });
+ window.lana.log(`Event property ${key} is not defined`, { tags: 'event-rich-results' });
}
logNullValues(value);
});
diff --git a/libs/blocks/faas/utils.js b/libs/blocks/faas/utils.js
index 70c17f093d..9c3249d7e4 100644
--- a/libs/blocks/faas/utils.js
+++ b/libs/blocks/faas/utils.js
@@ -248,7 +248,7 @@ const beforeSubmitCallback = () => {
}),
})
.catch((error) => {
- window.lana.log(`AA Sandbox Error: ${error.reason || error.error || error.message || error}`, { tags: 'errorType=info,module=faas' });
+ window.lana.log(`AA Sandbox Error: ${error.reason || error.error || error.message || error}`, { tags: 'faas', errorType: 'i' });
});
}
};
diff --git a/libs/blocks/library-config/lists/templates.js b/libs/blocks/library-config/lists/templates.js
index 2c1f780078..736f79c35c 100644
--- a/libs/blocks/library-config/lists/templates.js
+++ b/libs/blocks/library-config/lists/templates.js
@@ -43,7 +43,7 @@ function formatDom(aemDom, path) {
async function formatTemplate(path) {
const resp = await fetch(path);
- if (!resp.ok) window.lana.log('Could not fetch template path', { tags: 'errorType=info,module=sidekick-templates' });
+ if (!resp.ok) window.lana.log('Could not fetch template path', { tags: 'sidekick-templates', errorType: 'i' });
const html = await resp.text();
const dom = new DOMParser().parseFromString(html, 'text/html');
diff --git a/libs/blocks/mobile-app-banner/mobile-app-banner.js b/libs/blocks/mobile-app-banner/mobile-app-banner.js
index 9c5988ee44..62f68b7086 100644
--- a/libs/blocks/mobile-app-banner/mobile-app-banner.js
+++ b/libs/blocks/mobile-app-banner/mobile-app-banner.js
@@ -18,7 +18,7 @@ async function getECID() {
if (window.alloy) {
await window.alloy('getIdentity').then((data) => {
ecid = data?.identity?.ECID;
- }).catch((err) => window.lana.log(`Error fetching ECID: ${err}`, { tags: 'errorType=error,module=mobile-app-banner' }));
+ }).catch((err) => window.lana.log(`Error fetching ECID: ${err}`, { tags: 'mobile-app-banner' }));
}
return ecid;
}
diff --git a/libs/blocks/path-finder/path-finder.js b/libs/blocks/path-finder/path-finder.js
index 8cad4c1c9d..3ba93e71df 100644
--- a/libs/blocks/path-finder/path-finder.js
+++ b/libs/blocks/path-finder/path-finder.js
@@ -63,7 +63,7 @@ function buildUi(el, path) {
async function setup(el) {
await login({ scopes: SCOPES, telemetry: TELEMETRY });
if (!account.value.username) {
- window.lana.log('Could not login to MS Graph', { tags: 'errorType=info,module=path-finder' });
+ window.lana.log('Could not login to MS Graph', { tags: 'path-finder', errorType: 'i' });
return;
}
el.innerHTML = '';
diff --git a/libs/blocks/preflight/panels/seo.js b/libs/blocks/preflight/panels/seo.js
index e69c561a7d..443b35d7c8 100644
--- a/libs/blocks/preflight/panels/seo.js
+++ b/libs/blocks/preflight/panels/seo.js
@@ -160,7 +160,7 @@ async function spidyCheck(url) {
connectionError();
} catch (e) {
connectionError();
- window.lana.log(`There was a problem connecting to the link check API ${url}. ${e}`, { tags: 'errorType=info,module=preflight' });
+ window.lana.log(`There was a problem connecting to the link check API ${url}. ${e}`, { tags: 'preflight', errorType: 'i' });
}
return false;
}
@@ -182,7 +182,7 @@ async function getSpidyResults(url, opts) {
return acc;
}, []);
} catch (e) {
- window.lana.log(`There was a problem connecting to the link check API ${url}/api/url-http-status. ${e}`, { tags: 'errorType=info,module=preflight' });
+ window.lana.log(`There was a problem connecting to the link check API ${url}/api/url-http-status. ${e}`, { tags: 'preflight', errorType: 'i' });
return [];
}
}
diff --git a/libs/blocks/quiz-entry/mlField.js b/libs/blocks/quiz-entry/mlField.js
index a04545b80c..17b9f72fc9 100644
--- a/libs/blocks/quiz-entry/mlField.js
+++ b/libs/blocks/quiz-entry/mlField.js
@@ -26,7 +26,7 @@ export const getMLResults = async (endpoint, apiKey, threshold, input, count, va
body: JSON.stringify(params),
})
.then((response) => response.json())
- .catch((error) => window.lana.log(`ERROR: Fetching fi codes ${error}`, { tags: 'errorType=info,module=quiz-entry' }));
+ .catch((error) => window.lana.log(`ERROR: Fetching fi codes ${error}`, { tags: 'quiz-entry', errorType: 'i' }));
let value;
let highestProb = null;
diff --git a/libs/blocks/quiz-entry/quiz-entry.js b/libs/blocks/quiz-entry/quiz-entry.js
index 6c9c9394ba..ea83b47c60 100644
--- a/libs/blocks/quiz-entry/quiz-entry.js
+++ b/libs/blocks/quiz-entry/quiz-entry.js
@@ -212,7 +212,7 @@ const App = ({
}
if (fiResults.errors) error = fiResults.errors[0].title;
if (fiResults.error_code) error = fiResults.message;
- window.lana.log(`ML results error - ${error}`, { tags: 'errorType=info,module=quiz-entry' });
+ window.lana.log(`ML results error - ${error}`, { tags: 'quiz-entry', errorType: 'i' });
sendMLFieldAnalytics(fallback, false);
}
diff --git a/libs/blocks/quiz-entry/quizPopover.js b/libs/blocks/quiz-entry/quizPopover.js
index 1c444d0d3d..ed0edbe212 100644
--- a/libs/blocks/quiz-entry/quizPopover.js
+++ b/libs/blocks/quiz-entry/quizPopover.js
@@ -12,7 +12,7 @@ export const getSuggestions = async (endpoint, clientId, input, scope) => {
});
if (!response.ok) {
- window.lana.log('Failed to fetch suggestions', { tags: 'errorType=info,module=quiz-entry' });
+ window.lana.log('Failed to fetch suggestions', { tags: 'quiz-entry', errorType: 'i' });
return '';
}
diff --git a/libs/blocks/quiz-results/quiz-results.js b/libs/blocks/quiz-results/quiz-results.js
index 7465782fc7..7c9622366a 100644
--- a/libs/blocks/quiz-results/quiz-results.js
+++ b/libs/blocks/quiz-results/quiz-results.js
@@ -20,7 +20,7 @@ async function loadFragments(el, experiences) {
function redirectPage(quizUrl, debug, message) {
const url = quizUrl ? getLocalizedURL(quizUrl.text) : 'https://adobe.com';
- window.lana.log(message, { tags: 'errorType=error,module=quiz-results' });
+ window.lana.log(message, { tags: 'quiz-results' });
if (debug === 'quiz-results') {
// eslint-disable-next-line no-console
@@ -97,7 +97,7 @@ export default async function init(el, debug = null, localStoreKey = null) {
loadFragments(el, basic);
} else {
- window.lana.log(`${LOADING_ERROR} The quiz-results block is misconfigured`, { tags: 'errorType=error,module=quiz-results' });
+ window.lana.log(`${LOADING_ERROR} The quiz-results block is misconfigured`, { tags: 'quiz-results' });
return;
}
diff --git a/libs/blocks/tag-selector/tag-selector.js b/libs/blocks/tag-selector/tag-selector.js
index 8607fed08c..ccfc43f9c9 100644
--- a/libs/blocks/tag-selector/tag-selector.js
+++ b/libs/blocks/tag-selector/tag-selector.js
@@ -86,7 +86,7 @@ const TagSelector = ({ consumerUrls = [] }) => {
const fetchCasS = async () => {
const { tags, errorMsg } = await loadCaasTags(caasTagUrl);
- if (errorMsg) window.lana.log(`Tag Selector. Error fetching caas tags: ${errorMsg}`, { tags: 'errorType=info,module=tag-selector' });
+ if (errorMsg) window.lana.log(`Tag Selector. Error fetching caas tags: ${errorMsg}`, { tags: 'tag-selector', errorType: 'i' });
setTagSelectorTags((prevConsumerTags) => ({ CaaS: tags, ...prevConsumerTags }));
};
diff --git a/libs/blocks/video-metadata/video-metadata.js b/libs/blocks/video-metadata/video-metadata.js
index 388cb62034..d94b9410b4 100644
--- a/libs/blocks/video-metadata/video-metadata.js
+++ b/libs/blocks/video-metadata/video-metadata.js
@@ -25,7 +25,7 @@ function addBroadcastEventField(videoObj, blockKey, blockValue) {
videoObj.publication[i][camelize(key)] = blockValue;
break;
default:
- window.lana.log(`VideoMetadata -- Unknown BroadcastEvent property: ${blockKey}`, { tags: 'errorType=warn,module=video-metadata' });
+ window.lana.log(`VideoMetadata -- Unknown BroadcastEvent property: ${blockKey}`, { tags: 'video-metadata' });
break;
}
}
@@ -45,7 +45,7 @@ function addClipField(videoObj, blockKey, blockValue) {
videoObj.hasPart[i][camelize(key)] = blockValue;
break;
default:
- window.lana.log(`VideoMetadata -- Unhandled Clip property: ${blockKey}`, { tags: 'errorType=warn,module=video-metadata' });
+ window.lana.log(`VideoMetadata -- Unhandled Clip property: ${blockKey}`, { tags: 'video-metadata' });
break;
}
}
@@ -61,7 +61,7 @@ function addSeekToActionField(videoObj, blockKey, blockValue) {
videoObj.potentialAction['startOffset-input'] = blockValue;
break;
default:
- window.lana.log(`VideoMetadata -- Unhandled SeekToAction property: ${blockKey}`, { tags: 'errorType=warn,module=video-metadata' });
+ window.lana.log(`VideoMetadata -- Unhandled SeekToAction property: ${blockKey}`, { tags: 'video-metadata' });
break;
}
}
@@ -96,7 +96,7 @@ export function createVideoObject(record) {
addSeekToActionField(video, blockKey, blockVal);
break;
default:
- window.lana.log(`VideoMetadata -- Unhandled VideoObject property: ${blockKey}`, { tags: 'errorType=warn,module=video-metadata' });
+ window.lana.log(`VideoMetadata -- Unhandled VideoObject property: ${blockKey}`, { tags: 'video-metadata' });
break;
}
});
diff --git a/libs/blocks/vimeo/vimeo.js b/libs/blocks/vimeo/vimeo.js
index deabe6bb85..10c55b599d 100644
--- a/libs/blocks/vimeo/vimeo.js
+++ b/libs/blocks/vimeo/vimeo.js
@@ -36,7 +36,7 @@ class LiteVimeo extends HTMLElement {
this.style.backgroundImage = `url("${thumbnailUrl}")`;
})
.catch((e) => {
- window.lana.log(`Error fetching Vimeo thumbnail: ${e}`, { tags: 'errorType=info,module=vimeo' });
+ window.lana.log(`Error fetching Vimeo thumbnail: ${e}`, { tags: 'vimeo', errorType: 'i' });
});
}
diff --git a/libs/features/footer-promo.js b/libs/features/footer-promo.js
index 78466a0055..2d47501b84 100644
--- a/libs/features/footer-promo.js
+++ b/libs/features/footer-promo.js
@@ -20,7 +20,7 @@ async function getPromoFromTaxonomy(contentRoot, doc) {
if (primaryTag) return primaryTag[FOOTER_PROMO_LINK_KEY];
} catch (error) {
/* c8 ignore next 2 */
- window.lana.log(`Footer Promo - Taxonomy error: ${error}`, { tags: 'errorType=info,module=footer-promo' });
+ window.lana.log(`Footer Promo - Taxonomy error: ${error}`, { tags: 'footer-promo', errorType: 'i' });
}
return undefined;
}
diff --git a/libs/martech/martech.js b/libs/martech/martech.js
index 91906910bc..01492cadfe 100644
--- a/libs/martech/martech.js
+++ b/libs/martech/martech.js
@@ -118,14 +118,14 @@ export const getTargetPersonalization = async () => {
const responseStart = Date.now();
window.addEventListener(ALLOY_SEND_EVENT, () => {
const responseTime = calculateResponseTime(responseStart);
- window.lana.log(`target response time: ${responseTime}`, { tags: 'errorType=info,module=martech' });
+ window.lana.log(`target response time: ${responseTime}`, { tags: 'martech', errorType: 'i' });
}, { once: true });
let manifests = [];
let propositions = [];
const response = await waitForEventOrTimeout(ALLOY_SEND_EVENT, timeout);
if (response.error) {
- window.lana.log('target response time: ad blocker', { tags: 'errorType=info,module=martech' });
+ window.lana.log('target response time: ad blocker', { tags: 'martech', errorType: 'i' });
return [];
}
if (response.timeout) {
diff --git a/test/blocks/article-header/article-header.test.js b/test/blocks/article-header/article-header.test.js
index cbcf096c1f..7c0a20bd17 100644
--- a/test/blocks/article-header/article-header.test.js
+++ b/test/blocks/article-header/article-header.test.js
@@ -1,7 +1,6 @@
import { readFile } from '@web/test-runner-commands';
import { expect } from '@esm-bundle/chai';
-import sinon from 'sinon';
-
+import sinon, { stub } from 'sinon';
import { setConfig, getConfig } from '../../../libs/utils/utils.js';
import { delay, waitForElement } from '../../helpers/waitfor.js';
@@ -9,9 +8,11 @@ const locales = { '': { ietf: 'en-US', tk: 'hah7vzn.css' } };
const conf = { locales, miloLibs: 'http://localhost:2000/libs' };
setConfig(conf);
const config = getConfig();
+window.lana = { log: stub() };
document.body.innerHTML = await readFile({ path: './mocks/body.html' });
const { default: init } = await import('../../../libs/blocks/article-header/article-header.js');
+const { loadTaxonomy } = await import('../../../libs/blocks/article-feed/article-helpers.js');
const invalidDoc = await readFile({ path: './mocks/body-invalid.html' });
@@ -20,10 +21,20 @@ describe('article header', () => {
const block = document.body.querySelector('.article-header');
config.locale.contentRoot = '/test/blocks/article-header/mocks';
config.taxonomyRoot = undefined;
-
await init(block);
});
+ it('should log unknown topic', async () => {
+ try {
+ const div = document.createElement('div');
+ div.setAttribute('data-topic-link', ['abcd']);
+ document.body.append(div);
+ await loadTaxonomy();
+ expect(window.lana.log.args[0][0]).to.equal('Trying to get a link for an unknown topic: abcd (current page)');
+ } catch (e) {
+ console.log(e);
+ }
+ });
it('creates article header block', () => {
expect(document.body.querySelector('.article-category')).to.exist;
expect(document.body.querySelector('.article-title')).to.exist;
@@ -36,16 +47,16 @@ describe('article header', () => {
it('should open link popup when share links are clicked', () => {
// first share link is twitter
const shareLink = document.querySelector('.article-byline-sharing a');
- const stub = sinon.stub(window, 'open');
+ const windowStub = sinon.stub(window, 'open');
shareLink.click();
const url = encodeURIComponent(window.location.href);
const title = encodeURIComponent(document.querySelector('h1').textContent);
- expect(stub.calledOnce).to.be.true;
- expect(stub.firstCall.args[0]).to.equal(`https://www.twitter.com/share?&url=${url}&text=${title}`);
- expect(stub.firstCall.args[2]).to.equal('popup,top=233,left=233,width=700,height=467');
+ expect(windowStub.calledOnce).to.be.true;
+ expect(windowStub.firstCall.args[0]).to.equal(`https://www.twitter.com/share?&url=${url}&text=${title}`);
+ expect(windowStub.firstCall.args[2]).to.equal('popup,top=233,left=233,width=700,height=467');
- stub.restore();
+ windowStub.restore();
});
it('updates share text after deferred event', async () => {
@@ -111,7 +122,6 @@ describe('test the invalid article header', () => {
it('adds invalid-date when invalid date is provided', async () => {
await init(document.body.querySelector('.article-header'));
-
const date = await waitForElement('.article-date-invalid');
expect(date).to.exist;
});
diff --git a/test/blocks/global-footer/global-footer.test.js b/test/blocks/global-footer/global-footer.test.js
index d99e9868c5..3ab306b9ce 100644
--- a/test/blocks/global-footer/global-footer.test.js
+++ b/test/blocks/global-footer/global-footer.test.js
@@ -378,7 +378,7 @@ describe('global footer', () => {
await createFullGlobalFooter({ waitForDecoration: false });
await clock.runAllAsync();
expect(window.lana.log.getCalls().find((c) => c.args[0].includes('Failed to fetch footer content')));
- expect(window.lana.log.getCalls().find((c) => c.args[1].tags.includes('errorType=warn,module=global-footer')));
+ expect(window.lana.log.getCalls().find((c) => c.args[1].tags.includes('global-footer')));
});
it('should send log when could not create URL for region picker', async () => {
@@ -393,7 +393,7 @@ describe('global footer', () => {
// should throw error
}
expect(window.lana.log.getCalls().find((c) => c.args[0].includes('Could not create URL for region picker')));
- expect(window.lana.log.getCalls().find((c) => c.args[1].tags.includes('errorType=error,module=global-footer')));
+ expect(window.lana.log.getCalls().find((c) => c.args[1].tags.includes('global-footer')));
});
it('should send log when footer cannot be instantiated ', async () => {
@@ -401,7 +401,7 @@ describe('global footer', () => {
await createFullGlobalFooter({ waitForDecoration: false });
await clock.runAllAsync();
expect(window.lana.log.getCalls().find((c) => c.args[0].includes('Footer could not be instantiated')));
- expect(window.lana.log.getCalls().find((c) => c.args[1].tags.includes('errorType=error,module=global-footer')));
+ expect(window.lana.log.getCalls().find((c) => c.args[1].tags.includes('global-footer')));
});
it('should send LANA log when icons.svg has some network issue', async () => {
diff --git a/test/blocks/quiz-results/mocks/body.html b/test/blocks/quiz-results/mocks/body.html
index 7323de08ac..10823f4ee2 100644
--- a/test/blocks/quiz-results/mocks/body.html
+++ b/test/blocks/quiz-results/mocks/body.html
@@ -38,5 +38,15 @@
http://this-is-a-fake-redirect-url
+
+
+
nested-fragments
+
marquee-product
+
+
+
diff --git a/test/blocks/quiz-results/quiz-results.test.js b/test/blocks/quiz-results/quiz-results.test.js
index 37bb6b77b9..7b0b887cb3 100644
--- a/test/blocks/quiz-results/quiz-results.test.js
+++ b/test/blocks/quiz-results/quiz-results.test.js
@@ -76,4 +76,11 @@ describe('Quiz Results', () => {
expect(el.querySelector('.fragment > .section > .content').getAttribute('daa-lh')).to.equal('b1|content');
expect(el.querySelector('a').getAttribute('daa-ll')).to.equal('Fragment link-1--This is a basic frag');
});
+ it('should return misconfigured block', async () => {
+ const el = document.body.querySelector('.nested-three');
+ localStorage.setItem('misconf', JSON.stringify(mockData.mockTwo));
+ el.classList.remove('nested');
+ await init(el, 'quiz-results', 'misconf');
+ expect(window.lana.log.args[2][0]).to.equal(`${LOADING_ERROR} The quiz-results block is misconfigured`);
+ });
});
diff --git a/test/blocks/vimeo/vimeo.test.html b/test/blocks/vimeo/vimeo.test.html
index 50504a2436..8eb108eb54 100644
--- a/test/blocks/vimeo/vimeo.test.html
+++ b/test/blocks/vimeo/vimeo.test.html
@@ -15,9 +15,11 @@