diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index 9126740c39..fe4b4aaabe 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -1045,7 +1045,7 @@ export default async function init(block) { content, block, }); - gnav.init(); + await gnav.init(); block.setAttribute('daa-im', 'true'); const mepMartech = mep?.martech || ''; block.setAttribute('daa-lh', `gnav|${getExperienceName()}${mepMartech}`); diff --git a/test/blocks/global-navigation/test-utilities.js b/test/blocks/global-navigation/test-utilities.js index 9e38a606b8..c6110f63ee 100644 --- a/test/blocks/global-navigation/test-utilities.js +++ b/test/blocks/global-navigation/test-utilities.js @@ -214,9 +214,12 @@ export const createFullGlobalNavigation = async ({ ), ]); - const instance = await initGnav(document.body.querySelector('header')); - instance.imsReady(); - await clock.runAllAsync(); + const instancePromise = initGnav(document.body.querySelector('header')); + + await clock.runToLastAsync(); + const instance = await instancePromise; + const imsPromise = instance.imsReady(); + await clock.runToLastAsync(); // We restore the clock here, because waitForElement uses setTimeout clock.restore(); @@ -241,6 +244,7 @@ export const createFullGlobalNavigation = async ({ waitForElements.push(waitForElement(selectors.breadcrumbsWrapper, document.body)); } await Promise.all(waitForElements); + await imsPromise; window.fetch = ogFetch; window.adobeIMS = undefined;