Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
kt-12 committed Oct 28, 2024
1 parent 30237f3 commit 65972ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ test.describe( 'Product Feed Page', () => {

test.describe( 'Has campaign', () => {
test.beforeAll( async () => {
await productFeedPage.mockAdsSetupComplete();
await productFeedPage.fulfillAdsCampaignsRequest( [
{
id: 111111111,
Expand Down
24 changes: 23 additions & 1 deletion tests/e2e/utils/pages/product-feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ export default class ProductFeedPage extends MockRequests {
] );
}

/**
* Change the value of adsSetupComplete to `true` after it is discovered.
*
* @return {Promise<void>}
*/
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.
*
Expand Down Expand Up @@ -99,7 +121,7 @@ export default class ProductFeedPage extends MockRequests {
* @return {Promise<import('@playwright/test').Locator>} 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.',
} );
Expand Down

0 comments on commit 65972ac

Please sign in to comment.