Skip to content

Commit

Permalink
tests: add logic to delete all email logs and woocommerce logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinderk committed Sep 18, 2023
1 parent 2ddddb3 commit 4d9b1f9
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/e2e/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Change the currency
*
* @param {Page} page
* @param {string} currency
* @return {Promise<void>}
*/
Expand Down Expand Up @@ -83,7 +84,7 @@ export async function editPayfastSetting( {page, settings} ) {
const submitButtonLocator = await page.locator( 'text=Save changes' );
await submitButtonLocator.click();
await waitForURLPromise;
};
}

/**
* Add a product to cart
Expand All @@ -96,3 +97,27 @@ export async function addProductToCart( {page, productUrl} ) {
await page.goto( productUrl );
await page.click( 'text=Add to cart' );
}

/**
* Clear email Logs
*
* @param {Page} page
*/
export async function clearEmailLogs( {page} ) {
// Send fetch request to clear email logs.
await page.evaluate( () => {
return fetch( '/wp-json/e2e-wc/v1/flush-all-emails' );
} );
}

/**
* Clear WooCommerce Logs
*
* @param {Page} page
*/
export async function clearWooCommerceLogs( {page} ) {
// Send fetch request to clear email logs.
await page.evaluate( () => {
return fetch( '/wp-json/e2e-wc/v1/flush-all-logs' );
} );
}

0 comments on commit 4d9b1f9

Please sign in to comment.