Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List end test #1022

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions __device-tests__/gutenberg-editor-lists-end.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @format
* */

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

jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000;

describe( 'Gutenberg Editor tests', () => {
let driver;
let editorPage;
let allPassed = true;

// 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 end a List block', async () => {
await editorPage.addNewListBlock();
const listBlockElement = await editorPage.getListBlockAtPosition( 1 );

// Send the first list item text
await editorPage.sendTextToListBlock( listBlockElement, testData.listItem1 );

// send an Enter
await editorPage.sendTextToParagraphBlock( listBlockElement, '\n' );

// send an Enter
await editorPage.sendTextToParagraphBlock( listBlockElement, '\n' );

await editorPage.verifyHtmlContent( testData.listEndedHtml );
} );

afterAll( async () => {
if ( ! isLocalEnvironment() ) {
driver.sauceJobStatus( allPassed );
}
await stopDriver( driver );
} );
} );
13 changes: 2 additions & 11 deletions __device-tests__/gutenberg-editor-lists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
* @format
* */

/**
* External dependencies
*/
import { Platform } from 'react-native';

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -57,12 +52,8 @@ describe( 'Gutenberg Editor tests', () => {
// Send the second list item text
await editorPage.sendTextToListBlock( listBlockElement, testData.listItem2 );

if ( Platform.OS === 'android' ) {
// switch to html and verify html
await editorPage.verifyHtmlContent( testData.listHtml );
} else {
// TODO: implement html verification on iOS too
}
// switch to html and verify html
await editorPage.verifyHtmlContent( testData.listHtml );
} );

afterAll( async () => {
Expand Down
7 changes: 7 additions & 0 deletions __device-tests__/helpers/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ exports.listItem2 = `Honey`;
exports.listHtml = `<!-- wp:list -->
<ul><li>Milk</li><li>Honey</li></ul>
<!-- /wp:list -->`;
exports.listEndedHtml = `<!-- wp:list -->
<ul><li>Milk</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->`;
9 changes: 9 additions & 0 deletions __device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* External dependencies
*/
import wd from 'wd';
import { Platform } from 'react-native';

/**
* WordPress dependencies
Expand Down Expand Up @@ -269,6 +270,14 @@ export default class EditorPage {
}

async verifyHtmlContent( html: string ) {
if ( Platform.OS === 'android' ) {
await this.verifyHtmlContentAndroid( html );
} else {
// TODO: implement html verification on iOS too
}
}

async verifyHtmlContentAndroid( html: string ) {
await toggleHtmlMode( this.driver );

const htmlContentView = await this.getTextViewForHtmlViewContent();
Expand Down