-
+
+
Connect Account to continue.',
+ 'Please click the Connect Account button to connect this WordPress site with your Mailchimp account. Once you complete the Mailchimp login in the pop-up window that appears, this page will refresh to show the Mailchimp List Subscribe Form settings.',
'mailchimp'
),
[
From 1198ebb147414b62d2255ade9557f25603fc03d3 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Wed, 7 Aug 2024 23:37:41 +0530
Subject: [PATCH 24/48] Show notice for re-connect incase of token decryption
fail.
---
mailchimp.php | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/mailchimp.php b/mailchimp.php
index ab9db62..de7d340 100644
--- a/mailchimp.php
+++ b/mailchimp.php
@@ -1415,8 +1415,18 @@ function mailchimp_sf_create_nonce( $action = -1 ) {
* @return string|bool
*/
function mailchimp_sf_get_access_token() {
- $access_token = get_option( 'mailchimp_sf_access_token' );
+ $access_token = get_option( 'mailchimp_sf_access_token' );
+ if ( empty( $access_token ) ) {
+ return false;
+ }
+
$data_encryption = new Mailchimp_Data_Encryption();
+ $access_token = $data_encryption->decrypt( $access_token );
+
+ // If decryption fails, display notice to user to re-authenticate.
+ if ( false === $access_token ) {
+ update_option( 'mailchimp_sf_auth_error', true );
+ }
- return $data_encryption->decrypt( $access_token );
+ return $access_token;
}
From c2c918917e56734f416ba6477221ca39434c15fb Mon Sep 17 00:00:00 2001
From: Darin Kotter
Date: Wed, 7 Aug 2024 14:38:30 -0600
Subject: [PATCH 25/48] Readme updates
---
README.md | 12 ++++++------
readme.txt | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index cfe49ca..41e20b0 100644
--- a/README.md
+++ b/README.md
@@ -18,20 +18,20 @@ WordPress.com compatibility is limited to Business tier users only. [How to add
![Configuring extra fields on your Signup Form (optional)](https://github.com/mailchimp/wordpress/blob/develop/.wordpress-org/screenshot-4.jpg?raw=true)
-## Access token Encryption
+## Access Token Encryption
-The plugin stores the OAuth access token in the WordPress database and encrypts it for security. To ensure encryption and decryption work properly, the plugin needs access to certain security constants that should remain unchanged.
+Starting in version 1.6.0, authentication has changed to use OAuth. As part of this process, we retrieve an access token that can be used to make API requests. To provide a high-level of security, this access token is encrypted before being stored in the WordPress database. In order to ensure this access token can be decrypted when used, the plugin relies on certain security constants that should remain unchanged.
-By default, the plugin uses the `LOGGED_IN_KEY` and `LOGGED_IN_SALT` constants from the wp-config.php file. These usually work well. However, if another plugin or mechanism regularly updates these constants, the plugin will have trouble decrypting the access token and you’ll need to reconnect your Mailchimp account.
+With no additional configuration, we use the standard `LOGGED_IN_KEY` and `LOGGED_IN_SALT` constants that are normally set in your site's `wp-config.php` file. Some sites make use of security plugins that rotate these constants on a periodic basis. When this happens, we won't be able to decrypt the access token and you’ll need to reconnect your Mailchimp account to generate a new access token.
-To prevent such issues, it is recommended to define two additional constants in your wp-config.php file: `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. These constants should consist of a combination of characters, preferably at least 32 characters long. Once set, these values should not be changed. For strong values, you can copy some of the values from https://api.wordpress.org/secret-key/1.1/salt/ and use them. You should have additional code like the following in your wp-config.php file:
+To prevent such issues, it is recommended to define two additional constants in your site's `wp-config.php` file: `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. These constants should consist of a combination of characters, preferably at least 32 characters long. Once set, these values should not be changed. For strong values, you can copy some of the values from [here](https://api.wordpress.org/secret-key/1.1/salt/) and use them. You'll end up with additional code like the following in your `wp-config.php` file:
```php
define( 'MAILCHIMP_SF_ENCRYPTION_KEY', 'put your unique phrase here' );
define( 'MAILCHIMP_SF_ENCRYPTION_SALT', 'put your unique phrase here' );
```
-If you add these constants after the plugin is already configured, the plugin will use the new constants, which may cause issues. To avoid this, you can copy the values from `LOGGED_IN_KEY` and `LOGGED_IN_SALT` to `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. If you prefer new values, you will need to reconnect your Mailchimp account.
+If these constants are added after you've already authenticated with Mailchimp, you will need to reconnect your account. To avoid this, you can copy the values from `LOGGED_IN_KEY` and `LOGGED_IN_SALT` (if they exist) to `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT` respectively.
## Frequently Asked Questions
@@ -56,7 +56,7 @@ This section describes how to install the plugin and get started using it.
### Advanced
-If you have a custom coded sidebar or bells and whistles that prevent enabling widgets through the WordPress GUI, complete these steps instead.
+If you have a custom coded sidebar or bells and whistles that prevent enabling widgets through the WordPress GUI, complete these steps instead.
WordPress v2.8 or higher:
` [mailchimpsf_form] `
diff --git a/readme.txt b/readme.txt
index 4490777..4b34a7e 100644
--- a/readme.txt
+++ b/readme.txt
@@ -16,20 +16,20 @@ After installation, you’ll log in with your API key, select your Mailchimp lis
WordPress.com compatibility is limited to Business tier users only. [How to add a signup form if you have a WordPress.com site](https://mailchimp.com/help/ways-to-add-a-signup-form-in-wordpress/).
-=== Access token Encryption ===
+=== Access Token Encryption ===
-The plugin stores the OAuth access token in the WordPress database and encrypts it for security. To ensure encryption and decryption work properly, the plugin needs access to certain security constants that should remain unchanged.
+Starting in version 1.6.0, authentication has changed to use OAuth. As part of this process, we retrieve an access token that can be used to make API requests. To provide a high-level of security, this access token is encrypted before being stored in the WordPress database. In order to ensure this access token can be decrypted when used, the plugin relies on certain security constants that should remain unchanged.
-By default, the plugin uses the `LOGGED_IN_KEY` and `LOGGED_IN_SALT` constants from the wp-config.php file. These usually work well. However, if another plugin or mechanism regularly updates these constants, the plugin will have trouble decrypting the access token and you’ll need to reconnect your Mailchimp account.
+With no additional configuration, we use the standard `LOGGED_IN_KEY` and `LOGGED_IN_SALT` constants that are normally set in your site's `wp-config.php` file. Some sites make use of security plugins that rotate these constants on a periodic basis. When this happens, we won't be able to decrypt the access token and you’ll need to reconnect your Mailchimp account to generate a new access token.
-To prevent such issues, it is recommended to define two additional constants in your wp-config.php file: `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. These constants should consist of a combination of characters, preferably at least 32 characters long. Once set, these values should not be changed. For strong values, you can copy some of the values from https://api.wordpress.org/secret-key/1.1/salt/ and use them. You should have additional code like the following in your wp-config.php file:
+To prevent such issues, it is recommended to define two additional constants in your site's `wp-config.php` file: `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. These constants should consist of a combination of characters, preferably at least 32 characters long. Once set, these values should not be changed. For strong values, you can copy some of the values from [here](https://api.wordpress.org/secret-key/1.1/salt/) and use them. You'll end up with additional code like the following in your `wp-config.php` file:
`
define( 'MAILCHIMP_SF_ENCRYPTION_KEY', 'put your unique phrase here' );
define( 'MAILCHIMP_SF_ENCRYPTION_SALT', 'put your unique phrase here' );
`
-If you add these constants after the plugin is already configured, the plugin will use the new constants, which may cause issues. To avoid this, you can copy the values from `LOGGED_IN_KEY` and `LOGGED_IN_SALT` to `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT`. If you prefer new values, you will need to reconnect your Mailchimp account.
+If these constants are added after you've already authenticated with Mailchimp, you will need to reconnect your account. To avoid this, you can copy the values from `LOGGED_IN_KEY` and `LOGGED_IN_SALT` (if they exist) to `MAILCHIMP_SF_ENCRYPTION_KEY` and `MAILCHIMP_SF_ENCRYPTION_SALT` respectively.
== Frequently Asked Questions ==
@@ -52,7 +52,7 @@ This section describes how to install the plugin and get started using it.
= Advanced =
-If you have a custom coded sidebar or bells and whistles that prevent enabling widgets through the WordPress GUI, complete these steps instead.
+If you have a custom coded sidebar or bells and whistles that prevent enabling widgets through the WordPress GUI, complete these steps instead.
WordPress v2.8 or higher:
` [mailchimpsf_form] `
From ed0edf06363317cd5a80ec080e6082e77322a199 Mon Sep 17 00:00:00 2001
From: Darin Kotter
Date: Wed, 7 Aug 2024 14:53:36 -0600
Subject: [PATCH 26/48] Minor formatting cleanup
---
includes/class-mailchimp-admin.php | 15 +++++++++------
includes/class-mailchimp-data-encryption.php | 4 ++--
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/includes/class-mailchimp-admin.php b/includes/class-mailchimp-admin.php
index dc3a201..064bb7f 100644
--- a/includes/class-mailchimp-admin.php
+++ b/includes/class-mailchimp-admin.php
@@ -1,6 +1,6 @@
@@ -221,7 +224,7 @@ public function admin_notices() {
/**
* Sanitize variables using sanitize_text_field.
*
- * Arrays are sanitized recursively, Non-scalar values are ignored.
+ * Arrays are sanitized recursively, non-scalar values are ignored.
*
* @param string|array $data Data to sanitize.
* @return string|array
diff --git a/includes/class-mailchimp-data-encryption.php b/includes/class-mailchimp-data-encryption.php
index d7ef9ce..3853bea 100644
--- a/includes/class-mailchimp-data-encryption.php
+++ b/includes/class-mailchimp-data-encryption.php
@@ -46,7 +46,7 @@ public function __construct() {
/**
* Encrypts a value.
*
- * If a user-based key is set, that key is used. Otherwise the default key is used.
+ * If a user-based key is set, that is used. Otherwise the default key is used.
*
* @since x.x.x
*
@@ -73,7 +73,7 @@ public function encrypt( $value ) {
/**
* Decrypts a value.
*
- * If a user-based key is set, that key is used. Otherwise the default key is used.
+ * If a user-based key is set, that is used. Otherwise the default key is used.
*
* @since x.x.x
*
From 3afeb8878443856b1c9b7641760ddc8a7fd08ef1 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 11:44:00 +0530
Subject: [PATCH 27/48] Use oauth url from the server side.
---
includes/class-mailchimp-admin.php | 34 +++++++++++++++++++++++++++++
js/admin.js | 7 +++---
mailchimp.php | 35 ------------------------------
3 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/includes/class-mailchimp-admin.php b/includes/class-mailchimp-admin.php
index dc3a201..f0e7d4d 100644
--- a/includes/class-mailchimp-admin.php
+++ b/includes/class-mailchimp-admin.php
@@ -32,6 +32,8 @@ public function init() {
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'wp_ajax_mailchimp_sf_oauth_start', array( $this, 'start_oauth_process' ) );
add_action( 'wp_ajax_mailchimp_sf_oauth_finish', array( $this, 'finish_oauth_process' ) );
+
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_page_scripts' ) );
}
@@ -233,4 +235,36 @@ public function sanitize_data( $data ) {
return is_scalar( $data ) ? sanitize_text_field( $data ) : $data;
}
}
+
+ /**
+ * Enqueue scripts/styles for the Mailchimp admin page
+ *
+ * @param string $hook_suffix The current admin page.
+ * @return void
+ */
+ public function enqueue_admin_page_scripts( $hook_suffix ) {
+ if ( 'toplevel_page_mailchimp_sf_options' !== $hook_suffix ) {
+ return;
+ }
+
+ wp_enqueue_style( 'mailchimp_sf_admin_css', MCSF_URL . 'css/admin.css', array( 'wp-jquery-ui-dialog' ), true );
+ wp_enqueue_script( 'showMe', MCSF_URL . 'js/hidecss.js', array( 'jquery' ), MCSF_VER, true );
+ wp_enqueue_script( 'mailchimp_sf_admin', MCSF_URL . 'js/admin.js', array( 'jquery', 'jquery-ui-dialog' ), MCSF_VER, true );
+
+ wp_localize_script(
+ 'mailchimp_sf_admin',
+ 'mailchimp_sf_admin_params',
+ array(
+ 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
+ 'oauth_url' => esc_url( $this->oauth_url ),
+ 'oauth_start_nonce' => wp_create_nonce( 'mailchimp_sf_oauth_start_nonce' ),
+ 'oauth_finish_nonce' => wp_create_nonce( 'mailchimp_sf_oauth_finish_nonce' ),
+ 'oauth_window_name' => esc_html__( 'Mailchimp For WordPress OAuth', 'mailchimp' ),
+ 'generic_error' => esc_html__( 'An error occurred. Please try again.', 'mailchimp' ),
+ 'modal_title' => esc_html__( 'Login Popup is blocked!', 'mailchimp' ),
+ 'modal_button_try_again' => esc_html__( 'Try again', 'mailchimp' ),
+ 'modal_button_cancel' => esc_html__( 'No, cancel!', 'mailchimp' ),
+ )
+ );
+ }
}
diff --git a/js/admin.js b/js/admin.js
index b33e9da..6e24563 100644
--- a/js/admin.js
+++ b/js/admin.js
@@ -1,7 +1,6 @@
/* eslint-disable prefer-template, no-console */
(function ($) {
const params = window.mailchimp_sf_admin_params || {};
- const oauthBaseUrl = 'https://woocommerce.mailchimpapp.com';
const spinner = '.mailchimp-sf-oauth-connect-wrapper .spinner';
const errorSelector = '.mailchimp-sf-oauth-section .oauth-error';
@@ -11,7 +10,7 @@
* @param {string} token - Token from the Oauth service.
*/
function openMailchimpOauthPopup(token) {
- const startUrl = oauthBaseUrl + '/auth/start/' + token;
+ const startUrl = params.oauth_url + '/auth/start/' + token;
const width = 800;
const height = 600;
const screenSizes = window.screen || { width: 1024, height: 768 };
@@ -27,7 +26,7 @@
', left=' +
left +
', domain=' +
- oauthBaseUrl.replace('https://', '');
+ params.oauth_url.replace('https://', '');
// Open Mailchimp OAuth popup.
const popup = window.open(startUrl, params.oauth_window_name, windowOptions);
@@ -67,7 +66,7 @@
window.clearInterval(oauthInterval);
// Check status of OAuth connection.
- const statusUrl = oauthBaseUrl + '/api/status/' + token;
+ const statusUrl = params.oauth_url + '/api/status/' + token;
$.post(statusUrl, function (statusData) {
if (statusData && statusData.status === 'accepted') {
const finishData = {
diff --git a/mailchimp.php b/mailchimp.php
index de7d340..166ae43 100644
--- a/mailchimp.php
+++ b/mailchimp.php
@@ -140,41 +140,6 @@ function mailchimp_sf_load_resources() {
}
}
-
-/**
- * Loads resources for the Mailchimp admin page
- *
- * @param string $hook_suffix The current admin page.
- * @return void
- */
-function mailchimp_admin_page_scripts( $hook_suffix ) {
- if ( 'toplevel_page_mailchimp_sf_options' !== $hook_suffix ) {
- return;
- }
-
- wp_enqueue_style( 'mailchimp_sf_admin_css', MCSF_URL . 'css/admin.css', array( 'wp-jquery-ui-dialog' ), true );
- wp_enqueue_script( 'showMe', MCSF_URL . 'js/hidecss.js', array( 'jquery' ), MCSF_VER, true );
- wp_enqueue_script( 'mailchimp_sf_admin', MCSF_URL . 'js/admin.js', array( 'jquery', 'jquery-ui-dialog' ), MCSF_VER, true );
-
- wp_localize_script(
- 'mailchimp_sf_admin',
- 'mailchimp_sf_admin_params',
- array(
- 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
- 'oauth_start_nonce' => wp_create_nonce( 'mailchimp_sf_oauth_start_nonce' ),
- 'oauth_finish_nonce' => wp_create_nonce( 'mailchimp_sf_oauth_finish_nonce' ),
- 'oauth_window_name' => esc_html__( 'Mailchimp For WordPress OAuth', 'mailchimp' ),
- 'generic_error' => esc_html__( 'An error occurred. Please try again.', 'mailchimp' ),
- 'modal_title' => esc_html__( 'Login Popup is blocked!', 'mailchimp' ),
- 'modal_button_try_again' => esc_html__( 'Try again', 'mailchimp' ),
- 'modal_button_cancel' => esc_html__( 'No, cancel!', 'mailchimp' ),
- )
- );
-}
-
-add_action( 'admin_enqueue_scripts', 'mailchimp_admin_page_scripts', 10, 1 );
-
-
/**
* Loads jQuery Datepicker for the date-pick class
**/
From 01deb4b20daef617448226eb761cefd194ec9d5e Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 12:18:34 +0530
Subject: [PATCH 28/48] Upgrade "@10up/cypress-wp-utils" to 0.4.0
---
package-lock.json | 8 ++++----
package.json | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index a821dba..c8b99b8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,7 +14,7 @@
"@wordpress/server-side-render": "^5.2.0"
},
"devDependencies": {
- "@10up/cypress-wp-utils": "^0.3.0",
+ "@10up/cypress-wp-utils": "^0.4.0",
"@wordpress/env": "^10.2.0",
"10up-toolkit": "^6.2.0",
"cypress": "^13.12.0",
@@ -42,9 +42,9 @@
}
},
"node_modules/@10up/cypress-wp-utils": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/@10up/cypress-wp-utils/-/cypress-wp-utils-0.3.0.tgz",
- "integrity": "sha512-iMjvca50TerMCY9M9vL0FIE+80ye5YohaQp3XvhgUgQdc4LS51X2fH+lhdb0uRmBTiUQcISazEvWGJxV7DeTbw==",
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/@10up/cypress-wp-utils/-/cypress-wp-utils-0.4.0.tgz",
+ "integrity": "sha512-7cNELIX6ml5V9JEU83iEyQ6dkZ77ImdR5HKjUP4oyArQogPVcFPUnokU7GInH8DicqXbESrrkxZ0IfnNtNWh+A==",
"dev": true,
"engines": {
"node": ">=12.0"
diff --git a/package.json b/package.json
index 193021c..8b247b7 100644
--- a/package.json
+++ b/package.json
@@ -31,7 +31,7 @@
"build": "10up-toolkit build"
},
"devDependencies": {
- "@10up/cypress-wp-utils": "^0.3.0",
+ "@10up/cypress-wp-utils": "^0.4.0",
"@wordpress/env": "^10.2.0",
"10up-toolkit": "^6.2.0",
"cypress": "^13.12.0",
From 3aed9d26d187ab841602c8f62eddedaa8fbba8bb Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 16:52:42 +0530
Subject: [PATCH 29/48] Upgrade cypress to 13.13.2
---
package-lock.json | 12 ++++++------
package.json | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index c8b99b8..57bc189 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -17,7 +17,7 @@
"@10up/cypress-wp-utils": "^0.4.0",
"@wordpress/env": "^10.2.0",
"10up-toolkit": "^6.2.0",
- "cypress": "^13.12.0",
+ "cypress": "^13.13.2",
"cypress-mochawesome-reporter": "^3.8.2",
"mochawesome-json-to-md": "^1.3.5"
}
@@ -9912,13 +9912,13 @@
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
},
"node_modules/cypress": {
- "version": "13.12.0",
- "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.12.0.tgz",
- "integrity": "sha512-udzS2JilmI9ApO/UuqurEwOvThclin5ntz7K0BtnHBs+tg2Bl9QShLISXpSEMDv/u8b6mqdoAdyKeZiSqKWL8g==",
+ "version": "13.13.2",
+ "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.13.2.tgz",
+ "integrity": "sha512-PvJQU33933NvS1StfzEb8/mu2kMy4dABwCF+yd5Bi7Qly1HOVf+Bufrygee/tlmty/6j5lX+KIi8j9Q3JUMbhA==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
- "@cypress/request": "^3.0.0",
+ "@cypress/request": "^3.0.1",
"@cypress/xvfb": "^1.2.4",
"@types/sinonjs__fake-timers": "8.1.1",
"@types/sizzle": "^2.3.2",
@@ -9957,7 +9957,7 @@
"request-progress": "^3.0.0",
"semver": "^7.5.3",
"supports-color": "^8.1.1",
- "tmp": "~0.2.1",
+ "tmp": "~0.2.3",
"untildify": "^4.0.0",
"yauzl": "^2.10.0"
},
diff --git a/package.json b/package.json
index 8b247b7..2c3fd71 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
},
"scripts": {
"cypress:open": "cypress open --config-file tests/cypress/config.js --e2e --browser chrome",
- "cypress:run": "cypress run --config-file tests/cypress/config.js",
+ "cypress:run": "cypress run --config-file tests/cypress/config.js --e2e --browser chrome",
"env": "wp-env",
"env:start": "wp-env start",
"env:stop": "wp-env stop",
@@ -34,7 +34,7 @@
"@10up/cypress-wp-utils": "^0.4.0",
"@wordpress/env": "^10.2.0",
"10up-toolkit": "^6.2.0",
- "cypress": "^13.12.0",
+ "cypress": "^13.13.2",
"cypress-mochawesome-reporter": "^3.8.2",
"mochawesome-json-to-md": "^1.3.5"
},
From 1b0159378b4a163abe74b87df500055560e9b40a Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 16:53:04 +0530
Subject: [PATCH 30/48] Added admin tests.
---
tests/cypress/e2e/admin.test.js | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/tests/cypress/e2e/admin.test.js b/tests/cypress/e2e/admin.test.js
index 1f9a545..65d5f4a 100644
--- a/tests/cypress/e2e/admin.test.js
+++ b/tests/cypress/e2e/admin.test.js
@@ -1,10 +1,22 @@
-describe( 'Admin can login and make sure plugin is activated', () => {
- before( () => {
+/* eslint-disable no-undef */
+describe('Admin can login and make sure plugin is activated', () => {
+ before(() => {
cy.login();
- } );
+ });
- it( 'Can deactivate and activate plugin?', () => {
- cy.deactivatePlugin( 'mailchimp' );
- cy.activatePlugin( 'mailchimp' );
- } );
-} );
+ it('Can deactivate and activate plugin?', () => {
+ cy.deactivatePlugin('mailchimp');
+ cy.activatePlugin('mailchimp');
+ });
+
+ it('Can see "Mailchimp" menu and Can visit "Mailchimp" settings page.', () => {
+ cy.visit('/wp-admin/');
+
+ // Check Mailchimp menu.
+ cy.get('#adminmenu li#toplevel_page_mailchimp_sf_options').contains('Mailchimp');
+
+ // Check Heading
+ cy.get('#adminmenu li#toplevel_page_mailchimp_sf_options').click();
+ cy.get('#wpbody .mailchimp-header h1').contains('Mailchimp List Subscribe Form');
+ });
+});
From 74fae4c5f133474d66f173ee9feaa9a64aee1243 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 16:53:37 +0530
Subject: [PATCH 31/48] Added connect to mailchimp test.
---
tests/cypress/e2e/connect.test.js | 37 +++++++++++++++++++++++++++++++
tests/cypress/support/commands.js | 25 +++++++++++++++++++++
tests/cypress/support/index.js | 3 +++
3 files changed, 65 insertions(+)
create mode 100644 tests/cypress/e2e/connect.test.js
diff --git a/tests/cypress/e2e/connect.test.js b/tests/cypress/e2e/connect.test.js
new file mode 100644
index 0000000..79f027d
--- /dev/null
+++ b/tests/cypress/e2e/connect.test.js
@@ -0,0 +1,37 @@
+/* eslint-disable no-undef */
+describe('Admin can connect to "Mailchimp" Account', () => {
+ before(() => {
+ cy.login();
+ });
+
+ it('Can connect to "Mailchimp" using OAuth flow.', () => {
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+
+ // Logout if already connected.
+ cy.get('body').then(($body) => {
+ if ($body.find('input[value="Logout"]').length > 0) {
+ cy.get('input[value="Logout"]').click();
+ }
+ });
+
+ // Check Mailchimp menu.
+ cy.get('#mailchimp_sf_oauth_connect').should('exist');
+
+ // Enable popup capture.
+ cy.capturePopup();
+
+ cy.get('#mailchimp_sf_oauth_connect').click();
+ cy.wait(5000);
+
+ cy.popup().find('input#username').clear().type(Cypress.env('MAILCHIMP_USERNAME'));
+ cy.popup().find('input#password').clear().type(Cypress.env('MAILCHIMP_PASSWORD'));
+ cy.popup().find('button[type="submit"]').click();
+ cy.wait(8000); // Not a best practice, but did not find a better way to handle this.
+
+ cy.popup().find('input#submitButton').click();
+ cy.wait(10000);
+
+ cy.get('.mc-user h3').contains('Logged in as: ');
+ cy.get('input[value="Logout"]').should('exist');
+ });
+});
diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js
index 119ab03..95025e3 100644
--- a/tests/cypress/support/commands.js
+++ b/tests/cypress/support/commands.js
@@ -23,3 +23,28 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
+
+const state = {};
+
+/**
+ * Intercepts calls to window.open() to keep a reference to the new window
+ */
+Cypress.Commands.add('capturePopup', () => {
+ cy.window().then((win) => {
+ const { open } = win;
+ cy.stub(win, 'open').callsFake((...params) => {
+ // Capture the reference to the popup
+ state.popup = open(...params);
+ return state.popup;
+ });
+ });
+});
+
+/**
+ * Returns a wrapped body of a captured popup
+ */
+Cypress.Commands.add('popup', () => {
+ console.log('state', state.popup);
+ const popup = Cypress.$(state.popup.document);
+ return cy.wrap(popup.contents().find('body'));
+});
diff --git a/tests/cypress/support/index.js b/tests/cypress/support/index.js
index d8895b6..5652037 100644
--- a/tests/cypress/support/index.js
+++ b/tests/cypress/support/index.js
@@ -15,6 +15,9 @@
import '@10up/cypress-wp-utils';
+// Import commands.js using ES2015 syntax:
+import './commands';
+
beforeEach( () => {
cy.session( 'login', cy.login, {
cacheAcrossSpecs: true,
From d61ab47f93ec98d3d3ce638113d45089f4faa5ab Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 17:35:09 +0530
Subject: [PATCH 32/48] Add settings, shortcode and block tests.
---
tests/cypress/e2e/settings.test.js | 83 ++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
create mode 100644 tests/cypress/e2e/settings.test.js
diff --git a/tests/cypress/e2e/settings.test.js b/tests/cypress/e2e/settings.test.js
new file mode 100644
index 0000000..71350a0
--- /dev/null
+++ b/tests/cypress/e2e/settings.test.js
@@ -0,0 +1,83 @@
+/* eslint-disable no-undef */
+describe('Admin can update plugin settings', () => {
+ let shortcodePostId = 0;
+ let blockPostId = 0;
+
+ before(() => {
+ cy.login();
+ });
+
+ it('Admin can see list and save it', () => {
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+
+ cy.get('.mc-h2').contains('Your Lists');
+ cy.get('#mc_list_id').select('10up');
+ cy.get('input[value="Update List"]').click();
+ cy.get('#mc-message .success_msg b').contains('Success!');
+ });
+
+ it('Admin can create a Signup form using the shortcode', () => {
+ const postTitle = 'Mailchimp signup form - shortcode';
+ const beforeSave = () => {
+ cy.insertBlock('core/shortcode').then((id) => {
+ cy.get(`#${id} .blocks-shortcode__textarea`).type('[mailchimpsf_form]');
+ });
+ };
+ cy.createPost({ title: postTitle, content: '', beforeSave }).then((post) => {
+ if (post) {
+ shortcodePostId = post.id;
+ cy.visit(`/?p=${shortcodePostId}`);
+ cy.get('#mc_signup').should('exist');
+ cy.get('#mc_mv_EMAIL').should('exist');
+ cy.get('#mc_signup_submit').should('exist');
+ cy.get('#mc_signup_submit').click();
+ cy.get('.mc_error_msg').should('exist');
+ cy.get('.mc_error_msg').contains(': This value should not be blank.');
+ }
+ });
+ });
+
+ it('Admin can create a Signup form using Mailchimp block', () => {
+ const postTitle = 'Mailchimp signup form - Block';
+ const beforeSave = () => {
+ cy.insertBlock('mailchimp/mailchimp');
+ };
+ cy.createPost({ title: postTitle, content: '', beforeSave }).then((post) => {
+ if (post) {
+ blockPostId = post.id;
+ cy.visit(`/?p=${shortcodePostId}`);
+ cy.get('#mc_signup').should('exist');
+ cy.get('#mc_mv_EMAIL').should('exist');
+ cy.get('#mc_signup_submit').should('exist');
+ cy.get('#mc_signup_submit').click();
+ cy.get('.mc_error_msg').should('exist');
+ cy.get('.mc_error_msg').contains(': This value should not be blank.');
+ }
+ });
+ });
+
+ it('Admin can set content options for signup form', () => {
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+
+ // Set content options
+ const header = 'Subscribe to our newsletter';
+ const subHeader =
+ 'Join our mailing list to receive the latest news and updates from our team.';
+ const button = 'Subscribe Now';
+ cy.get('#mc_header_content').clear().type(header);
+ cy.get('#mc_subheader_content').clear().type(subHeader);
+ cy.get('#mc_submit_text').clear().type(button);
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+
+ // Verify content options
+ cy.visit(`/?p=${shortcodePostId}`);
+ cy.get('.mc_custom_border_hdr').contains(header);
+ cy.get('#mc_subheader').contains(subHeader);
+ cy.get('#mc_signup_submit').contains(button);
+
+ cy.visit(`/?p=${blockPostId}`);
+ cy.get('.mc_custom_border_hdr').contains(header);
+ cy.get('#mc_subheader').contains(subHeader);
+ cy.get('#mc_signup_submit').contains(button);
+ });
+});
From ee0884eb9695b8880e159eab2f4f63daf8ea0fe9 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 18:06:56 +0530
Subject: [PATCH 33/48] Added tests for remove CSS and custom styling.
---
tests/cypress/e2e/settings.test.js | 55 ++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/tests/cypress/e2e/settings.test.js b/tests/cypress/e2e/settings.test.js
index 71350a0..51df7f1 100644
--- a/tests/cypress/e2e/settings.test.js
+++ b/tests/cypress/e2e/settings.test.js
@@ -80,4 +80,59 @@ describe('Admin can update plugin settings', () => {
cy.get('#mc_subheader').contains(subHeader);
cy.get('#mc_signup_submit').contains(button);
});
+
+ it('Admin can remove mailchimp CSS', () => {
+ // Remove mailchimp CSS.
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mc_nuke_all_styles').check();
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+
+ // Verify
+ cy.visit(`/?p=${shortcodePostId}`);
+ cy.get('#mc_subheader').should('not.have.css', 'margin-bottom', '18px');
+
+ cy.visit(`/?p=${blockPostId}`);
+ cy.get('#mc_subheader').should('not.have.css', 'margin-bottom', '18px');
+
+ // Enable mailchimp CSS.
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mc_nuke_all_styles').uncheck();
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+
+ // Verify
+ cy.visit(`/?p=${shortcodePostId}`);
+ cy.get('#mc_subheader').should('have.css', 'margin-bottom', '18px');
+
+ cy.visit(`/?p=${blockPostId}`);
+ cy.get('#mc_subheader').should('have.css', 'margin-bottom', '18px');
+ });
+
+ it('Admin can set custom styling on signup form', () => {
+ // Remove mailchimp CSS.
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mc_custom_style').check();
+ cy.get('#mc_form_border_width').clear().type('10');
+ cy.get('#mc_form_border_color').clear().type('000000');
+ cy.get('#mc_form_text_color').clear().type('FF0000');
+ cy.get('#mc_form_background').clear().type('00FF00');
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+
+ // Verify
+ cy.visit(`/?p=${shortcodePostId}`);
+ cy.get('#mc_signup form').should('have.css', 'border-width', '10px');
+ cy.get('#mc_signup form').should('have.css', 'border-color', 'rgb(0, 0, 0)');
+ cy.get('#mc_signup form').should('have.css', 'color', 'rgb(255, 0, 0)');
+ cy.get('#mc_signup form').should('have.css', 'background-color', 'rgb(0, 255, 0)');
+
+ cy.visit(`/?p=${blockPostId}`);
+ cy.get('#mc_signup form').should('have.css', 'border-width', '10px');
+ cy.get('#mc_signup form').should('have.css', 'border-color', 'rgb(0, 0, 0)');
+ cy.get('#mc_signup form').should('have.css', 'color', 'rgb(255, 0, 0)');
+ cy.get('#mc_signup form').should('have.css', 'background-color', 'rgb(0, 255, 0)');
+
+ // Enable mailchimp CSS.
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mc_custom_style').uncheck();
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+ });
});
From 5bfe73e23042d858014304ba50c9a6aa540c8550 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 18:45:34 +0530
Subject: [PATCH 34/48] Added some more settings tests.
---
tests/cypress/e2e/settings.test.js | 118 +++++++++++++++++++++--------
1 file changed, 86 insertions(+), 32 deletions(-)
diff --git a/tests/cypress/e2e/settings.test.js b/tests/cypress/e2e/settings.test.js
index 51df7f1..d19c76f 100644
--- a/tests/cypress/e2e/settings.test.js
+++ b/tests/cypress/e2e/settings.test.js
@@ -70,15 +70,12 @@ describe('Admin can update plugin settings', () => {
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
// Verify content options
- cy.visit(`/?p=${shortcodePostId}`);
- cy.get('.mc_custom_border_hdr').contains(header);
- cy.get('#mc_subheader').contains(subHeader);
- cy.get('#mc_signup_submit').contains(button);
-
- cy.visit(`/?p=${blockPostId}`);
- cy.get('.mc_custom_border_hdr').contains(header);
- cy.get('#mc_subheader').contains(subHeader);
- cy.get('#mc_signup_submit').contains(button);
+ [shortcodePostId, blockPostId].forEach((postId) => {
+ cy.visit(`/?p=${postId}`);
+ cy.get('.mc_custom_border_hdr').contains(header);
+ cy.get('#mc_subheader').contains(subHeader);
+ cy.get('#mc_signup_submit').contains(button);
+ });
});
it('Admin can remove mailchimp CSS', () => {
@@ -88,11 +85,10 @@ describe('Admin can update plugin settings', () => {
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
// Verify
- cy.visit(`/?p=${shortcodePostId}`);
- cy.get('#mc_subheader').should('not.have.css', 'margin-bottom', '18px');
-
- cy.visit(`/?p=${blockPostId}`);
- cy.get('#mc_subheader').should('not.have.css', 'margin-bottom', '18px');
+ [shortcodePostId, blockPostId].forEach((postId) => {
+ cy.visit(`/?p=${postId}`);
+ cy.get('#mc_subheader').should('not.have.css', 'margin-bottom', '18px');
+ });
// Enable mailchimp CSS.
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
@@ -100,15 +96,14 @@ describe('Admin can update plugin settings', () => {
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
// Verify
- cy.visit(`/?p=${shortcodePostId}`);
- cy.get('#mc_subheader').should('have.css', 'margin-bottom', '18px');
-
- cy.visit(`/?p=${blockPostId}`);
- cy.get('#mc_subheader').should('have.css', 'margin-bottom', '18px');
+ [shortcodePostId, blockPostId].forEach((postId) => {
+ cy.visit(`/?p=${postId}`);
+ cy.get('#mc_subheader').should('have.css', 'margin-bottom', '18px');
+ });
});
it('Admin can set custom styling on signup form', () => {
- // Remove mailchimp CSS.
+ // Enable custom styling and set values.
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
cy.get('#mc_custom_style').check();
cy.get('#mc_form_border_width').clear().type('10');
@@ -118,21 +113,80 @@ describe('Admin can update plugin settings', () => {
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
// Verify
- cy.visit(`/?p=${shortcodePostId}`);
- cy.get('#mc_signup form').should('have.css', 'border-width', '10px');
- cy.get('#mc_signup form').should('have.css', 'border-color', 'rgb(0, 0, 0)');
- cy.get('#mc_signup form').should('have.css', 'color', 'rgb(255, 0, 0)');
- cy.get('#mc_signup form').should('have.css', 'background-color', 'rgb(0, 255, 0)');
-
- cy.visit(`/?p=${blockPostId}`);
- cy.get('#mc_signup form').should('have.css', 'border-width', '10px');
- cy.get('#mc_signup form').should('have.css', 'border-color', 'rgb(0, 0, 0)');
- cy.get('#mc_signup form').should('have.css', 'color', 'rgb(255, 0, 0)');
- cy.get('#mc_signup form').should('have.css', 'background-color', 'rgb(0, 255, 0)');
+ [shortcodePostId, blockPostId].forEach((postId) => {
+ cy.visit(`/?p=${postId}`);
+ cy.get('#mc_signup form').should('have.css', 'border-width', '10px');
+ cy.get('#mc_signup form').should('have.css', 'border-color', 'rgb(0, 0, 0)');
+ cy.get('#mc_signup form').should('have.css', 'color', 'rgb(255, 0, 0)');
+ cy.get('#mc_signup form').should('have.css', 'background-color', 'rgb(0, 255, 0)');
+ });
- // Enable mailchimp CSS.
+ // Reset
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
cy.get('#mc_custom_style').uncheck();
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
});
+
+ it('Admin can set Merge Fields Included settings', () => {
+ // Remove mailchimp CSS.
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mc_mv_FNAME').uncheck();
+ cy.get('#mc_mv_LNAME').uncheck();
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+
+ // Verify
+ [shortcodePostId, blockPostId].forEach((postId) => {
+ cy.visit(`/?p=${postId}`);
+ cy.get('#mc_mv_FNAME').should('not.exist');
+ cy.get('#mc_mv_LNAME').should('not.exist');
+ });
+
+ // Reset
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mc_mv_FNAME').check();
+ cy.get('#mc_mv_LNAME').check();
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+
+ // Verify
+ [shortcodePostId, blockPostId].forEach((postId) => {
+ cy.visit(`/?p=${postId}`);
+ cy.get('#mc_mv_FNAME').should('exist');
+ cy.get('#mc_mv_LNAME').should('exist');
+ });
+ });
+
+ it('Admin can set list options settings', () => {
+ // Remove mailchimp CSS.
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mc_use_javascript').uncheck();
+ cy.get('#mc_use_datepicker').uncheck();
+ cy.get('#mc_use_unsub_link').check();
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+
+ // Verify
+ [shortcodePostId, blockPostId].forEach((postId) => {
+ cy.visit(`/?p=${postId}`);
+ cy.get('#mc_submit_type').should('have.value', 'html');
+ cy.get('#mc_mv_BIRTHDAY').should('not.have.class', 'hasDatepicker');
+ cy.get('#mc_mv_BIRTHDAY').click();
+ cy.get('#ui-datepicker-div').should('not.exist');
+ cy.get('#mc_unsub_link').should('exist');
+ });
+
+ // Reset
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mc_use_javascript').check();
+ cy.get('#mc_use_datepicker').check();
+ cy.get('#mc_use_unsub_link').uncheck();
+ cy.get('input[value="Update Subscribe Form Settings"]').first().click();
+
+ [shortcodePostId, blockPostId].forEach((postId) => {
+ cy.visit(`/?p=${postId}`);
+ cy.get('#mc_submit_type').should('have.value', 'js');
+ cy.get('#mc_mv_BIRTHDAY').should('have.class', 'hasDatepicker');
+ cy.get('#mc_mv_BIRTHDAY').click();
+ cy.get('#ui-datepicker-div').should('exist');
+ cy.get('#mc_unsub_link').should('not.exist');
+ });
+ });
});
From a63ad6072a678bbb44994765c7bd2a54b87f7b60 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 18:51:12 +0530
Subject: [PATCH 35/48] Add logout tests.
---
tests/cypress/e2e/settings.test.js | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/cypress/e2e/settings.test.js b/tests/cypress/e2e/settings.test.js
index d19c76f..8d06de2 100644
--- a/tests/cypress/e2e/settings.test.js
+++ b/tests/cypress/e2e/settings.test.js
@@ -189,4 +189,13 @@ describe('Admin can update plugin settings', () => {
cy.get('#mc_unsub_link').should('not.exist');
});
});
+
+ it('Admin can logout', () => {
+ cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
+ cy.get('#mailchimp_sf_oauth_connect').should('not.exist');
+ cy.get('input[value="Logout"]').click();
+
+ // connect to "Mailchimp" Account button should be visible.
+ cy.get('#mailchimp_sf_oauth_connect').should('exist');
+ });
});
From 91f09c2b9a23549dddefe035050b6b804f688fc5 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 19:08:48 +0530
Subject: [PATCH 36/48] Updated E2E workflow file.
---
.github/workflows/e2e.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index ec60018..db40edc 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -13,6 +13,9 @@ jobs:
cypress:
name: ${{ matrix.core.name }}
runs-on: ubuntu-latest
+ env:
+ CYPRESS_MAILCHIMP_USERNAME: ${{ secrets.MAILCHIMP_USERNAME }}
+ CYPRESS_MAILCHIMP_PASSWORD: ${{ secrets.MAILCHIMP_PASSWORD }}
strategy:
matrix:
core:
From 6e7dc0830a682835b4965918ba2eaad9192c5147 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 19:09:01 +0530
Subject: [PATCH 37/48] Readme updates.
---
README.md | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/README.md b/README.md
index 41e20b0..35fa33e 100644
--- a/README.md
+++ b/README.md
@@ -104,6 +104,23 @@ Currently we have the plugin configured so it can be translated and the followin
* sv_SE - Swedish in Sweden (thanks to [Sebastian Johnsson](http://www.agiley.se/) for contributing)
* tr_TR - Turkish in Turkey (thanks to [Hakan E.](http://kazancexpert.com/) for contributing)
+## E2E tests
+The `tests` directory contains end-to-end tests for the project, utilizing Cypress to run tests in an environment created using wp-env.
+
+### Pre-requisites
+- Node.js v20
+- Docker
+- Create an account in [Mailchimp](https://mailchimp.com/)
+
+### Run E2E tests in local
+1. Run `npm install`.
+2. Run `npm run build`.
+3. Run `npm run env:start`.
+4. Set Mailchimp credentials as environment variables:
+ - run `export CYPRESS_MAILCHIMP_USERNAME="your mailchimp username"`
+ - run `export CYPRESS_MAILCHIMP_PASSWORD="your mailchimp password"`
+5. Run `npm run cypress:run`. You can also run `npm run cypress:open` to run tests in UI mode.
+
## Support Level
**Active:** Mailchimp is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.
From a1c810284ee6a6ee85f10dbe148be54996d06e0d Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 20:04:11 +0530
Subject: [PATCH 38/48] Trigger E2E tests.
---
tests/cypress/e2e/connect.test.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/cypress/e2e/connect.test.js b/tests/cypress/e2e/connect.test.js
index 79f027d..411bcd9 100644
--- a/tests/cypress/e2e/connect.test.js
+++ b/tests/cypress/e2e/connect.test.js
@@ -29,7 +29,7 @@ describe('Admin can connect to "Mailchimp" Account', () => {
cy.wait(8000); // Not a best practice, but did not find a better way to handle this.
cy.popup().find('input#submitButton').click();
- cy.wait(10000);
+ cy.wait(10000); // Not a best practice, but did not find a better way to handle this.
cy.get('.mc-user h3').contains('Logged in as: ');
cy.get('input[value="Logout"]').should('exist');
From 554fa372ba3fb9d8e91333053320adb5a45c328d Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Thu, 8 Aug 2024 20:28:02 +0530
Subject: [PATCH 39/48] Add block name in insertBlock command.
---
tests/cypress/e2e/connect.test.js | 4 ++--
tests/cypress/e2e/settings.test.js | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/cypress/e2e/connect.test.js b/tests/cypress/e2e/connect.test.js
index 411bcd9..e29942a 100644
--- a/tests/cypress/e2e/connect.test.js
+++ b/tests/cypress/e2e/connect.test.js
@@ -21,12 +21,12 @@ describe('Admin can connect to "Mailchimp" Account', () => {
cy.capturePopup();
cy.get('#mailchimp_sf_oauth_connect').click();
- cy.wait(5000);
+ cy.wait(6000);
cy.popup().find('input#username').clear().type(Cypress.env('MAILCHIMP_USERNAME'));
cy.popup().find('input#password').clear().type(Cypress.env('MAILCHIMP_PASSWORD'));
cy.popup().find('button[type="submit"]').click();
- cy.wait(8000); // Not a best practice, but did not find a better way to handle this.
+ cy.wait(10000); // Not a best practice, but did not find a better way to handle this.
cy.popup().find('input#submitButton').click();
cy.wait(10000); // Not a best practice, but did not find a better way to handle this.
diff --git a/tests/cypress/e2e/settings.test.js b/tests/cypress/e2e/settings.test.js
index 8d06de2..a6d411b 100644
--- a/tests/cypress/e2e/settings.test.js
+++ b/tests/cypress/e2e/settings.test.js
@@ -40,7 +40,7 @@ describe('Admin can update plugin settings', () => {
it('Admin can create a Signup form using Mailchimp block', () => {
const postTitle = 'Mailchimp signup form - Block';
const beforeSave = () => {
- cy.insertBlock('mailchimp/mailchimp');
+ cy.insertBlock('mailchimp/mailchimp', 'Mailchimp List Subscribe Form');
};
cy.createPost({ title: postTitle, content: '', beforeSave }).then((post) => {
if (post) {
From 57c0058b8ea70d13a3970992a25fc9bfc4e6b2b4 Mon Sep 17 00:00:00 2001
From: Dharmesh Patel
Date: Fri, 9 Aug 2024 12:44:53 +0530
Subject: [PATCH 40/48] Addressed improvements feedback.
---
includes/class-mailchimp-admin.php | 2 +-
lib/mailchimp/mailchimp.php | 2 ++
mailchimp.php | 10 ++++++++++
mailchimp_widget.php | 4 ++++
views/setup_page.php | 2 +-
5 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/includes/class-mailchimp-admin.php b/includes/class-mailchimp-admin.php
index 1a243a9..0322d52 100644
--- a/includes/class-mailchimp-admin.php
+++ b/includes/class-mailchimp-admin.php
@@ -206,7 +206,7 @@ public function admin_notices() {
// Display a notice if the access token is invalid/revoked.
?>
-