-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1100 from wordpress-mobile/try/add-paste-ui-test
Add Paste UI Tests for Android
- Loading branch information
Showing
4 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/** | ||
* @format | ||
* */ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import EditorPage from './pages/editor-page'; | ||
import { | ||
setupDriver, | ||
isLocalEnvironment, | ||
longPressMiddleOfElement, | ||
tapSelectAllAboveElement, | ||
tapCopyAboveElement, | ||
tapPasteAboveElement, | ||
stopDriver, | ||
isAndroid, | ||
} from './helpers/utils'; | ||
import testData from './helpers/test-data'; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000; | ||
|
||
describe( 'Gutenberg Editor paste tests', () => { | ||
// skip iOS for now | ||
if ( ! isAndroid() ) { | ||
it( 'skips the tests on any platform other than Android', async () => { | ||
} ); | ||
return; | ||
} | ||
|
||
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(); | ||
await driver.setClipboard( '', 'plaintext' ); | ||
editorPage = new EditorPage( driver ); | ||
} ); | ||
|
||
it( 'copies plain text from one paragraph block and pastes in another', async () => { | ||
await editorPage.addNewParagraphBlock(); | ||
const paragraphBlockElement = await editorPage.getParagraphBlockAtPosition( 1 ); | ||
|
||
if ( isAndroid() ) { | ||
await paragraphBlockElement.click(); | ||
} | ||
|
||
await editorPage.sendTextToParagraphBlock( paragraphBlockElement, testData.pastePlainText ); | ||
const textViewElement = await editorPage.getTextViewForParagraphBlock( paragraphBlockElement ); | ||
|
||
// copy content to clipboard | ||
await longPressMiddleOfElement( driver, textViewElement ); | ||
await tapSelectAllAboveElement( driver, textViewElement ); | ||
await tapCopyAboveElement( driver, textViewElement ); | ||
|
||
// create another paragraph block | ||
await editorPage.addNewParagraphBlock(); | ||
const paragraphBlockElement2 = await editorPage.getParagraphBlockAtPosition( 2 ); | ||
|
||
if ( isAndroid() ) { | ||
await paragraphBlockElement2.click(); | ||
} | ||
|
||
const textViewElement2 = await editorPage.getTextViewForParagraphBlock( paragraphBlockElement2 ); | ||
|
||
// paste into second paragraph block | ||
await longPressMiddleOfElement( driver, textViewElement2 ); | ||
await tapPasteAboveElement( driver, textViewElement2 ); | ||
|
||
const text = await editorPage.getTextForParagraphBlockAtPosition( 2 ); | ||
expect( text ).toBe( testData.pastePlainText ); | ||
} ); | ||
|
||
it( 'copies styled text from one paragraph block and pastes in another', async () => { | ||
// create paragraph block with styled text by editing html | ||
await editorPage.setHtmlContentAndroid( testData.pasteHtmlText ); | ||
const paragraphBlockElement = await editorPage.getParagraphBlockAtPosition( 1 ); | ||
|
||
if ( isAndroid() ) { | ||
await paragraphBlockElement.click(); | ||
} | ||
|
||
const textViewElement = await editorPage.getTextViewForParagraphBlock( paragraphBlockElement ); | ||
|
||
// copy content to clipboard | ||
await longPressMiddleOfElement( driver, textViewElement ); | ||
await tapSelectAllAboveElement( driver, textViewElement ); | ||
await tapCopyAboveElement( driver, textViewElement ); | ||
|
||
// create another paragraph block | ||
await editorPage.addNewParagraphBlock(); | ||
const paragraphBlockElement2 = await editorPage.getParagraphBlockAtPosition( 2 ); | ||
|
||
if ( isAndroid() ) { | ||
await paragraphBlockElement2.click(); | ||
} | ||
|
||
const textViewElement2 = await editorPage.getTextViewForParagraphBlock( paragraphBlockElement2 ); | ||
|
||
// paste into second paragraph block | ||
await longPressMiddleOfElement( driver, textViewElement2 ); | ||
await tapPasteAboveElement( driver, textViewElement2 ); | ||
|
||
// check styled text by verifying html contents | ||
await editorPage.verifyHtmlContent( testData.pasteHtmlTextResult ); | ||
} ); | ||
|
||
afterAll( async () => { | ||
if ( ! isLocalEnvironment() ) { | ||
driver.sauceJobStatus( allPassed ); | ||
} | ||
await stopDriver( driver ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters