Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Jun 3, 2024
1 parent 7b926bf commit 4648243
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 38 deletions.
4 changes: 1 addition & 3 deletions .idea/WooCommerce.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/phpunit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/Playwright/tests/Shared/products.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const allProducts = {
surcharge: {
'id': 14,//117,
'id': 16,//117,
"title": "Surcharge",
'link': '/product/surcharge/',
'sku': 'woo-surcharge',
Expand All @@ -11,7 +11,7 @@ const allProducts = {
'downloadable': 'no',
},
simple: {
'id': 20,//11,
'id': 15,//11,
"title": "Beanie",
'link': '/product/beanie/',
'sku': 'woo-beanie',
Expand Down
11 changes: 7 additions & 4 deletions tests/Playwright/tests/Shared/wooUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -232,7 +235,7 @@ const manualOrder = (productId, productQuantity, country, postcode) => {

module.exports = {
addProductToCart,
fillCustomerInCheckoutBlock,
fillCustomerInCheckoutBlock: fillCustomerInCheckout,
gotoWooPaymentTab,
placeOrderCheckout,
emptyCart,
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const testData = [
await checkExpiredAtMollie(page);
}
},
{
/*{
methodId: "billie",
testId: "C354674",
mollieStatus: "Authorized",
Expand Down Expand Up @@ -130,7 +130,7 @@ export const testData = [
action: async (page) => {
await checkExpiredAtMollie(page);
}
},
},*/
{
methodId: "eps",
testId: "C3412",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ export const testData = [
await wooOrderRetryPage(page);
}
},
{
/*{
methodId: "billie",
testId: "C420413",
mollieStatus: "Authorized",
Expand Down Expand Up @@ -640,7 +640,7 @@ export const testData = [
action: async (page) => {
await wooOrderRetryPage(page);
}
},
},*/
{
methodId: "in3",
testId: "C420334",
Expand Down

0 comments on commit 4648243

Please sign in to comment.