Skip to content

Commit

Permalink
Merge pull request #2122 from wordpress-mobile/add/e2e/separator-test
Browse files Browse the repository at this point in the history
[UI tests] Cover additional blocks with UI tests
  • Loading branch information
mchowning authored Apr 29, 2020
2 parents 602ed0b + abf757c commit e24b22e
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 20 deletions.
7 changes: 4 additions & 3 deletions __device-tests__/gutenberg-editor-latest-posts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe( 'Gutenberg Editor Latest Post Block tests', () => {
let driver;
let editorPage;
let allPassed = true;
const lastPostBlockName = 'Latest Posts';

// Use reporter for setting status for saucelabs Job
if ( ! isLocalEnvironment() ) {
Expand All @@ -40,11 +41,11 @@ describe( 'Gutenberg Editor Latest Post Block tests', () => {
} );

it( 'should be able to add a Latests-Posts block', async () => {
await editorPage.addNewLatestPostsBlock();
const latestPostsBlock = await editorPage.getLatestPostsBlockAtPosition( 1 );
await editorPage.addNewBlock( lastPostBlockName );
const latestPostsBlock = await editorPage.getBlockAtPosition( lastPostBlockName );

expect( latestPostsBlock ).toBeTruthy();
await editorPage.removeLatestPostsBlockAtPosition( 1 );
await editorPage.removeBlockAtPosition( lastPostBlockName );
} );

afterAll( async () => {
Expand Down
57 changes: 57 additions & 0 deletions __device-tests__/gutenberg-editor-more.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @format
* */

/**
* Internal dependencies
*/
import EditorPage from './pages/editor-page';
import {
setupDriver,
isLocalEnvironment,
stopDriver,
} from './helpers/utils';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor Spacer Block test', () => {
let driver;
let editorPage;
let allPassed = true;
const moreBlockName = 'More';

// Use reporter for setting status for saucelabs Job
if ( ! isLocalEnvironment() ) {
const reporter = {
specDone: async ( result ) => {
allPassed = allPassed && result.status !== 'failed';
},
};

jasmine.getEnv().addReporter( reporter );
}

beforeAll( async () => {
driver = await setupDriver();
editorPage = new EditorPage( driver );
} );

it( 'should be able to see visual editor', async () => {
await expect( editorPage.getBlockList() ).resolves.toBe( true );
} );

it( 'should be able to add an separator block', async () => {
await editorPage.addNewBlock( moreBlockName );
const separatorBlock = await editorPage.getBlockAtPosition( moreBlockName );

expect( separatorBlock ).toBeTruthy();
await editorPage.removeBlockAtPosition( moreBlockName );
} );

afterAll( async () => {
if ( ! isLocalEnvironment() ) {
driver.sauceJobStatus( allPassed );
}
await stopDriver( driver );
} );
} );
57 changes: 57 additions & 0 deletions __device-tests__/gutenberg-editor-separator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @format
* */

/**
* Internal dependencies
*/
import EditorPage from './pages/editor-page';
import {
setupDriver,
isLocalEnvironment,
stopDriver,
} from './helpers/utils';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor Separator Block test', () => {
let driver;
let editorPage;
let allPassed = true;
const separatorBlockName = 'Separator';

// Use reporter for setting status for saucelabs Job
if ( ! isLocalEnvironment() ) {
const reporter = {
specDone: async ( result ) => {
allPassed = allPassed && result.status !== 'failed';
},
};

jasmine.getEnv().addReporter( reporter );
}

beforeAll( async () => {
driver = await setupDriver();
editorPage = new EditorPage( driver );
} );

it( 'should be able to see visual editor', async () => {
await expect( editorPage.getBlockList() ).resolves.toBe( true );
} );

it( 'should be able to add an separator block', async () => {
await editorPage.addNewBlock( separatorBlockName );
const separatorBlock = await editorPage.getBlockAtPosition( separatorBlockName );

expect( separatorBlock ).toBeTruthy();
await editorPage.removeBlockAtPosition( separatorBlockName );
} );

afterAll( async () => {
if ( ! isLocalEnvironment() ) {
driver.sauceJobStatus( allPassed );
}
await stopDriver( driver );
} );
} );
57 changes: 57 additions & 0 deletions __device-tests__/gutenberg-editor-spacer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @format
* */

/**
* Internal dependencies
*/
import EditorPage from './pages/editor-page';
import {
setupDriver,
isLocalEnvironment,
stopDriver,
} from './helpers/utils';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor Spacer Block test', () => {
let driver;
let editorPage;
let allPassed = true;
const spacerBlockName = 'Spacer';

// Use reporter for setting status for saucelabs Job
if ( ! isLocalEnvironment() ) {
const reporter = {
specDone: async ( result ) => {
allPassed = allPassed && result.status !== 'failed';
},
};

jasmine.getEnv().addReporter( reporter );
}

beforeAll( async () => {
driver = await setupDriver();
editorPage = new EditorPage( driver );
} );

it( 'should be able to see visual editor', async () => {
await expect( editorPage.getBlockList() ).resolves.toBe( true );
} );

it( 'should be able to add an separator block', async () => {
await editorPage.addNewBlock( spacerBlockName );
const separatorBlock = await editorPage.getBlockAtPosition( spacerBlockName );

expect( separatorBlock ).toBeTruthy();
await editorPage.removeBlockAtPosition( spacerBlockName );
} );

afterAll( async () => {
if ( ! isLocalEnvironment() ) {
driver.sauceJobStatus( allPassed );
}
await stopDriver( driver );
} );
} );
17 changes: 0 additions & 17 deletions __device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default class EditorPage {
accessibilityIdKey: string;
accessibilityIdXPathAttrib: string;
paragraphBlockName = 'Paragraph';
latestPostsBlockName = 'Latest Posts';
orderedListButtonName = 'Convert to ordered list';

constructor( driver: wd.PromiseChainWebdriver ) {
Expand Down Expand Up @@ -384,20 +383,4 @@ export default class EditorPage {
const textViewElement = await this.getTextViewForHeadingBlock( block, true );
return await typeString( this.driver, textViewElement, text, clear );
}

// ============================
// Latest-Posts Block functions
// ============================

async addNewLatestPostsBlock() {
await this.addNewBlock( this.latestPostsBlockName );
}

async getLatestPostsBlockAtPosition( position: number ) {
return this.getBlockAtPosition( this.latestPostsBlockName, position );
}

async removeLatestPostsBlockAtPosition( position: number ) {
return await this.removeBlockAtPosition( this.latestPostsBlockName, position );
}
}

0 comments on commit e24b22e

Please sign in to comment.