Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Run Jetpack smoke test against multiple test accounts (#1365)
Browse files Browse the repository at this point in the history
* Run Jetpack smoke test against multiple test accounts

* Add Jetpack users and refine spec file
  • Loading branch information
brbrr authored and abidhahmed committed Jul 25, 2018
1 parent 4e06f74 commit b342aa5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
Binary file modified config/encrypted.enc
Binary file not shown.
3 changes: 2 additions & 1 deletion lib/flows/jetpack-connect-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default class JetpackConnectFlow {
async disconnectFromWPAdmin( account ) {
// 'Login into wporg site'
const user = dataHelper.getAccountConfig( account );
await driverManager.clearCookiesAndDeleteLocalStorage( this.driver );
const loginPage = await WPAdminLogonPage.Visit( this.driver, user[ 2 ] );
await loginPage.login( user[ 0 ], user[ 1 ] );

Expand All @@ -106,6 +107,6 @@ export default class JetpackConnectFlow {
// 'Can disconnect site if connected'
const wpAdminJetpack = await WPAdminJetpackPage.Expect( this.driver );
if ( ! await wpAdminJetpack.atAGlanceDisplayed() ) return;
return wpAdminJetpack.disconnectSite();
return await wpAdminJetpack.disconnectSite();
}
}
6 changes: 5 additions & 1 deletion lib/pages/wp-admin/wp-admin-jetpack-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export default class WPAdminJetpackPage extends AsyncBaseContainer {
await driverHelper.clickWhenClickable( this.driver, manageConnectionButton );
await driverHelper.clickWhenClickable( this.driver, disconnectButton );

return await driverHelper.waitTillPresentAndDisplayed( this.driver, successDisconnectNotice );
return await driverHelper.waitTillPresentAndDisplayed(
this.driver,
successDisconnectNotice,
this.explicitWaitMS * 2
);
}
}
4 changes: 2 additions & 2 deletions lib/pages/wp-admin/wp-admin-posts-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export default class WPAdminPostsPage extends AsyncBaseContainer {
}

async viewFirstPost() {
const viewAnchor = By.css( '.row-actions .view a' );
const viewAnchor = By.css( '.status-publish .row-actions .view a' );
const postPage = By.css( '#page' );

await driverHelper.waitTillPresentAndDisplayed( this.driver, viewAnchor );
await driverHelper.followLinkWhenFollowable( this.driver, viewAnchor );
return await driverHelper.waitTillPresentAndDisplayed( this.driver, postPage );
}
Expand Down
20 changes: 15 additions & 5 deletions specs-jetpack/connect-disconnect-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import WPAdminLogonPage from '../lib/pages/wp-admin/wp-admin-logon-page';
import WPAdminSidebar from '../lib/pages/wp-admin/wp-admin-sidebar.js';
import JetpackConnectFlow from '../lib/flows/jetpack-connect-flow';
import WPAdminPostsPage from '../lib/pages/wp-admin/wp-admin-posts-page';
import WPAdminDashboardPage from '../lib/pages/wp-admin/wp-admin-dashboard-page';
import * as driverManager from '../lib/driver-manager';
import * as dataHelper from '../lib/data-helper';

const mochaTimeOut = config.get( 'mochaTimeoutMS' );
const startBrowserTimeoutMS = config.get( 'startBrowserTimeoutMS' );
const screenSize = driverManager.currentScreenSize();
const user = dataHelper.getAccountConfig( 'asoJetpackUser' );
const jetpackUser = process.env.JETPACKUSER;
const user = dataHelper.getAccountConfig( jetpackUser );
let driver;

before( async function() {
Expand All @@ -27,11 +29,11 @@ describe( 'Disconnect wporg site', function() {
this.timeout( mochaTimeOut );

step( 'Can disconnect wporg site', async function() {
await driverManager.ensureNotLoggedIn( driver );
await driverManager.clearCookiesAndDeleteLocalStorage( driver, user[ 2 ] );
await new JetpackConnectFlow( driver, 'jetpackConnectUser' ).disconnectFromWPAdmin(
'asoJetpackUser'
jetpackUser
);
await driverManager.clearCookiesAndDeleteLocalStorage( driver );
await driverManager.clearCookiesAndDeleteLocalStorage( driver, user[ 2 ] );
} );
} );

Expand Down Expand Up @@ -69,6 +71,14 @@ describe( `Jetpack Connect and Disconnect: (${ screenSize })`, function() {
} );

step( 'Can click the free plan button', async function() {
// Some of the users are not the plan owners, so skipping this step for them
if (
[ 'siteGroundJetpackUser', 'bluehostJetpackUserSub', 'goDaddyJetpackUserSub' ].includes(
jetpackUser
)
) {
return await WPAdminDashboardPage.Visit( driver, user[ 2 ] );
}
const pickAPlanPage = await PickAPlanPage.Expect( driver );
return await pickAPlanPage.selectFreePlanJetpack();
} );
Expand All @@ -88,7 +98,7 @@ describe( `Jetpack Connect and Disconnect: (${ screenSize })`, function() {
step( 'Can disconnect Jetpack connection in wp-admin', async function() {
await driverManager.clearCookiesAndDeleteLocalStorage( driver, user[ 2 ] );
await new JetpackConnectFlow( driver, 'jetpackConnectUser' ).disconnectFromWPAdmin(
'asoJetpackUser'
jetpackUser
);
} );

Expand Down
11 changes: 11 additions & 0 deletions specs-jetpack/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
export JETPACKHOST=PRESSABLE
export TARGET=JETPACK
array=( 'goDaddyJetpackUser' 'asoJetpackUser' 'goDaddyJetpackUserSub'
'bluehostJetpackUser' 'bluehostJetpackUserSub' 'siteGroundJetpackUser')

for i in "${array[@]}"
do
export JETPACKUSER="$i"
eval "./node_modules/.bin/mocha ./specs-jetpack/connect-disconnect-spec.js &"
done

0 comments on commit b342aa5

Please sign in to comment.