Skip to content

Commit 169aed7

Browse files
committed
Merge branch 'fix/e2e-tests' of github.com:mailchimp/wordpress into release/1.7.0
2 parents 697dc56 + 359123e commit 169aed7

18 files changed

+152
-456
lines changed

tests/cypress/config.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const { defineConfig } = require( 'cypress' );
2-
const { loadConfig } = require( '@wordpress/env/lib/config' );
3-
const getCacheDirectory = require( '@wordpress/env/lib/config/get-cache-directory' );
1+
const { defineConfig } = require('cypress');
2+
const { loadConfig } = require('@wordpress/env/lib/config');
3+
const getCacheDirectory = require('@wordpress/env/lib/config/get-cache-directory');
44
const dotenvPlugin = require('cypress-dotenv');
55

6-
module.exports = defineConfig( {
6+
module.exports = defineConfig({
77
chromeWebSecurity: false,
88
fixturesFolder: 'tests/cypress/fixtures',
99
screenshotsFolder: 'tests/cypress/screenshots',
@@ -13,21 +13,24 @@ module.exports = defineConfig( {
1313
reporter: 'mochawesome',
1414
reporterOptions: {
1515
mochaFile: 'mochawesome-[name]',
16-
reportDir: __dirname + '/reports',
16+
reportDir: `${__dirname}/reports`,
1717
overwrite: false,
1818
html: false,
1919
json: true,
2020
},
2121
e2e: {
22-
setupNodeEvents( on, config ) {
22+
setupNodeEvents(on, config) {
2323
config = dotenvPlugin(config, { path: '../../.env.test' }); // Load .env variables into Cypress
24-
return setBaseUrl( on, config );
24+
return setBaseUrl(on, config);
2525
},
2626
specPattern: [
27-
'tests/cypress/e2e/admin.test.js',
27+
'tests/cypress/e2e/settings/admin.test.js',
2828
'tests/cypress/e2e/connect.test.js',
29-
'tests/cypress/e2e/settings.test.js',
30-
'tests/cypress/e2e/mailchimp-block.test.js',
29+
'tests/cypress/e2e/settings/list.test.js',
30+
'tests/cypress/e2e/settings/settings.test.js',
31+
'tests/cypress/e2e/submission/**.test.js',
32+
'tests/cypress/e2e/validation/**.test.js',
33+
'tests/cypress/e2e/block.test.js',
3134
'tests/cypress/e2e/logout.test.js',
3235
],
3336
supportFile: 'tests/cypress/support/index.js',
@@ -38,23 +41,23 @@ module.exports = defineConfig( {
3841
runMode: 2,
3942
openMode: 0,
4043
},
41-
} );
44+
});
4245

4346
/**
4447
* Set WP URL as baseUrl in Cypress config.
4548
*
4649
* @param {Function} on function that used to register listeners on various events.
47-
* @param {Object} config Cypress Config object.
48-
* @return {Object} Updated Cypress Config object.
50+
* @param {object} config Cypress Config object.
51+
* @returns {object} Updated Cypress Config object.
4952
*/
50-
const setBaseUrl = async ( on, config ) => {
53+
const setBaseUrl = async (on, config) => {
5154
const cacheDirectory = await getCacheDirectory();
52-
const wpEnvConfig = await loadConfig( cacheDirectory );
55+
const wpEnvConfig = await loadConfig(cacheDirectory);
5356

54-
if ( wpEnvConfig ) {
57+
if (wpEnvConfig) {
5558
const port = wpEnvConfig.env.tests.port || null;
5659

57-
if ( port ) {
60+
if (port) {
5861
config.baseUrl = wpEnvConfig.env.tests.config.WP_SITEURL;
5962
}
6063
}

tests/cypress/e2e/mailchimp-block.test.js renamed to tests/cypress/e2e/block.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ describe('Block Tests', () => {
44

55
before(() => {
66
cy.login();
7+
cy.mailchimpLoginIfNotAlreadyLoggedIn();
8+
cy.toggleMergeFields('check');
9+
10+
// Hide all interest groups
11+
cy.visit('/wp-admin/admin.php?page=mailchimp_sf_options');
12+
cy.get('input[id^="mc_show_interest_groups_"]').uncheck();
13+
cy.get('input[value="Update Subscribe Form Settings"]').first().click();
714
});
815

916
it('Admin can create a Signup form using Mailchimp block', () => {

tests/cypress/e2e/settings.test.js

Lines changed: 0 additions & 200 deletions
This file was deleted.

tests/cypress/e2e/settings/list.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ describe('Mailchimp lists ', () => {
66
before(() => {
77
// Load the post URLs from the JSON file
88
cy.fixture('postUrls').then((urls) => {
9-
shortcodePostURL = urls.shortcodePostURL;
10-
blockPostPostURL = urls.blockPostPostURL;
9+
({ shortcodePostURL, blockPostPostURL } = urls);
1110
});
1211

1312
cy.login(); // WP
@@ -40,7 +39,7 @@ describe('Mailchimp lists ', () => {
4039
// Verify that list can be saved
4140
cy.get('.mc-h2').contains('Your Lists');
4241
cy.selectList('10up');
43-
cy.get('#mc-message .success_msg b').contains('Success!');
42+
cy.get('.notice.notice-success.is-dismissible').first().contains('Success!');
4443

4544
// Verify that the settings are visible if a list is saved
4645
cy.get('input[value="Update Subscribe Form Settings"]').should('exist');

0 commit comments

Comments
 (0)