Skip to content

Commit

Permalink
Merge pull request #1038 from wordpress-mobile/fix/device-test-editor…
Browse files Browse the repository at this point in the history
…-focus

Merging for now as a way to limit false negatives
  • Loading branch information
JavonDavis authored May 29, 2019
2 parents cb57c49 + 43ec6bf commit 6e46800
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
17 changes: 14 additions & 3 deletions __device-tests__/gutenberg-editor-lists-end.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import EditorPage from './pages/editor-page';
import {
setupDriver,
isLocalEnvironment,
stopDriver } from './helpers/utils';
stopDriver,
isAndroid,
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000;
Expand All @@ -35,18 +37,27 @@ describe( 'Gutenberg Editor tests', () => {
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 end a List block', async () => {
await editorPage.addNewListBlock();
const listBlockElement = await editorPage.getListBlockAtPosition( 1 );

// Click List block on Android to force EditText focus
if ( isAndroid() ) {
await listBlockElement.click();
}

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

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

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

await editorPage.verifyHtmlContent( testData.listEndedHtml );
} );
Expand Down
11 changes: 9 additions & 2 deletions __device-tests__/gutenberg-editor-lists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import EditorPage from './pages/editor-page';
import {
setupDriver,
isLocalEnvironment,
stopDriver } from './helpers/utils';
stopDriver,
isAndroid,
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000;
Expand Down Expand Up @@ -43,11 +45,16 @@ describe( 'Gutenberg Editor tests', () => {
await editorPage.addNewListBlock();
const listBlockElement = await editorPage.getListBlockAtPosition( 1 );

// Click List block on Android to force EditText focus
if ( isAndroid() ) {
await listBlockElement.click();
}

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

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

// Send the second list item text
await editorPage.sendTextToListBlock( listBlockElement, testData.listItem2 );
Expand Down
20 changes: 19 additions & 1 deletion __device-tests__/gutenberg-editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
isLocalEnvironment,
clickMiddleOfElement,
clickBeginningOfElement,
stopDriver } from './helpers/utils';
stopDriver,
isAndroid,
} from './helpers/utils';
import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000;
Expand Down Expand Up @@ -44,13 +46,19 @@ describe( 'Gutenberg Editor tests', () => {
it( 'should be able to add a new Paragraph block', async () => {
await editorPage.addNewParagraphBlock();
const paragraphBlockElement = await editorPage.getParagraphBlockAtPosition( 1 );
if ( isAndroid() ) {
await paragraphBlockElement.click();
}
await editorPage.sendTextToParagraphBlock( paragraphBlockElement, testData.shortText );
await editorPage.removeParagraphBlockAtPosition( 1 );
} );

it( 'should be able to split one paragraph block into two', async () => {
await editorPage.addNewParagraphBlock();
const paragraphBlockElement = await editorPage.getParagraphBlockAtPosition( 1 );
if ( isAndroid() ) {
await paragraphBlockElement.click();
}
await editorPage.sendTextToParagraphBlock( paragraphBlockElement, testData.shortText );
const textViewElement = await editorPage.getTextViewForParagraphBlock( paragraphBlockElement );
await clickMiddleOfElement( driver, textViewElement );
Expand All @@ -71,6 +79,9 @@ describe( 'Gutenberg Editor tests', () => {
it( 'should be able to merge 2 paragraph blocks into 1', async () => {
await editorPage.addNewParagraphBlock();
let paragraphBlockElement = await editorPage.getParagraphBlockAtPosition( 1 );
if ( isAndroid() ) {
await paragraphBlockElement.click();
}
await editorPage.sendTextToParagraphBlock( paragraphBlockElement, testData.shortText );
let textViewElement = await editorPage.getTextViewForParagraphBlock( paragraphBlockElement );
await clickMiddleOfElement( driver, textViewElement );
Expand All @@ -81,6 +92,9 @@ describe( 'Gutenberg Editor tests', () => {
const text0 = await editorPage.getTextForParagraphBlockAtPosition( 1 );
const text1 = await editorPage.getTextForParagraphBlockAtPosition( 2 );
paragraphBlockElement = await editorPage.getParagraphBlockAtPosition( 2 );
if ( isAndroid() ) {
await paragraphBlockElement.click();
}
textViewElement = await editorPage.getTextViewForParagraphBlock( paragraphBlockElement );
await clickBeginningOfElement( driver, textViewElement );
await editorPage.sendTextToParagraphBlock( paragraphBlockElement, '\u0008' );
Expand All @@ -94,6 +108,10 @@ describe( 'Gutenberg Editor tests', () => {

it( 'should be able to create a post with multiple paragraph blocks', async () => {
await editorPage.addNewParagraphBlock();
const paragraphBlockElement = await editorPage.getParagraphBlockAtPosition( 1 );
if ( isAndroid() ) {
await paragraphBlockElement.click();
}
await editorPage.sendTextToParagraphBlockAtPosition( 1, testData.longText );

for ( let i = 4; i > 0; i-- ) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"test:inside-gb": "cross-env NODE_ENV=test jest --verbose --config jest_gb.config.js",
"test:debug": "cross-env NODE_ENV=test node --inspect-brk jest --runInBand --verbose --config jest.config.js",
"device-tests": "cross-env NODE_ENV=test jest --runInBand --reporters=default --reporters=jest-junit --detectOpenHandles --verbose --config jest_ui.config.js",
"device-tests:debug": "cross-env NODE_ENV=test node --inspect-brk node_modules/jest/bin/jest --runInBand --reporters=default --reporters=jest-junit --detectOpenHandles --verbose --config jest_ui.config.js",
"device-tests:debug": "cross-env NODE_ENV=test node $NODE_DEBUG_OPTION --inspect-brk node_modules/jest/bin/jest --runInBand --reporters=default --reporters=jest-junit --detectOpenHandles --verbose --config jest_ui.config.js",
"test:e2e": "yarn test:e2e:android && yarn test:e2e:ios",
"test:e2e:android": "TEST_RN_PLATFORM=android yarn device-tests",
"test:e2e:android:debug": "TEST_RN_PLATFORM=android yarn device-tests:debug",
Expand Down

0 comments on commit 6e46800

Please sign in to comment.