-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from mailchimp/enhancement/e2e-tests
Add E2E tests
- Loading branch information
Showing
11 changed files
with
380 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,46 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require( 'fs' ); | ||
const { exit } = require( 'process' ); | ||
|
||
const path = `${ process.cwd() }/.wp-env.override.json`; | ||
const path = `${ process.cwd() }/.wp-env.json`; | ||
|
||
// eslint-disable-next-line import/no-dynamic-require | ||
const config = fs.existsSync( path ) ? require( path ) : {}; | ||
let config = fs.existsSync( path ) ? require( path ) : { plugins: [ '.' ] }; | ||
|
||
const args = process.argv.slice( 2 ); | ||
const args = {}; | ||
process.argv | ||
.slice(2, process.argv.length) | ||
.forEach( arg => { | ||
if (arg.slice(0,2) === '--') { | ||
const param = arg.split('='); | ||
const paramName = param[0].slice(2,param[0].length); | ||
const paramValue = param.length > 1 ? param[1] : true; | ||
args[paramName] = paramValue; | ||
} | ||
}); | ||
|
||
if ( args.length === 0 ) exit( 0 ); | ||
if ( ! args.core && ! args.plugins ) { | ||
return; | ||
} | ||
|
||
if ( 'latest' === args.core ) { | ||
delete args.core; | ||
} | ||
|
||
if ( args[ 0 ] === 'latest' ) { | ||
if ( fs.existsSync( path ) ) { | ||
fs.unlinkSync( path ); | ||
} | ||
exit( 0 ); | ||
if( Object.keys(args).length === 0 ) { | ||
return; | ||
} | ||
|
||
config.core = args[ 0 ]; | ||
if ( args.plugins ) { | ||
args.plugins = args.plugins.split(','); | ||
} | ||
|
||
// eslint-disable-next-line no-useless-escape | ||
if ( ! config.core.match( /^WordPress\/WordPress\#/ ) ) { | ||
config.core = `WordPress/WordPress#${ config.core }`; | ||
config = { | ||
...config, | ||
...args, | ||
} | ||
|
||
try { | ||
fs.writeFileSync( path, JSON.stringify( config ) ); | ||
fs.writeFileSync( path, JSON.stringify( config ) ); | ||
} catch ( err ) { | ||
// eslint-disable-next-line no-console | ||
console.error( err ); | ||
console.error( err ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* 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(6000); | ||
|
||
cy.popup() | ||
.find('input#username') | ||
.clear() | ||
.type(Cypress.env('MAILCHIMP_USERNAME'), { force: true }); | ||
cy.popup() | ||
.find('input#password') | ||
.clear() | ||
.type(Cypress.env('MAILCHIMP_PASSWORD'), { force: true }); | ||
cy.popup().find('button[type="submit"]').click({ force: true }); | ||
cy.wait(10000); // Not a best practice, but did not find a better way to handle this. | ||
|
||
cy.popup().find('input#submitButton').click({ force: true }); | ||
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'); | ||
}); | ||
}); |
Oops, something went wrong.