Skip to content

Commit

Permalink
Use closures to read driver instead of passing it as args (#50736)
Browse files Browse the repository at this point in the history
  • Loading branch information
scinos authored Mar 4, 2021
1 parent 26c1750 commit 19043b6
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions test/e2e/specs/wp-calypso-gutenberg-upgrade-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const startBrowserTimeoutMS = config.get( 'startBrowserTimeoutMS' );
const screenSize = driverManager.currentScreenSize();
const host = dataHelper.getJetpackHost();

let driver;
let editor;
let sampleImages;

Expand Down Expand Up @@ -99,11 +100,10 @@ async function insertBlock( Block ) {
/**
* Starts a new post in the editor. User must be logged-in.
*
* @param {object} driver WebDriver instance
* @param {object} loginFlow Instance of the LoginFlow helper.
* @returns {object} Instance of the GutenbergEditorComponent.
*/
async function startNewPost( driver, loginFlow ) {
async function startNewPost( loginFlow ) {
await ReaderPage.Visit( driver );
await NavBarComponent.Expect( driver );

Expand Down Expand Up @@ -136,10 +136,9 @@ function verifyBlockInEditor( Block ) {
/**
* Re-usable collection of steps for verifying blocks in the frontend/published page.
*
* @param {object} driver WebDriver instance
* @param {Function} Block A block class.
*/
function verifyBlockInPublishedPage( driver, Block ) {
function verifyBlockInPublishedPage( Block ) {
step( 'Publish page', async function () {
await editor.publish( { visit: true } );
} );
Expand All @@ -159,8 +158,6 @@ function verifyBlockInPublishedPage( driver, Block ) {
}

describe( `[${ host }, ${ screenSize }] Test Gutenberg upgrade against most popular blocks:`, function () {
let driver;

before( async function () {
if ( process.env.GUTENBERG_EDGE === 'true' ) {
sampleImages = times( 3, () => mediaHelper.createFile() );
Expand Down Expand Up @@ -206,7 +203,7 @@ describe( `[${ host }, ${ screenSize }] Test Gutenberg upgrade against most popu
const loginFlow = new LoginFlow( driver, 'gutenbergUpgradeUser' );

await loginFlow.login();
editor = await startNewPost( driver, loginFlow );
editor = await startNewPost( loginFlow );
} );

step( `Insert and configure the block`, async function () {
Expand All @@ -219,15 +216,15 @@ describe( `[${ host }, ${ screenSize }] Test Gutenberg upgrade against most popu
currentGutenbergBlocksCode = await editor.getBlocksCode();
} );

verifyBlockInPublishedPage( driver, Block );
verifyBlockInPublishedPage( Block );
} );

describe( `Test the same block on a corresponding edge site`, function () {
step( `Start a new post`, async function () {
const loginFlow = new LoginFlow( driver, 'gutenbergUpgradeEdgeUser' );

// No need to log in again as the edge site is owned by the same user.
editor = await startNewPost( driver, loginFlow );
editor = await startNewPost( loginFlow );
} );

step( 'Load the block via markup copied from the non-edge site', async function () {
Expand All @@ -236,7 +233,7 @@ describe( `[${ host }, ${ screenSize }] Test Gutenberg upgrade against most popu

verifyBlockInEditor( Block );

verifyBlockInPublishedPage( driver, Block );
verifyBlockInPublishedPage( Block );
} );
} );
} );
Expand Down

0 comments on commit 19043b6

Please sign in to comment.