diff --git a/tests/e2e/specs/product-feed/product-feed-campaign-notice.test.js b/tests/e2e/specs/product-feed/product-feed-campaign-notice.test.js index 9b84fdbc86..db417331f4 100644 --- a/tests/e2e/specs/product-feed/product-feed-campaign-notice.test.js +++ b/tests/e2e/specs/product-feed/product-feed-campaign-notice.test.js @@ -144,6 +144,7 @@ test.describe( 'Product Feed Page', () => { test.describe( 'Has campaign', () => { test.beforeAll( async () => { + await productFeedPage.mockAdsSetupComplete(); await productFeedPage.fulfillAdsCampaignsRequest( [ { id: 111111111, diff --git a/tests/e2e/utils/pages/product-feed.js b/tests/e2e/utils/pages/product-feed.js index 2463630e18..6d07395c45 100644 --- a/tests/e2e/utils/pages/product-feed.js +++ b/tests/e2e/utils/pages/product-feed.js @@ -68,6 +68,28 @@ export default class ProductFeedPage extends MockRequests { ] ); } + /** + * Change the value of adsSetupComplete to `true` after it is discovered. + * + * @return {Promise} + */ + async mockAdsSetupComplete() { + this.page.addInitScript( () => { + const targetId = 'google-listings-and-ads-js-before'; + const checkElement = () => { + const targetElement = document.getElementById( targetId ); + if ( targetElement ) { + window.glaData = window.glaData || {}; + window.glaData.adsSetupComplete = true; + } else { + // If not, keep checking until targetElement exists + window.requestAnimationFrame( checkElement ); + } + }; + checkElement(); + } ); + } + /** * Get the active product value element. * @@ -99,7 +121,7 @@ export default class ProductFeedPage extends MockRequests { * @return {Promise} The campaign notice section. */ async getCampaignNoticeSection() { - return this.page.locator( '.components-notice__content' ).filter( { + return this.page.locator( '.gla-ads-inline-notice' ).filter( { hasText: 'You have approved products. Create a Google Ads campaign to reach more customers and drive more sales.', } );