From 464824377d8fbd98a588451eb4fb82e06cd433c6 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Mon, 3 Jun 2024 08:46:51 +0200 Subject: [PATCH] Update tests --- .idea/WooCommerce.iml | 4 +- .idea/phpunit.xml | 3 +- tests/Playwright/tests/Shared/products.js | 4 +- tests/Playwright/tests/Shared/wooUtils.js | 11 +++-- ..._payment_method_settings_surcharge.spec.js | 45 ++++++++++--------- ..._payment_statuses_-_block_checkout.spec.js | 4 +- .../Payment statuses - Checkout/testData.js | 4 +- .../testData.js | 4 +- 8 files changed, 41 insertions(+), 38 deletions(-) diff --git a/.idea/WooCommerce.iml b/.idea/WooCommerce.iml index 09827d3d..2a7a97c9 100644 --- a/.idea/WooCommerce.iml +++ b/.idea/WooCommerce.iml @@ -3,8 +3,6 @@ - - @@ -81,4 +79,4 @@ - + \ No newline at end of file diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml index 776785bf..32be0005 100644 --- a/.idea/phpunit.xml +++ b/.idea/phpunit.xml @@ -3,8 +3,9 @@ - + \ No newline at end of file diff --git a/tests/Playwright/tests/Shared/products.js b/tests/Playwright/tests/Shared/products.js index 7f039c5c..04c27c83 100644 --- a/tests/Playwright/tests/Shared/products.js +++ b/tests/Playwright/tests/Shared/products.js @@ -1,6 +1,6 @@ const allProducts = { surcharge: { - 'id': 14,//117, + 'id': 16,//117, "title": "Surcharge", 'link': '/product/surcharge/', 'sku': 'woo-surcharge', @@ -11,7 +11,7 @@ const allProducts = { 'downloadable': 'no', }, simple: { - 'id': 20,//11, + 'id': 15,//11, "title": "Beanie", 'link': '/product/beanie/', 'sku': 'woo-beanie', diff --git a/tests/Playwright/tests/Shared/wooUtils.js b/tests/Playwright/tests/Shared/wooUtils.js index 5a9119bd..4f14c696 100644 --- a/tests/Playwright/tests/Shared/wooUtils.js +++ b/tests/Playwright/tests/Shared/wooUtils.js @@ -60,11 +60,14 @@ const emptyCart = async (baseUrl) => { /** * @param {import('@playwright/test').Page} page */ -const fillCustomerInCheckoutBlock = async (page, country = 'Germany') => { - if(await page.getByText(country).first().isVisible()) { +const fillCustomerInCheckout = async (page, country = 'Germany') => { + const countryIsSet = await page.getByText(country).first().isVisible() + const canEdit = await page.getByText('Edit').first().isVisible(); + const isBlockCheckout = page.url().includes('checkout-block'); + if(isBlockCheckout && countryIsSet) { return; } - if (await page.getByText('Edit').isVisible()) { + if (isBlockCheckout && canEdit) { await page.getByText('Edit').click(); } await page.getByLabel('First name').first().fill('Julia'); @@ -232,7 +235,7 @@ const manualOrder = (productId, productQuantity, country, postcode) => { module.exports = { addProductToCart, - fillCustomerInCheckoutBlock, + fillCustomerInCheckoutBlock: fillCustomerInCheckout, gotoWooPaymentTab, placeOrderCheckout, emptyCart, diff --git a/tests/Playwright/tests/surcharge/_mollie_settings_tab_payment_method_settings_surcharge.spec.js b/tests/Playwright/tests/surcharge/_mollie_settings_tab_payment_method_settings_surcharge.spec.js index 738a7b5b..2d5bc455 100644 --- a/tests/Playwright/tests/surcharge/_mollie_settings_tab_payment_method_settings_surcharge.spec.js +++ b/tests/Playwright/tests/surcharge/_mollie_settings_tab_payment_method_settings_surcharge.spec.js @@ -1,7 +1,7 @@ const {test} = require('../Shared/base-test'); const {settingsNames, checkoutTransaction} = require('../Shared/mollieUtils'); const {addProductToCart, updateMethodSetting, selectPaymentMethodInCheckout, - captureTotalAmountCheckout, parseTotalAmount + captureTotalAmountCheckout, parseTotalAmount, emptyCart } = require("../Shared/wooUtils"); const {expect, webkit} = require("@playwright/test"); const {allMethods} = require("../Shared/gateways"); @@ -18,9 +18,9 @@ const testData = { 'totalExpectedAmount': 11.00, 'methods': { 'bancontact': 'C129502', - 'applepay': 'C420309', + //'applepay': 'C420309', 'belfius': 'C138011', - 'billie': 'C354664', + //'billie': 'C354664', 'eps': 'C133658', 'giropay': 'C136539', 'ideal': 'C130856', @@ -49,9 +49,9 @@ const testData = { 'totalExpectedAmount': 22.00, 'methods': { 'bancontact': 'C129503', - 'applepay': 'C420310', + //'applepay': 'C420310', 'belfius': 'C138012', - 'billie': 'C354665', + //'billie': 'C354665', 'eps': 'C133659', 'giropay': 'C136540', 'ideal': 'C130857', @@ -80,9 +80,9 @@ const testData = { 'totalExpectedAmount': 34.19, 'methods': { 'bancontact': 'C129504', - 'applepay': 'C420311', + //'applepay': 'C420311', 'belfius': 'C138013', - 'billie': 'C354666', + //'billie': 'C354666', 'eps': 'C133660', 'giropay': 'C136541', 'ideal': 'C130858', @@ -112,9 +112,9 @@ const testData = { 'totalExpectedAmount': 45.19, 'methods': { 'bancontact': 'C129505', - 'applepay': 'C420312', + //'applepay': 'C420312', 'belfius': 'C138014', - 'billie': 'C354667', + //'billie': 'C354667', 'eps': 'C133661', 'giropay': 'C136542', 'ideal': 'C130859', @@ -144,9 +144,9 @@ const testData = { 'totalExpectedAmount': 41.80, 'methods': { 'bancontact': 'C129506', - 'applepay': 'C420313', + //'applepay': 'C420313', 'belfius': 'C138015', - 'billie': 'C354668', + //'billie': 'C354668', 'eps': 'C133662', 'giropay': 'C136543', 'ideal': 'C130860', @@ -176,9 +176,9 @@ const testData = { 'totalExpectedAmount': 34.19, 'methods': { 'bancontact': 'C129507', - 'applepay': 'C420314', + //'applepay': 'C420314', 'belfius': 'C138016', - 'billie': 'C354669', + //'billie': 'C354669', 'eps': 'C133663', 'giropay': 'C136544', 'ideal': 'C130861', @@ -209,9 +209,9 @@ const testData = { 'totalExpectedAmount': 45.19, 'methods': { 'bancontact': 'C129508', - 'applepay': 'C420315', + //'applepay': 'C420315', 'belfius': 'C138017', - 'billie': 'C354670', + //'billie': 'C354670', 'eps': 'C133664', 'giropay': 'C136545', 'ideal': 'C130862', @@ -241,9 +241,9 @@ const testData = { 'totalExpectedAmount': 70.40, 'methods': { 'bancontact': 'C129509', - 'applepay': 'C420316', + //'applepay': 'C420316', 'belfius': 'C138018', - 'billie': 'C354671', + //'billie': 'C354671', 'eps': 'C133665', 'giropay': 'C136546', 'ideal': 'C130863', @@ -273,9 +273,9 @@ const testData = { 'totalExpectedAmount': 70.40, 'methods': { 'bancontact': 'C129510', - 'applepay': 'C420317', + //'applepay': 'C420317', 'belfius': 'C138019', - 'billie': 'C354672', + //'billie': 'C354672', 'eps': 'C133666', 'giropay': 'C137063', 'ideal': 'C130864', @@ -306,9 +306,9 @@ const testData = { 'totalExpectedAmount': 70.40, 'methods': { 'bancontact': 'C129511', - 'applepay': 'C420318', + //'applepay': 'C420318', 'belfius': 'C138020', - 'billie': 'C354673', + //'billie': 'C354673', 'eps': 'C133667', 'giropay': 'C137322', 'ideal': 'C130865', @@ -333,10 +333,11 @@ for (const [testAction, testActionData] of Object.entries(testData)) { test(testActionData.description(testId, methodName) , async ({page, products, baseURL}) => { await updateMethodSetting(methodName, testActionData.payload); if(!beforeAllRan) { - console.log(testActionData.productQuantity) + await emptyCart(baseURL); await addProductToCart(baseURL, products.surcharge.id, testActionData.productQuantity); const keys = Object.keys(testActionData.methods); randomMethod = keys[Math.floor(Math.random() * Object.entries(testActionData.methods).length)]; + console.log('randomMethod', randomMethod) beforeAllRan = true; } await page.goto('/checkout/'); diff --git a/tests/Playwright/tests/transaction/Payment statuses - Block Checkout/_transaction_scenarios_payment_statuses_-_block_checkout.spec.js b/tests/Playwright/tests/transaction/Payment statuses - Block Checkout/_transaction_scenarios_payment_statuses_-_block_checkout.spec.js index 91b299e7..97b7c11e 100644 --- a/tests/Playwright/tests/transaction/Payment statuses - Block Checkout/_transaction_scenarios_payment_statuses_-_block_checkout.spec.js +++ b/tests/Playwright/tests/transaction/Payment statuses - Block Checkout/_transaction_scenarios_payment_statuses_-_block_checkout.spec.js @@ -6,11 +6,11 @@ const {sharedUrl} = require("../../Shared/sharedUrl"); const {emptyCart, addProductToCart} = require("../../Shared/wooUtils"); const {testData} = require("./testData"); const {expect} = require("@playwright/test"); -test('basic test', async ({ page }) => { +/*test('basic test', async ({ page }) => { await page.goto('https://playwright.dev/'); const title = page.locator('.navbar__inner .navbar__title'); await expect(title).toHaveText('Playwright'); -}); +});*/ testData.forEach(({methodId, testId, mollieStatus, wooStatus, notice, action}) => { test.describe(`_Transaction scenarios_Payment statuses - Block Checkout - ${methodId}`, () => { let productQuantity = 1; diff --git a/tests/Playwright/tests/transaction/Payment statuses - Checkout/testData.js b/tests/Playwright/tests/transaction/Payment statuses - Checkout/testData.js index 23741fcc..e5f63468 100644 --- a/tests/Playwright/tests/transaction/Payment statuses - Checkout/testData.js +++ b/tests/Playwright/tests/transaction/Payment statuses - Checkout/testData.js @@ -91,7 +91,7 @@ export const testData = [ await checkExpiredAtMollie(page); } }, - { + /*{ methodId: "billie", testId: "C354674", mollieStatus: "Authorized", @@ -130,7 +130,7 @@ export const testData = [ action: async (page) => { await checkExpiredAtMollie(page); } - }, + },*/ { methodId: "eps", testId: "C3412", diff --git a/tests/Playwright/tests/transaction/Payment statuses - Pay for order page/testData.js b/tests/Playwright/tests/transaction/Payment statuses - Pay for order page/testData.js index 637754b6..3117920f 100644 --- a/tests/Playwright/tests/transaction/Payment statuses - Pay for order page/testData.js +++ b/tests/Playwright/tests/transaction/Payment statuses - Pay for order page/testData.js @@ -601,7 +601,7 @@ export const testData = [ await wooOrderRetryPage(page); } }, - { + /*{ methodId: "billie", testId: "C420413", mollieStatus: "Authorized", @@ -640,7 +640,7 @@ export const testData = [ action: async (page) => { await wooOrderRetryPage(page); } - }, + },*/ { methodId: "in3", testId: "C420334",