From 1c3e0ae4573f6e6b3d1272564635ff9f8876ba30 Mon Sep 17 00:00:00 2001 From: vgoodric Date: Tue, 12 Mar 2024 00:32:48 -0600 Subject: [PATCH 1/2] change delimiter to --- --- libs/features/personalization/personalization.js | 3 ++- libs/features/personalization/preview.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index f5a4665d5d..ecf577c3a2 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -417,7 +417,7 @@ async function getPersonalizationVariant(manifestPath, variantNames = [], varian if (config.mep?.override) { let manifest; /* c8 ignore start */ - config.mep?.override?.split(',').some((item) => { + config.mep?.override?.split('---').some((item) => { const pair = item.trim().split('--'); if (pair[0] === manifestPath && pair.length > 1) { [, manifest] = pair; @@ -606,6 +606,7 @@ function compareExecutionOrder(a, b) { export function cleanAndSortManifestList(manifests) { const manifestObj = {}; manifests.forEach((manifest) => { + if (!manifest) return; manifest.manifestPath = normalizePath(manifest.manifestUrl || manifest.manifest); if (manifest.manifestPath in manifestObj) { let fullManifest = manifestObj[manifest.manifestPath]; diff --git a/libs/features/personalization/preview.js b/libs/features/personalization/preview.js index c17923241c..054bfb4027 100644 --- a/libs/features/personalization/preview.js +++ b/libs/features/personalization/preview.js @@ -28,7 +28,7 @@ function updatePreviewButton() { }); const simulateHref = new URL(window.location.href); - simulateHref.searchParams.set('mep', manifestParameter.join(',')); + simulateHref.searchParams.set('mep', manifestParameter.join('---')); const mepHighlightCheckbox = document.querySelector( '.mep-popup input[type="checkbox"]#mepHighlightCheckbox', From e8cd3029ad275aa4577dbf017d0349876e4fe9a6 Mon Sep 17 00:00:00 2001 From: vgoodric Date: Tue, 12 Mar 2024 01:01:00 -0600 Subject: [PATCH 2/2] update unit tests --- libs/features/personalization/preview.js | 2 +- test/features/personalization/preview.test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/features/personalization/preview.js b/libs/features/personalization/preview.js index 054bfb4027..2fe0e790fe 100644 --- a/libs/features/personalization/preview.js +++ b/libs/features/personalization/preview.js @@ -203,7 +203,7 @@ function createPreviewPill(manifests) { const personalizationOn = getMetadata('personalization'); const personalizationOnText = personalizationOn && personalizationOn !== '' ? 'on' : 'off'; const simulateHref = new URL(window.location.href); - simulateHref.searchParams.set('manifest', manifestParameter.join(',')); + simulateHref.searchParams.set('manifest', manifestParameter.join('---')); const config = getConfig(); let mepHighlightChecked = ''; diff --git a/test/features/personalization/preview.test.js b/test/features/personalization/preview.test.js index b3b9b13c70..51feed86e1 100644 --- a/test/features/personalization/preview.test.js +++ b/test/features/personalization/preview.test.js @@ -185,6 +185,7 @@ describe('preview feature', () => { expect(document.querySelector('input#mepHighlightCheckbox').getAttribute('checked')).to.equal('checked'); }); it('updates preview button', () => { + expect(document.querySelector('a[title="Preview above choices"]').getAttribute('href')).to.contain('---'); document.querySelector('#new-manifest').value = 'https://main--homepage--adobecom.hlx.live/homepage/fragments/mep/new-manifest.json'; document.querySelector('input[name="/homepage/fragments/mep/selected-example.json"][value="default"]').click(); expect(document.querySelector('a[title="Preview above choices"]').getAttribute('href')).to.contain('new-manifest.json'); @@ -193,6 +194,7 @@ describe('preview feature', () => { expect(document.querySelector('a[title="Preview above choices"]').getAttribute('href')).to.not.contain('mepHighlight'); document.querySelector('input#mepPreviewButtonCheckbox').click(); expect(document.querySelector('a[title="Preview above choices"]').getAttribute('href')).to.contain('mepButton=off'); + expect(document.querySelector('a[title="Preview above choices"]').getAttribute('href')).to.contain('---'); }); it('opens manifest', () => { document.querySelector('a.mep-edit-manifest').click();