Skip to content

Commit

Permalink
Merge branch 'release/7.3.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed May 31, 2023
2 parents e78603b + 9db38f6 commit 8b9d479
Show file tree
Hide file tree
Showing 141 changed files with 7,132 additions and 1,090 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ playwright-report/
/test-results/
/playwright-report/
/playwright/.cache/
/test-results/
/playwright-report/
/playwright/.cache/
4 changes: 2 additions & 2 deletions mollie-payments-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Mollie Payments for WooCommerce
* Plugin URI: https://www.mollie.com
* Description: Accept payments in WooCommerce with the official Mollie plugin
* Version: 7.3.7
* Version: 7.3.8-beta
* Author: Mollie
* Author URI: https://www.mollie.com
* Requires at least: 5.0
Expand All @@ -12,7 +12,7 @@
* Domain Path: /languages
* License: GPLv2 or later
* WC requires at least: 3.0
* WC tested up to: 7.5
* WC tested up to: 7.7
* Requires PHP: 7.2
*/
declare(strict_types=1);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@babel/polyfill": "^7.7.0",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.14.5",
"@playwright/test": "^1.30.0",
"@playwright/test": "^1.33.0",
"@symfony/webpack-encore": "^0.28.2",
"@woocommerce/dependency-extraction-webpack-plugin": "^1.7.0",
"@wordpress/data": "^6.1.5",
Expand Down
131 changes: 35 additions & 96 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,138 +1,77 @@
// @ts-check
const {defineConfig, devices} = require('@playwright/test');
const {simple, virtual} = require('./tests/e2e/Shared/products');
const {ideal, banktransfer, paypal, creditcard} = require('./tests/e2e/Shared/gateways');

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
require('dotenv').config();

const testRailOptions = {
// Whether to add <properties> with all annotations; default is false
embedAnnotationsAsProperties: true,
// Where to put the report.
outputFile: './test-results/junit-report.xml'
};
/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests/e2e',
/* Maximum time one test can run for. */
timeout: 120000,
globalTimeout: 0,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 60000
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
fullyParallel: false,
timeout: 320000,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
globalSetup: require.resolve('./tests/e2e/Shared/global-setup'),
reporter: [
['list'],
['junit', testRailOptions]
],
globalSetup: './tests/e2e/globalSetup.js',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.BASEURL,
storageState: './storageState.json',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
extraHTTPHeaders: {'ngrok-skip-browser-warning': '123'}
extraHTTPHeaders: {'ngrok-skip-browser-warning': '123'},
actionTimeout: 120000,
},

/* Configure projects for major browsers */
projects: [
{
name: 'activation',
testMatch: ['**/Activation/Activation.spec.js'],
name: 'plugins-page',
testDir: './tests/e2e/Plugins page',
use: {
...devices['Desktop Chrome'],
testIdAttribute: 'data-slug'
},
}
},
{
name: 'simple-settings',
testMatch: '**/Settings/GeneralSettings.spec.js',
name: 'woo-payments-tab',
testDir: './tests/e2e/WooCommerce Payments tab',
use: {
...devices['Desktop Chrome'],
gateways: {banktransfer},
products: {simple},
},
...devices['Desktop Chrome']
}
},
{
name: 'full-settings',
testMatch: '**/Settings/PaymentSettings.classic.spec.js',
name: 'transaction-scenarios',
testDir: './tests/e2e/Transaction Scenarios',
use: {
...devices['Desktop Chrome']
},
}
},
{
name: 'simple-classic',
testMatch: ['**/Transaction/Checkout.classic.spec.js'],
name: 'mollie-settings-tab',
testDir: './tests/e2e/Mollie Settings tab',
use: {
...devices['Desktop Chrome'],
gateways: {ideal},
products: {simple},
},
...devices['Desktop Chrome']
}
},
{
name: 'product-paypal',
testMatch: '**/Product/**',
name: 'error-handling',
testDir: './tests/e2e/Error Handling',
use: {
...devices['Desktop Chrome'],
gateways: paypal,
products: {simple, virtual},
},
...devices['Desktop Chrome']
}
},
/*{
name: 'chromium',
use: {...devices['Desktop Chrome']},
},*/

/* {
name: 'firefox',
use: {...devices['Desktop Firefox']},
},
{
name: 'webkit',
use: {...devices['Desktop Safari']},
},*/

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { channel: 'chrome' },
// },
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
outputDir: './tests/e2e/Reports/',

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// port: 3000,
// },
});

106 changes: 17 additions & 89 deletions resources/js/mollieBillie.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,26 @@
import {maybeRequireField, saveOriginalField} from "./wooCheckoutFieldsUtility";

(
function ({jQuery}) {
let gateway = 'mollie_wc_gateway_billie';
let originalBillingCompanyField = {};
saveOriginalBillingCompanyField();

function usingGateway(gateway)
{
return jQuery('form[name="checkout"] input[name="payment_method"]:checked').val() === gateway;
}
function showBillingCompanyField()
{
let billingField = jQuery('form[name="checkout"] p#billing_company_field');
if ((billingField).length <= 0) {
jQuery('form[name="checkout"] input[name="billing_last_name"]')
.closest('p')
.after(
'<p class="form-row form-row-wide" id="billing_company_field" data-priority="30">'
+ '<label for="billing_company" class="">Company name&nbsp;'
+ '<abbr className="required" title="required">*</abbr>'
+ '</label>'
+ '<span class="woocommerce-input-wrapper">'
+ '<input type="text" class="input-text " name="billing_company" id="billing_company" placeholder="" value="" autocomplete="organization">'
+ '</span>'
+ '</p>'
);
}
}
function requireBillingCompanyField()
{
jQuery('form[name="checkout"] input[name="billing_company"]').attr('required', '');
jQuery('form[name="checkout"] p#billing_company_field').addClass('validate-required');
jQuery('form[name="checkout"] p#billing_company_field label span').replaceWith('<abbr class="required" title="required">*</abbr>');
}

function saveOriginalBillingCompanyField()
{
let billingCompanyField = jQuery('form[name="checkout"] input[name="billing_company"]');
let isVisible = billingCompanyField.is(':visible');
let isRequired = billingCompanyField.prop('required');
originalBillingCompanyField = { isVisible, isRequired };
}

function removeBillingCompanyField()
{
jQuery('form[name="checkout"] p#billing_company_field').remove();
}

function unrequireBillingCompanyField()
{
jQuery('form[name="checkout"] input[name="billing_company"]').removeAttr('required');
jQuery('form[name="checkout"] p#billing_company_field').removeClass('validate-required');
jQuery('form[name="checkout"] p#billing_company_field label abbr').replaceWith('<span class="optional">(optional)</span>');

}

function restoreOriginalBillingCompanyField()
{
let billingCompanyField = jQuery('form[name="checkout"] input[name="billing_company"]');
let currentVisibility = billingCompanyField.is(':visible');
let currentRequired = billingCompanyField.prop('required');
if (currentVisibility !== originalBillingCompanyField.isVisible) {
if (originalBillingCompanyField.isVisible) {
showBillingCompanyField();
} else {
removeBillingCompanyField();
}
}
if (currentRequired !== originalBillingCompanyField.isRequired) {
if (originalBillingCompanyField.isRequired) {
requireBillingCompanyField();
} else {
unrequireBillingCompanyField();
}
}
}

function maybeRequireBillingCompanyField()
{
if (usingGateway(gateway)) {
showBillingCompanyField();
requireBillingCompanyField();
} else {
restoreOriginalBillingCompanyField();
}
}
let inputCompanyName = 'billing_company';
let originalBillingCompanyField = saveOriginalField(inputCompanyName, {});
let companyFieldId = 'billing_company_field';
let companyField = jQuery('form[name="checkout"] p#billing_company_field');
let positionCompanyField = 'form[name="checkout"] input[name="billing_last_name"]';
let companyMarkup = '<p class="form-row form-row-wide" id="billing_company_field" data-priority="30">'
+ '<label for="billing_company" class="">Company name&nbsp;'
+ '<abbr className="required" title="required">*</abbr>'
+ '</label>'
+ '<span class="woocommerce-input-wrapper">'
+ '<input type="text" class="input-text " name="billing_company" id="billing_company" placeholder="" value="" autocomplete="organization">'
+ '</span>'
+ '</p>'

jQuery(function () {
jQuery('body')
.on('updated_checkout', function () {
maybeRequireBillingCompanyField();
});
jQuery('body')
.on('payment_method_selected', function () {
maybeRequireBillingCompanyField();
.on('updated_checkout payment_method_selected', function () {
companyField = maybeRequireField(companyField, positionCompanyField, companyMarkup, inputCompanyName, companyFieldId, originalBillingCompanyField, gateway);
});
});
}
Expand Down
20 changes: 15 additions & 5 deletions resources/js/mollieBlockIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,25 @@ import molliePaymentMethod from './blocks/molliePaymentMethod'
const { ajaxUrl, filters, gatewayData, availableGateways } = mollieBlockData.gatewayData;
const {useEffect} = wp.element;
const isAppleSession = typeof window.ApplePaySession === "function"
let shippingCompany = document.getElementById('shipping-company');
let billingCompany = document.getElementById('billing-company');
let companyField = shippingCompany ? shippingCompany : billingCompany;
let isCompanyFieldVisible = companyField && companyField.style.display !== 'none';

function getCompanyField()
{
let shippingCompany = document.getElementById('shipping-company');
let billingCompany = document.getElementById('billing-company');
return shippingCompany ? shippingCompany : billingCompany;
}

function isFieldVisible(field)
{
return field && field.style.display !== 'none';
}

let companyField = getCompanyField();
let companyNameString = companyField && companyField.parentNode.querySelector("label[for='" + companyField.id + "']").innerHTML;
gatewayData.forEach(item => {
let register = () => registerPaymentMethod(molliePaymentMethod(useEffect, ajaxUrl, filters, gatewayData, availableGateways, item, jQuery, companyNameString));
if (item.name === 'mollie_wc_gateway_billie') {
if (isCompanyFieldVisible) {
if (isFieldVisible(companyField)) {
register();
}
return;
Expand Down
Loading

0 comments on commit 8b9d479

Please sign in to comment.