From 876ebe714219f4f0ba3ab23e82e535747db041e6 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Thu, 23 May 2019 12:44:05 +0300 Subject: [PATCH 1/2] Move the platform check deeper, in the EditorPage class --- __device-tests__/gutenberg-editor-lists.test.js | 13 ++----------- __device-tests__/pages/editor-page.js | 9 +++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/__device-tests__/gutenberg-editor-lists.test.js b/__device-tests__/gutenberg-editor-lists.test.js index bf17c0a5ca..3750dd1282 100644 --- a/__device-tests__/gutenberg-editor-lists.test.js +++ b/__device-tests__/gutenberg-editor-lists.test.js @@ -2,11 +2,6 @@ * @format * */ -/** - * External dependencies - */ -import { Platform } from 'react-native'; - /** * Internal dependencies */ @@ -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 () => { diff --git a/__device-tests__/pages/editor-page.js b/__device-tests__/pages/editor-page.js index dc10d40351..0bfd74f28e 100644 --- a/__device-tests__/pages/editor-page.js +++ b/__device-tests__/pages/editor-page.js @@ -6,6 +6,7 @@ * External dependencies */ import wd from 'wd'; +import { Platform } from 'react-native'; /** * WordPress dependencies @@ -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(); From a0bf165d4a274fcdf82c1661a3b6d630a8518fb0 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Thu, 23 May 2019 12:45:15 +0300 Subject: [PATCH 2/2] Add a test for ending a list --- .../gutenberg-editor-lists-end.test.js | 60 +++++++++++++++++++ __device-tests__/helpers/test-data.js | 7 +++ 2 files changed, 67 insertions(+) create mode 100644 __device-tests__/gutenberg-editor-lists-end.test.js diff --git a/__device-tests__/gutenberg-editor-lists-end.test.js b/__device-tests__/gutenberg-editor-lists-end.test.js new file mode 100644 index 0000000000..85a30b7a82 --- /dev/null +++ b/__device-tests__/gutenberg-editor-lists-end.test.js @@ -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 ); + } ); +} ); diff --git a/__device-tests__/helpers/test-data.js b/__device-tests__/helpers/test-data.js index aaab37effc..946f688dde 100644 --- a/__device-tests__/helpers/test-data.js +++ b/__device-tests__/helpers/test-data.js @@ -10,3 +10,10 @@ exports.listItem2 = `Honey`; exports.listHtml = ` `; +exports.listEndedHtml = ` + + + + +

+`;