From 4d9b1f9e406d4cef5779645f2eb9be7b7e746b56 Mon Sep 17 00:00:00 2001 From: Ravinder Kumar Date: Mon, 18 Sep 2023 12:01:04 +0530 Subject: [PATCH] tests: add logic to delete all email logs and woocommerce logs --- tests/e2e/utils/index.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/e2e/utils/index.js b/tests/e2e/utils/index.js index f949d08..e949236 100644 --- a/tests/e2e/utils/index.js +++ b/tests/e2e/utils/index.js @@ -1,6 +1,7 @@ /** * Change the currency * + * @param {Page} page * @param {string} currency * @return {Promise} */ @@ -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 @@ -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' ); + } ); +}