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

Add async/await into /specs #1154

Merged
merged 11 commits into from
Apr 24, 2018
67 changes: 32 additions & 35 deletions specs/wp-log-in-out-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ let driver;

let eyes = eyesHelper.eyesSetup( true );

test.before( function() {
test.before( async function() {
this.timeout( startBrowserTimeoutMS );
driver = driverManager.startBrowser();
driver = await driverManager.startBrowser();
} );

test.describe(
Expand All @@ -51,57 +51,55 @@ test.describe(
} );

test.describe( 'Logging In and Out:', function() {
test.before( function() {
return driverManager.clearCookiesAndDeleteLocalStorage( driver );
test.before( async function() {
return await driverManager.clearCookiesAndDeleteLocalStorage( driver );
} );

test.describe( 'Can Log In', function() {
test.it( 'Can log in', function() {
test.it( 'Can log in', async function() {
let loginFlow = new LoginFlow( driver );
loginFlow.login( { screenshot: true }, eyes );
await loginFlow.login( { screenshot: true }, eyes );
} );

test.it( 'Can see Reader Page after logging in', function() {
test.it( 'Can see Reader Page after logging in', async function() {
let readerPage = new ReaderPage( driver );
readerPage.displayed().then( function( displayed ) {
assert.equal( displayed, true, 'The reader page is not displayed after log in' );
} );
let displayed = await readerPage.displayed();
assert.equal( displayed, true, 'The reader page is not displayed after log in' );
} );
} );

// Test Jetpack SSO
if ( host !== 'WPCOM' ) {
test.describe( 'Can Log via Jetpack SSO', function() {
test.it( 'Can log into site via Jetpack SSO', () => {
test.it( 'Can log into site via Jetpack SSO', async () => {
let loginFlow = new LoginFlow( driver );
return loginFlow.login( { jetpackSSO: true } );
return await loginFlow.login( { jetpackSSO: true } );
} );

test.it( 'Can return to Reader', () => {
test.it( 'Can return to Reader', async () => {
let readerPage = new ReaderPage( driver, true );
return readerPage.displayed();
return await readerPage.displayed();
} );
} );
}

test.describe( 'Can Log Out', function() {
test.it( 'Can view profile to log out', function() {
test.it( 'Can view profile to log out', async function() {
let navbarComponent = new NavbarComponent( driver );
navbarComponent.clickProfileLink();
await navbarComponent.clickProfileLink();
} );

test.it( 'Can logout from profile page', function() {
test.it( 'Can logout from profile page', async function() {
let profilePage = new ProfilePage( driver );
profilePage.waitForProfileLinks();
eyesHelper.eyesScreenshot( driver, eyes, 'Me Profile Page' );
profilePage.clickSignOut();
await profilePage.waitForProfileLinks();
await eyesHelper.eyesScreenshot( driver, eyes, 'Me Profile Page' );
await profilePage.clickSignOut();
} );

test.it( 'Can see wordpress.com home when after logging out', function() {
test.it( 'Can see wordpress.com home when after logging out', async function() {
const loggedOutMasterbarComponent = new LoggedOutMasterbarComponent( driver );
loggedOutMasterbarComponent.displayed().then( displayed => {
assert( displayed, "The logged out masterbar isn't displayed after logging out" );
} );
let displayed = await loggedOutMasterbarComponent.displayed();
assert( displayed, "The logged out masterbar isn't displayed after logging out" );
} );
} );
} );
Expand Down Expand Up @@ -403,8 +401,8 @@ test.describe(
// } );
// }

test.after( function() {
eyesHelper.eyesClose( eyes );
test.after( async function() {
await eyesHelper.eyesClose( eyes );
} );
}
);
Expand All @@ -413,17 +411,16 @@ test.describe( `[${ host }] User Agent: (${ screenSize }) @parallel @jetpack`, f
this.timeout( mochaTimeOut );
this.bailSuite( true );

test.before( function() {
driverManager.clearCookiesAndDeleteLocalStorage( driver );
test.before( async function() {
await driverManager.clearCookiesAndDeleteLocalStorage( driver );
} );

test.it( 'Can see the correct user agent set', function() {
test.it( 'Can see the correct user agent set', async function() {
this.wpHomePage = new WPHomePage( driver, { visit: true } );
driver.executeScript( 'return navigator.userAgent;' ).then( userAgent => {
assert(
userAgent.match( 'wp-e2e-tests' ),
`User Agent does not contain 'wp-e2e-tests'. [${ userAgent }]`
);
} );
let userAgent = await driver.executeScript( 'return navigator.userAgent;' );
assert(
userAgent.match( 'wp-e2e-tests' ),
`User Agent does not contain 'wp-e2e-tests'. [${ userAgent }]`
);
} );
} );
133 changes: 68 additions & 65 deletions specs/wp-manage-domains-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const host = dataHelper.getJetpackHost();

let driver;

test.before( function() {
test.before( async function() {
this.timeout( startBrowserTimeoutMS );
driver = driverManager.startBrowser();
driver = await driverManager.startBrowser();
} );

test.describe( `[${ host }] Managing Domains: (${ screenSize }) @parallel`, function() {
Expand All @@ -48,55 +48,59 @@ test.describe( `[${ host }] Managing Domains: (${ screenSize }) @parallel`, func
const expectedDomainName = blogName + '.com';
const testDomainRegistarDetails = dataHelper.getTestDomainRegistarDetails( domainEmailAddress );

test.before( function() {
return driverManager.ensureNotLoggedIn( driver );
test.before( async function() {
return await driverManager.ensureNotLoggedIn( driver );
} );

test.it( 'Log In and Select Domains', function() {
return new LoginFlow( driver ).loginAndSelectDomains();
test.it( 'Log In and Select Domains', async function() {
return await new LoginFlow( driver ).loginAndSelectDomains();
} );

test.it( 'Can see the Domains page and choose add a domain', function() {
test.it( 'Can see the Domains page and choose add a domain', async function() {
const domainsPage = new DomainsPage( driver );
driver.getCurrentUrl().then( urlDisplayed => {
domainsPage.setABTestControlGroupsInLocalStorage( urlDisplayed );
} );
return domainsPage.clickAddDomain();
let urlDisplayed = await driver.getCurrentUrl();
await domainsPage.setABTestControlGroupsInLocalStorage( urlDisplayed );
return await domainsPage.clickAddDomain();
} );

test.it( 'Can see the domain search component', function() {
return new FindADomainComponent( driver ).waitForResults();
test.it( 'Can see the domain search component', async function() {
return await new FindADomainComponent( driver ).waitForResults();
} );

test.it( 'Can search for a blog name', function() {
return new FindADomainComponent( driver ).searchForBlogNameAndWaitForResults( blogName );
test.it( 'Can search for a blog name', async function() {
return await new FindADomainComponent( driver ).searchForBlogNameAndWaitForResults(
blogName
);
} );

test.it( 'Can select the .com search result and decline Google Apps for email', function() {
const findADomainComponent = new FindADomainComponent( driver );
findADomainComponent.selectDomainAddress( expectedDomainName );
return findADomainComponent.declineGoogleApps();
} );
test.it(
'Can select the .com search result and decline Google Apps for email',
async function() {
const findADomainComponent = new FindADomainComponent( driver );
await findADomainComponent.selectDomainAddress( expectedDomainName );
return await findADomainComponent.declineGoogleApps();
}
);

test.it( 'Can see checkout page, choose privacy and enter registrar details', function() {
test.it( 'Can see checkout page, choose privacy and enter registrar details', async function() {
const checkOutPage = new CheckOutPage( driver );
checkOutPage.selectAddPrivacyProtectionCheckbox();
checkOutPage.enterRegistarDetails( testDomainRegistarDetails );
return checkOutPage.submitForm();
await checkOutPage.selectAddPrivacyProtectionCheckbox();
await checkOutPage.enterRegistarDetails( testDomainRegistarDetails );
return await checkOutPage.submitForm();
} );

test.it( 'Can then see secure payment component', function() {
return new SecurePaymentComponent( driver ).displayed();
test.it( 'Can then see secure payment component', async function() {
return await new SecurePaymentComponent( driver ).displayed();
} );

test.after( function() {
test.after( async function() {
// Empty the cart
new ReaderPage( driver, true ).displayed();
new NavbarComponent( driver ).clickMySites();
new StatsPage( driver, true ).displayed();
new SidebarComponent( driver ).selectDomains();
new DomainsPage( driver ).displayed();
return new ShoppingCartWidgetComponent( driver ).empty();
await new ReaderPage( driver, true ).displayed();
await new NavbarComponent( driver ).clickMySites();
await new StatsPage( driver, true ).displayed();
await new SidebarComponent( driver ).selectDomains();
await new DomainsPage( driver ).displayed();
return await new ShoppingCartWidgetComponent( driver ).empty();
} );
} );

Expand All @@ -105,62 +109,61 @@ test.describe( `[${ host }] Managing Domains: (${ screenSize }) @parallel`, func

const blogName = 'myawesomedomain.com';

test.before( function() {
return driverManager.ensureNotLoggedIn( driver );
test.before( async function() {
return await driverManager.ensureNotLoggedIn( driver );
} );

test.it( 'Log In and Select Domains', function() {
return new LoginFlow( driver ).loginAndSelectDomains();
test.it( 'Log In and Select Domains', async function() {
return await new LoginFlow( driver ).loginAndSelectDomains();
} );

test.it( 'Can see the Domains page and choose add a domain', function() {
test.it( 'Can see the Domains page and choose add a domain', async function() {
const domainsPage = new DomainsPage( driver );
driver.getCurrentUrl().then( urlDisplayed => {
domainsPage.setABTestControlGroupsInLocalStorage( urlDisplayed );
} );
return domainsPage.clickAddDomain();
let urlDisplayed = await driver.getCurrentUrl();
await domainsPage.setABTestControlGroupsInLocalStorage( urlDisplayed );
return await domainsPage.clickAddDomain();
} );

test.it( 'Can see the domain search component', function() {
return new FindADomainComponent( driver ).waitForResults();
test.it( 'Can see the domain search component', async function() {
return await new FindADomainComponent( driver ).waitForResults();
} );

test.it( 'Can select to use an existing domain', function() {
return new FindADomainComponent( driver ).selectUseOwnDomain();
test.it( 'Can select to use an existing domain', async function() {
return await new FindADomainComponent( driver ).selectUseOwnDomain();
} );

test.it( 'Can see use my own domain page', function() {
return new MyOwnDomainPage( driver ).displayed();
test.it( 'Can see use my own domain page', async function() {
return await new MyOwnDomainPage( driver ).displayed();
} );

test.it( 'Can select to manually connect existing domain component', function() {
return new MapADomainComponent( driver ).selectManuallyConnectExistingDomain();
test.it( 'Can select to manually connect existing domain component', async function() {
return await new MapADomainComponent( driver ).selectManuallyConnectExistingDomain();
} );

test.it( 'Can see enter a domain component', function() {
return new MapADomainPage( driver ).displayed();
test.it( 'Can see enter a domain component', async function() {
return await new MapADomainPage( driver ).displayed();
} );

test.it( 'Can enter the domain name', function() {
return new EnterADomainComponent( driver ).enterADomain( blogName );
test.it( 'Can enter the domain name', async function() {
return await new EnterADomainComponent( driver ).enterADomain( blogName );
} );

test.it( 'Can add domain to the cart', function() {
return new EnterADomainComponent( driver ).clickonAddButtonToAddDomainToTheCart();
test.it( 'Can add domain to the cart', async function() {
return await new EnterADomainComponent( driver ).clickonAddButtonToAddDomainToTheCart();
} );

test.it( 'Can see checkout page', function() {
return new MapADomainCheckoutPage( driver ).displayed();
test.it( 'Can see checkout page', async function() {
return await new MapADomainCheckoutPage( driver ).displayed();
} );

test.after( function() {
test.after( async function() {
// Empty the cart
new ReaderPage( driver, true ).displayed();
new NavbarComponent( driver ).clickMySites();
new StatsPage( driver, true ).displayed();
new SidebarComponent( driver ).selectDomains();
new DomainsPage( driver ).displayed();
return new ShoppingCartWidgetComponent( driver ).empty();
await new ReaderPage( driver, true ).displayed();
await new NavbarComponent( driver ).clickMySites();
await new StatsPage( driver, true ).displayed();
await new SidebarComponent( driver ).selectDomains();
await new DomainsPage( driver ).displayed();
return await new ShoppingCartWidgetComponent( driver ).empty();
} );
} );
} );
Loading