From 6d9e9ef3df57c52a4a7bb02887326af6e31f2eab Mon Sep 17 00:00:00 2001 From: markpadbe Date: Tue, 4 Feb 2025 14:00:36 -0800 Subject: [PATCH 1/6] Add ajo integration --- .../personalization/personalization.js | 79 ++++++++++--------- libs/martech/martech.js | 35 ++++---- libs/utils/utils.js | 17 ++-- 3 files changed, 74 insertions(+), 57 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index eea9bd2caa..d4448afb96 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -1141,28 +1141,28 @@ export const combineMepSources = async (persEnabled, promoEnabled, mepParam) => }; async function updateManifestsAndPropositions( - { config, targetManifests, targetPropositions }, + { config, targetAjoManifests, targetAjoPropositions }, ) { - targetManifests.forEach((manifest) => { - manifest.source = ['target']; + targetAjoManifests.forEach((manifest) => { + manifest.source = [config.mep.ajoEnabled ? 'ajo' : 'target']; }); - config.mep.targetManifests = targetManifests; + config.mep.targetAjoManifests = targetAjoManifests; if (config.mep.enablePersV2) { if (!config.mep.hybridPersEnabled) { window.addEventListener('alloy_sendEvent', () => { - if (targetPropositions?.length && window._satellite) { - window._satellite.track('propositionDisplay', targetPropositions); + if (targetAjoPropositions?.length && window._satellite) { + window._satellite.track('propositionDisplay', targetAjoPropositions); } }, { once: true }); } - } else if (targetPropositions?.length && window._satellite) { - window._satellite.track('propositionDisplay', targetPropositions); + } else if (targetAjoPropositions?.length && window._satellite) { + window._satellite.track('propositionDisplay', targetAjoPropositions); } if (config.mep.targetEnabled === 'postlcp') { const event = new CustomEvent(MARTECH_RETURNED_EVENT, { detail: 'Martech returned' }); window.dispatchEvent(event); } - return targetManifests; + return targetAjoManifests; } function roundToQuarter(num) { @@ -1201,65 +1201,71 @@ function sendTargetResponseAnalytics(failure, responseStart, timeoutLocal, messa } const handleAlloyResponse = (response) => ((response.propositions || response.decisions)) - ?.map((i) => i.items) + ?.map((i) => { + const { id } = i; + return i.items.map((item) => ({ ...item, id })); + }) ?.flat() ?.map((item) => { const content = item?.data?.content; if (!content || !(content.manifestLocation || content.manifestContent)) return null; - return { manifestPath: content.manifestLocation || content.manifestPath, manifestUrl: content.manifestLocation, manifestData: content.manifestContent?.experiences?.data || content.manifestContent?.data, manifestPlaceholders: content.manifestContent?.placeholders?.data, manifestInfo: content.manifestContent?.info.data, - name: item.meta['activity.name'], - variantLabel: item.meta['experience.name'] && `target-${item.meta['experience.name']}`, + name: item.meta?.['activity.name'] || item.id, + variantLabel: (item.meta?.['experience.name'] && `target-${item.meta['experience.name']}`) + || content.experienceName, meta: item.meta, }; }) ?.filter(Boolean) ?? []; async function handleMartechTargetInteraction( - { config, targetInteractionPromise, calculatedTimeout }, + { config, targetAjoInteractionPromise, calculatedTimeout }, ) { - let targetManifests = []; - let targetPropositions = []; - if (config?.mep?.enablePersV2 && targetInteractionPromise) { - const { targetInteractionData, respTime, respStartTime } = await targetInteractionPromise; + const targetAjo = config.mep.ajoEnabled ? 'ajo' : 'target'; + let targetAjoManifests = []; + let targetAjoPropositions = []; + if (config?.mep?.enablePersV2 && targetAjoInteractionPromise) { + const { targetAjoInteractionData, respTime, respStartTime } = await targetAjoInteractionPromise; sendTargetResponseAnalytics(false, respStartTime, calculatedTimeout); - if (targetInteractionData.result) { + if (targetAjoInteractionData.result) { const roundedResponseTime = roundToQuarter(respTime); performance.clearMarks(); performance.clearMeasures(); try { - window.lana.log(`target response time: ${roundedResponseTime}`, { + window.lana.log(`${targetAjo} response time: ${roundedResponseTime}`, { tags: 'martech', errorType: 'e', sampleRate: 0.5, }); } catch (e) { // eslint-disable-next-line no-console - console.error('Error logging target response time:', e); + console.error(`Error logging ${targetAjo} response time:`, e); } - targetManifests = handleAlloyResponse(targetInteractionData.result); - targetPropositions = targetInteractionData.result?.propositions || []; + targetAjoManifests = handleAlloyResponse(targetAjoInteractionData.result); + targetAjoPropositions = targetAjoInteractionData.result?.propositions || []; } } return updateManifestsAndPropositions( - { config, targetManifests, targetPropositions }, + { config, targetAjoManifests, targetAjoPropositions }, ); } async function callMartech(config) { - const { getTargetPersonalization } = await import('../../martech/martech.js'); + const { getTargetAjoPersonalization } = await import('../../martech/martech.js'); const { - targetManifests, - targetPropositions, - } = await getTargetPersonalization({ handleAlloyResponse, sendTargetResponseAnalytics }); + targetAjoManifests, + targetAjoPropositions, + } = await getTargetAjoPersonalization( + { handleAlloyResponse, config, sendTargetResponseAnalytics }, + ); return updateManifestsAndPropositions( - { config, targetManifests, targetPropositions }, + { config, targetAjoManifests, targetAjoPropositions }, ); } @@ -1272,7 +1278,7 @@ export async function init(enablements = {}) { let manifests = []; const { mepParam, mepHighlight, mepButton, pzn, promo, enablePersV2, hybridPersEnabled, - target, targetInteractionPromise, calculatedTimeout, postLCP, + target, ajo, targetAjoInteractionPromise, calculatedTimeout, postLCP, } = enablements; const config = getConfig(); if (postLCP) { @@ -1285,6 +1291,7 @@ export async function init(enablements = {}) { variantOverride: parseMepParam(mepParam), highlight: (mepHighlight !== undefined && mepHighlight !== 'false'), targetEnabled: target, + ajoEnabled: ajo, experiments: [], prefix: config.locale?.prefix.split('/')[1]?.toLowerCase() || US_GEO, enablePersV2, @@ -1299,17 +1306,17 @@ export async function init(enablements = {}) { if (pzn) loadLink(getXLGListURL(config), { as: 'fetch', crossorigin: 'anonymous', rel: 'preload' }); } - if (enablePersV2 && target === true) { + if (enablePersV2 && (target === true || ajo === true)) { manifests = manifests.concat(await handleMartechTargetInteraction( - { config, targetInteractionPromise, calculatedTimeout }, + { config, targetAjoInteractionPromise, calculatedTimeout }, )); } else { - if (target === true) manifests = manifests.concat(await callMartech(config)); - if (target === 'postlcp') callMartech(config); + if (target === true || ajo === true) manifests = manifests.concat(await callMartech(config)); + if (target === 'postlcp' || ajo === 'postlcp') callMartech(config); } if (postLCP) { - if (!config.mep.targetManifests) await awaitMartech(); - manifests = config.mep.targetManifests; + if (!config.mep.targetAjoManifests) await awaitMartech(); + manifests = config.mep.targetAjoManifests; } try { if (manifests?.length) await applyPers({ manifests }); diff --git a/libs/martech/martech.js b/libs/martech/martech.js index a1bb1d0958..e51050ceb6 100644 --- a/libs/martech/martech.js +++ b/libs/martech/martech.js @@ -2,6 +2,7 @@ import { getConfig, loadIms, loadLink, loadScript, getMepEnablement, getMetadata, } from '../utils/utils.js'; +const ALLOY_PROPOSITION_FETCH = 'alloy_propositionFetch'; const ALLOY_SEND_EVENT = 'alloy_sendEvent'; const ALLOY_SEND_EVENT_ERROR = 'alloy_sendEvent_error'; const ENTITLEMENT_TIMEOUT = 3000; @@ -49,8 +50,10 @@ const waitForEventOrTimeout = (eventName, timeoutLocal, returnValIfTimeout) => n } }, timeoutLocal); + const eventError = eventName + === ALLOY_SEND_EVENT ? ALLOY_SEND_EVENT_ERROR : ALLOY_PROPOSITION_FETCH; window.addEventListener(eventName, listener, { once: true }); - window.addEventListener(ALLOY_SEND_EVENT_ERROR, errorListener, { once: true }); + window.addEventListener(eventError, errorListener, { once: true }); }); function roundToQuarter(num) { @@ -62,11 +65,14 @@ function calculateResponseTime(responseStart) { return roundToQuarter(responseTime); } -export const getTargetPersonalization = async ( - { handleAlloyResponse, sendTargetResponseAnalytics }, +export const getTargetAjoPersonalization = async ( + { handleAlloyResponse, config, sendTargetResponseAnalytics }, ) => { const responseStart = Date.now(); - window.addEventListener(ALLOY_SEND_EVENT, () => { + const ajo = config.mep.ajoEnabled; + const eventName = ajo ? ALLOY_PROPOSITION_FETCH : ALLOY_SEND_EVENT; + const targetAjo = ajo ? 'ajo' : 'target'; + window.addEventListener(eventName, () => { const responseTime = calculateResponseTime(responseStart); try { window.lana.log(`target response time: ${responseTime}`, { @@ -80,33 +86,34 @@ export const getTargetPersonalization = async ( } }, { once: true }); - let targetManifests = []; - let targetPropositions = []; + let targetAjoManifests = []; + let targetAjoPropositions = []; + + const response = await waitForEventOrTimeout(eventName, timeout); - const response = await waitForEventOrTimeout(ALLOY_SEND_EVENT, timeout); if (response.error) { try { - window.lana.log('target response time: ad blocker', { + window.lana.log(`${targetAjo} response time: ad blocker`, { tags: 'martech', errorType: 'e', sampleRate: 0.5, }); } catch (e) { // eslint-disable-next-line no-console - console.error('Error logging target response time for ad blocker:', e); + console.error(`Error logging ${targetAjo} response time for ad blocker:`, e); } - return { targetManifests, targetPropositions }; + return { targetAjoManifests, targetAjoPropositions }; } if (response.timeout) { - waitForEventOrTimeout(ALLOY_SEND_EVENT, 5100 - timeout) + waitForEventOrTimeout(eventName, 5100 - timeout) .then(() => sendTargetResponseAnalytics(true, responseStart, timeout)); } else { sendTargetResponseAnalytics(false, responseStart, timeout); - targetManifests = handleAlloyResponse(response.result); - targetPropositions = response.result?.propositions || []; + targetAjoManifests = handleAlloyResponse(response.result); + targetAjoPropositions = response.result?.propositions || []; } - return { targetManifests, targetPropositions }; + return { targetAjoManifests, targetAjoPropositions }; }; const setupEntitlementCallback = () => { diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 63411d2291..cf474301e8 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -1119,27 +1119,29 @@ async function checkForPageMods() { mepButton, martech, } = Object.fromEntries(PAGE_URL.searchParams); - let targetInteractionPromise = null; + let targetAjoInteractionPromise = null; let calculatedTimeout = null; if (mepParam === 'off') return; const pzn = getMepEnablement('personalization'); const promo = getMepEnablement('manifestnames', PROMO_PARAM); const target = martech === 'off' ? false : getMepEnablement('target'); const xlg = martech === 'off' ? false : getMepEnablement('xlg'); + const isPOC = (document.title === '404' && window.location.pathname === '/products/photoshop/123.html'); + const ajo = martech === 'off' ? false : isPOC || getMepEnablement('ajo'); if (!(pzn || target || promo || mepParam - || mepHighlight || mepButton || mepParam === '' || xlg)) return; + || mepHighlight || mepButton || mepParam === '' || xlg || ajo)) return; const enablePersV2 = enablePersonalizationV2(); const hybridPersEnabled = getMepEnablement('hybrid-pers'); - if ((target || xlg) && enablePersV2) { + if ((target || xlg || ajo) && enablePersV2) { const params = new URL(window.location.href).searchParams; calculatedTimeout = parseInt(params.get('target-timeout'), 10) || parseInt(getMetadata('target-timeout'), 10) || TARGET_TIMEOUT_MS; const { locale } = getConfig(); - targetInteractionPromise = (async () => { + targetAjoInteractionPromise = (async () => { const { loadAnalyticsAndInteractionData } = await import('../martech/helpers.js'); const now = performance.now(); performance.mark('interaction-start'); @@ -1150,9 +1152,9 @@ async function checkForPageMods() { performance.measure('total-time', 'interaction-start', 'interaction-end'); const respTime = performance.getEntriesByName('total-time')[0]; - return { targetInteractionData: data, respTime, respStartTime: now }; + return { targetAjoInteractionData: data, respTime, respStartTime: now }; })(); - } else if ((target || xlg) && !isMartechLoaded) loadMartech(); + } else if ((target || xlg || ajo) && !isMartechLoaded) loadMartech(); else if (pzn && martech !== 'off') { loadIms() .then(() => { @@ -1170,7 +1172,8 @@ async function checkForPageMods() { pzn, promo, target, - targetInteractionPromise, + ajo, + targetAjoInteractionPromise, calculatedTimeout, enablePersV2, hybridPersEnabled, From 453306de9c8b06f9bdfd89ddf5589d87aa46d4dc Mon Sep 17 00:00:00 2001 From: markpadbe Date: Wed, 19 Feb 2025 13:19:57 -0800 Subject: [PATCH 2/6] Remove AJO references from pznv2 for now --- libs/features/personalization/personalization.js | 16 ++++++++-------- libs/utils/utils.js | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index d4448afb96..cff7c7cce2 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -1224,15 +1224,15 @@ const handleAlloyResponse = (response) => ((response.propositions || response.de ?.filter(Boolean) ?? []; async function handleMartechTargetInteraction( - { config, targetAjoInteractionPromise, calculatedTimeout }, + { config, targetInteractionPromise, calculatedTimeout }, ) { const targetAjo = config.mep.ajoEnabled ? 'ajo' : 'target'; let targetAjoManifests = []; let targetAjoPropositions = []; - if (config?.mep?.enablePersV2 && targetAjoInteractionPromise) { - const { targetAjoInteractionData, respTime, respStartTime } = await targetAjoInteractionPromise; + if (config?.mep?.enablePersV2 && targetInteractionPromise) { + const { targetInteractionData, respTime, respStartTime } = await targetInteractionPromise; sendTargetResponseAnalytics(false, respStartTime, calculatedTimeout); - if (targetAjoInteractionData.result) { + if (targetInteractionData.result) { const roundedResponseTime = roundToQuarter(respTime); performance.clearMarks(); performance.clearMeasures(); @@ -1246,8 +1246,8 @@ async function handleMartechTargetInteraction( // eslint-disable-next-line no-console console.error(`Error logging ${targetAjo} response time:`, e); } - targetAjoManifests = handleAlloyResponse(targetAjoInteractionData.result); - targetAjoPropositions = targetAjoInteractionData.result?.propositions || []; + targetAjoManifests = handleAlloyResponse(targetInteractionData.result); + targetAjoPropositions = targetInteractionData.result?.propositions || []; } } @@ -1278,7 +1278,7 @@ export async function init(enablements = {}) { let manifests = []; const { mepParam, mepHighlight, mepButton, pzn, promo, enablePersV2, hybridPersEnabled, - target, ajo, targetAjoInteractionPromise, calculatedTimeout, postLCP, + target, ajo, targetInteractionPromise, calculatedTimeout, postLCP, } = enablements; const config = getConfig(); if (postLCP) { @@ -1308,7 +1308,7 @@ export async function init(enablements = {}) { if (enablePersV2 && (target === true || ajo === true)) { manifests = manifests.concat(await handleMartechTargetInteraction( - { config, targetAjoInteractionPromise, calculatedTimeout }, + { config, targetInteractionPromise, calculatedTimeout }, )); } else { if (target === true || ajo === true) manifests = manifests.concat(await callMartech(config)); diff --git a/libs/utils/utils.js b/libs/utils/utils.js index cf474301e8..6e2d435664 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -1119,7 +1119,7 @@ async function checkForPageMods() { mepButton, martech, } = Object.fromEntries(PAGE_URL.searchParams); - let targetAjoInteractionPromise = null; + let targetInteractionPromise = null; let calculatedTimeout = null; if (mepParam === 'off') return; const pzn = getMepEnablement('personalization'); @@ -1134,14 +1134,14 @@ async function checkForPageMods() { const enablePersV2 = enablePersonalizationV2(); const hybridPersEnabled = getMepEnablement('hybrid-pers'); - if ((target || xlg || ajo) && enablePersV2) { + if ((target || xlg) && enablePersV2) { const params = new URL(window.location.href).searchParams; calculatedTimeout = parseInt(params.get('target-timeout'), 10) || parseInt(getMetadata('target-timeout'), 10) || TARGET_TIMEOUT_MS; const { locale } = getConfig(); - targetAjoInteractionPromise = (async () => { + targetInteractionPromise = (async () => { const { loadAnalyticsAndInteractionData } = await import('../martech/helpers.js'); const now = performance.now(); performance.mark('interaction-start'); @@ -1152,7 +1152,7 @@ async function checkForPageMods() { performance.measure('total-time', 'interaction-start', 'interaction-end'); const respTime = performance.getEntriesByName('total-time')[0]; - return { targetAjoInteractionData: data, respTime, respStartTime: now }; + return { targetInteractionData: data, respTime, respStartTime: now }; })(); } else if ((target || xlg || ajo) && !isMartechLoaded) loadMartech(); else if (pzn && martech !== 'off') { @@ -1173,7 +1173,7 @@ async function checkForPageMods() { promo, target, ajo, - targetAjoInteractionPromise, + targetInteractionPromise, calculatedTimeout, enablePersV2, hybridPersEnabled, From e6a3e2e79823b8dfd5042446698438df3106157a Mon Sep 17 00:00:00 2001 From: markpadbe Date: Wed, 19 Feb 2025 14:54:56 -0800 Subject: [PATCH 3/6] Remove another ajo reference --- libs/features/personalization/personalization.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index cff7c7cce2..2cf76f541c 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -1306,7 +1306,7 @@ export async function init(enablements = {}) { if (pzn) loadLink(getXLGListURL(config), { as: 'fetch', crossorigin: 'anonymous', rel: 'preload' }); } - if (enablePersV2 && (target === true || ajo === true)) { + if (enablePersV2 && (target === true)) { manifests = manifests.concat(await handleMartechTargetInteraction( { config, targetInteractionPromise, calculatedTimeout }, )); From 4bf24be62c823ee3e68a970bf39a4c13ef7d1b61 Mon Sep 17 00:00:00 2001 From: markpadbe Date: Wed, 19 Feb 2025 14:58:27 -0800 Subject: [PATCH 4/6] revert formatting --- libs/features/personalization/personalization.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 2cf76f541c..da5bc39553 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -1306,7 +1306,7 @@ export async function init(enablements = {}) { if (pzn) loadLink(getXLGListURL(config), { as: 'fetch', crossorigin: 'anonymous', rel: 'preload' }); } - if (enablePersV2 && (target === true)) { + if (enablePersV2 && target === true) { manifests = manifests.concat(await handleMartechTargetInteraction( { config, targetInteractionPromise, calculatedTimeout }, )); From 147b7db21d7ea8c2eea419f188c5947fa6fdf376 Mon Sep 17 00:00:00 2001 From: markpadbe Date: Mon, 24 Feb 2025 10:03:03 -0800 Subject: [PATCH 5/6] Remove hard-coded url --- libs/utils/utils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index a7b1c2460b..33bedc3ca9 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -1184,8 +1184,7 @@ async function checkForPageMods() { const promo = getMepEnablement('manifestnames', PROMO_PARAM); const target = martech === 'off' ? false : getMepEnablement('target'); const xlg = martech === 'off' ? false : getMepEnablement('xlg'); - const isPOC = (document.title === '404' && window.location.pathname === '/products/photoshop/123.html'); - const ajo = martech === 'off' ? false : isPOC || getMepEnablement('ajo'); + const ajo = martech === 'off' ? false : getMepEnablement('ajo'); if (!(pzn || target || promo || mepParam || mepHighlight || mepButton || mepParam === '' || xlg || ajo)) return; From aca09e6930a29b6112dd18010a493da968796337 Mon Sep 17 00:00:00 2001 From: markpadbe Date: Mon, 24 Feb 2025 11:35:07 -0800 Subject: [PATCH 6/6] Add tests for enabling ajo --- test/utils/mocks/mep/head-ajo-off.html | 4 ++++ test/utils/mocks/mep/head-ajo-on.html | 4 ++++ test/utils/mocks/mep/head-ajo-postlcp.html | 3 +++ test/utils/utils-mep-with-params.test.js | 2 ++ test/utils/utils-mep.test.js | 19 +++++++++++++++++-- 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/utils/mocks/mep/head-ajo-off.html create mode 100644 test/utils/mocks/mep/head-ajo-on.html create mode 100644 test/utils/mocks/mep/head-ajo-postlcp.html diff --git a/test/utils/mocks/mep/head-ajo-off.html b/test/utils/mocks/mep/head-ajo-off.html new file mode 100644 index 0000000000..b16aa329c1 --- /dev/null +++ b/test/utils/mocks/mep/head-ajo-off.html @@ -0,0 +1,4 @@ + +Document Title + + diff --git a/test/utils/mocks/mep/head-ajo-on.html b/test/utils/mocks/mep/head-ajo-on.html new file mode 100644 index 0000000000..d159abd762 --- /dev/null +++ b/test/utils/mocks/mep/head-ajo-on.html @@ -0,0 +1,4 @@ + +Document Title + + diff --git a/test/utils/mocks/mep/head-ajo-postlcp.html b/test/utils/mocks/mep/head-ajo-postlcp.html new file mode 100644 index 0000000000..d1546ed7c0 --- /dev/null +++ b/test/utils/mocks/mep/head-ajo-postlcp.html @@ -0,0 +1,3 @@ + +Document Title + diff --git a/test/utils/utils-mep-with-params.test.js b/test/utils/utils-mep-with-params.test.js index 8eb2fa0795..12a82797e4 100644 --- a/test/utils/utils-mep-with-params.test.js +++ b/test/utils/utils-mep-with-params.test.js @@ -11,9 +11,11 @@ describe('MEP Utils', () => { setTimeout(() => { const persEnabled = getMepEnablement('personalization'); const promoEnabled = getMepEnablement('manifestnames', 'promo'); + const ajoEnabled = getMepEnablement('ajo'); const targetEnabled = getMepEnablement('target'); expect(promoEnabled).to.equal(false); expect(persEnabled).to.equal(false); + expect(ajoEnabled).to.equal(false); expect(targetEnabled).to.equal('postlcp'); }, 1000); }); diff --git a/test/utils/utils-mep.test.js b/test/utils/utils-mep.test.js index 8b161acb5e..7e284573c9 100644 --- a/test/utils/utils-mep.test.js +++ b/test/utils/utils-mep.test.js @@ -33,12 +33,12 @@ describe('MEP Utils', () => { }); }); describe('getMepEnablement', async () => { - it('checks target metadata set to off', async () => { + it('checks target metadata set to on', async () => { document.head.innerHTML = await readFile({ path: './mocks/mep/head-target-on.html' }); const targetEnabled = getMepEnablement('target'); expect(targetEnabled).to.equal(true); }); - it('checks target metadata set to on', async () => { + it('checks target metadata set to off', async () => { document.head.innerHTML = await readFile({ path: './mocks/mep/head-target-off.html' }); const targetEnabled = getMepEnablement('target'); expect(targetEnabled).to.equal(false); @@ -48,6 +48,21 @@ describe('MEP Utils', () => { const targetEnabled = getMepEnablement('target'); expect(targetEnabled).to.equal('postlcp'); }); + it('checks ajo metadata set to on', async () => { + document.head.innerHTML = await readFile({ path: './mocks/mep/head-ajo-on.html' }); + const ajoEnabled = getMepEnablement('ajo'); + expect(ajoEnabled).to.equal(true); + }); + it('checks ajo metadata set to off', async () => { + document.head.innerHTML = await readFile({ path: './mocks/mep/head-ajo-off.html' }); + const ajoEnabled = getMepEnablement('ajo'); + expect(ajoEnabled).to.equal(false); + }); + it('checks ajo metadata set to postlcp', async () => { + document.head.innerHTML = await readFile({ path: './mocks/mep/head-ajo-postlcp.html' }); + const ajoEnabled = getMepEnablement('ajo'); + expect(ajoEnabled).to.equal('postlcp'); + }); it('checks from just metadata with no target metadata', async () => { document.head.innerHTML = await readFile({ path: './mocks/mep/head-promo.html' }); const persEnabled = getMepEnablement('personalization');