Skip to content

Commit

Permalink
await the gnav init function
Browse files Browse the repository at this point in the history
  • Loading branch information
sharmrj committed Sep 26, 2024
1 parent 501a373 commit b436b7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
10 changes: 7 additions & 3 deletions test/blocks/global-navigation/test-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
Expand Down

0 comments on commit b436b7f

Please sign in to comment.