diff --git a/benefit-finder/cypress/e2e/storybook/dataLayer.cy.js b/benefit-finder/cypress/e2e/storybook/dataLayer.cy.js index f3747d88d..fa0fa38fc 100644 --- a/benefit-finder/cypress/e2e/storybook/dataLayer.cy.js +++ b/benefit-finder/cypress/e2e/storybook/dataLayer.cy.js @@ -217,11 +217,28 @@ describe('Calls to Google Analytics Object', function () { .button() .contains(EN_LOCALE_DATA.intro.button) .then(() => { - // get the last pushed event - const ev = { ...window.dataLayer[window.dataLayer.length - 1] } - removeID(ev) + cy.wait(wait).then(() => { + assert.isDefined( + window.dataLayer.find(x => x.event === 'gtm.load'), + 'GTM is done loading' + ) + assert.isDefined( + window.dataLayer.find(x => x.event === 'bf_page_change'), + 'bf_page_change is loaded' + ) - expect(ev).to.deep.equal(dataLayerValueIntro) + cy.wait(500).then(() => { + console.log(window.dataLayer) + // get the last pushed event + const bfEventIndex = window.dataLayer.findIndex( + x => x.event === 'bf_page_change' + ) + const ev = { ...window.dataLayer[bfEventIndex] } + removeID(ev) + + expect(ev).to.deep.equal(dataLayerValueIntro) + }) + }) }) }) }) diff --git a/usagov-2021 b/usagov-2021 index eb418375f..0ca782595 160000 --- a/usagov-2021 +++ b/usagov-2021 @@ -1 +1 @@ -Subproject commit eb418375f783b0dc9f8ab330f2ba0507242bc053 +Subproject commit 0ca782595d9f266ed0064025a531d19cc070bc78