-
Notifications
You must be signed in to change notification settings - Fork 58
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
Include UI tests for blocks with Appium #676
Merged
Merged
Changes from all commits
Commits
Show all changes
146 commits
Select commit
Hold shift + click to select a range
702077a
Changed accessibility of block elements, included .nvmrc
JavonDavis aa306fa
combining blockID and client ID to make testID for locating blocks
JavonDavis 2bfd973
included testID for simple editor check
JavonDavis 03858c7
renamed test files to better match with intent
JavonDavis 9e9fa98
Update jest to ignoer page objects and locators
JavonDavis 88b7391
simple interaction with blocks
JavonDavis 2a76cd6
merge in changes for master and use environment variable to determine…
JavonDavis 8e949ac
instability in type function, had to resort to a typing letter by letter
JavonDavis 5fea42b
simplified to type, this works well on android but not so much on ios
JavonDavis 06535c2
update before and after step in test to handle starting and stopping …
JavonDavis f4f7e22
use relative path for app paths
JavonDavis 879c5e3
updated README
JavonDavis fd163ae
started refactoring into page object model
JavonDavis 89ab16f
removed page and block functions from spec file
JavonDavis 16ef7ab
reverted type function for consistency on iOS
JavonDavis 409e1ac
remove console logs
JavonDavis 815ba1d
fix majority of travis checks
JavonDavis 5fd1d39
Merge branch 'develop' of https://github.com/wordpress-mobile/gutenbe…
JavonDavis 55c994e
resolved flow errors
JavonDavis 98a576f
resolved all eslint problems
JavonDavis 5a203c8
excluding device tests from jest config
JavonDavis 2a8b1c8
* resolved build error caused by initial data set
JavonDavis 1e8a20e
submodule update
JavonDavis 397e645
delete large file
JavonDavis 65b7be6
updated submodule
JavonDavis e09284e
reverted intiial-html.js file
JavonDavis e644985
include simple test for editor load
JavonDavis be9d6fd
move afterall to end of describe
JavonDavis b5905fd
moved helper code out of test file into utils.js
JavonDavis 2f54ed3
small fix to typo in accessibility label for block-toolbar
JavonDavis 0f5fb54
rename toolbar button test IDs
JavonDavis 1f6ff72
removal of redudant uses of testID props
JavonDavis f854050
remove local test config
JavonDavis 7f6fcab
started integration to sauce labs
JavonDavis 5627c28
Complete basic connection to sauce labs with two possible device conf…
JavonDavis 928ec07
revert intial html changes
JavonDavis f13ae1c
update circle ci config with parameters for device-checks job
JavonDavis e8c0c4b
add android on device tests to ci
JavonDavis baad98a
rename Block to BlockInteraction
JavonDavis 1efa97c
remove nvmrc
JavonDavis b998c81
fixed typo in ParagraphBlockInteraction class name
JavonDavis b5f0c36
fixed error caused from Block to BlockInteraction refactor
JavonDavis ce2d03e
included additional inline comments
JavonDavis eb3727d
included pre and post step in ui tests to change out initial-html.js
JavonDavis fc7d3f6
included pre and post step in ui tests to change out initial-html.js
JavonDavis 2f38b81
Merge branch 'add/ci-support-ui-tests' of https://github.com/wordpres…
JavonDavis 78c954e
updated jest ui tests config to use main override main jest config
JavonDavis 546fa49
create script option for running tests without environment variable a…
JavonDavis fc61bf4
try1: update circleci config to build android and upload to sauce labs
JavonDavis af7490f
try2: update circleci config to build android and upload to sauce labs
JavonDavis 39bdd7e
try3: update circleci config to build android and upload to sauce labs
JavonDavis 43abeba
try4: update circleci config to build android and upload to sauce labs
JavonDavis 410af64
try4: update circleci config to build android app
JavonDavis 12ca311
try5: remove bundle step in build-android
JavonDavis adac5a6
try5: remove bundle step in build-android
JavonDavis 57c8de4
try5: use android environment for android-device-checks job
JavonDavis b4030ce
try5: use android environment for android-device-checks job
JavonDavis 67faed2
try5: use android environment for android-device-checks job
JavonDavis a73029d
try5: use android environment for android-device-checks job
JavonDavis 503f643
try5: use android environment for android-device-checks job
JavonDavis 78b8590
try5: use android environment for android-device-checks job
JavonDavis 7a0de83
try5: try android image with correct node version
JavonDavis 1de03f6
try5: try android image with correct node version
JavonDavis 5ad81d1
try5: try android image 27 instead of 28
JavonDavis af0294c
try6: try bundling RN again
JavonDavis 457ffd6
try6: try bundling RN again
JavonDavis a3de56c
try6: try bundling RN again
JavonDavis b7b16ed
try6: try bundling RN again
JavonDavis 9de759b
try6: try bundling RN again
JavonDavis d0ee88d
try6: try bundling RN again
JavonDavis 438ab7d
try6: try bundling RN again
JavonDavis 2891b0b
try6: try bundling RN again
JavonDavis e3d0a34
try7: change android run step to update initial html
JavonDavis 0172399
try7: change android run step to update initial html
JavonDavis 46bb8a6
switch to macos environment on ios
JavonDavis 36cffaa
switch to macos environment on ios
JavonDavis bff1bc5
remove yarn cache step in ios device tests and remove yarn install st…
JavonDavis 37ad5b6
remove build android step from ios check
JavonDavis 002678f
include missing yarn install step
JavonDavis a089058
include missing yarn install step
JavonDavis 662f5ab
try running device tests with sudo access
JavonDavis 70245d4
invlude step to brew install yarn
JavonDavis 66a2d0c
upgrade yarn version
JavonDavis 2d2fb69
upgrade yarn version
JavonDavis 19c1979
set env variables inline
JavonDavis 390ebe2
remove sudo yarn call
JavonDavis eeec9e1
include npm install step for yan
JavonDavis 708585e
include npm install step for yan
JavonDavis dc9b881
include npm install step for yan
JavonDavis 9e9e10c
include npm install step for yan
JavonDavis bcc9842
quit driver after sauce status publish
JavonDavis d7ea6ee
patch to how driver is dismissed
JavonDavis 367d201
revert initial html
JavonDavis bf389da
try waiting a little longer for driver to initialize on iOS
JavonDavis f3ad2b2
include ios build steps in circleci configg
JavonDavis af4db53
try debug configuration
JavonDavis e80ac18
experiement with yarn ios
JavonDavis 143589f
experiement with yarn ios
JavonDavis 113ca5e
experiement with sudo yarn
JavonDavis 2f1bb34
try sudo yarn install
JavonDavis 63017ab
try without sudo again
JavonDavis a0a5444
try without sudo again
JavonDavis 6dbb9e3
reorder config step
JavonDavis 2f2dbfc
remove yarn start
JavonDavis 8bacf67
remove build ios step
JavonDavis 3c182ab
resolved error in zip command
JavonDavis 744ce55
resolved error in zip command missing recursive flag
JavonDavis b345050
removed bundle file and included in gitignore
JavonDavis 6915a74
reset bundle to develop
JavonDavis 8f32b72
reset bundle to develop
JavonDavis 139ebdf
change yarn ios to preios
JavonDavis 05d8813
Update yarn-install cache key
jtreanor 9ee8294
Add Carthage caching
jtreanor 9debb49
Better caching and use xcodebuild
jtreanor 98aa40d
Fix yarn cache and don't use xcodebuild
jtreanor 7416ffd
Build debug
jtreanor c83c5ad
revert to the Release configuration
JavonDavis beb523b
resolve typo in app file location for CI
JavonDavis a53cea8
check for accessibility label updates
JavonDavis c4f45c1
wait a little longer on driver
JavonDavis 1ecaa54
use block index instead of client ID for easier construction of block…
JavonDavis a3bd9ab
resolve conflicts with master
JavonDavis 590a98e
resolve empty initial-html causing ci check errors
JavonDavis 986d999
remove release configuration
JavonDavis ce4e9bb
update bundle output path
JavonDavis 8be80dd
update circleci images
JavonDavis ce8d880
update circleci images
JavonDavis 8dda3ae
remove cache for aztech
JavonDavis ac716ee
reuse original bundle command
JavonDavis 509bdfb
accept licenses
JavonDavis 8de552d
clean install yarn
JavonDavis 19f32e3
update zip loation based on derived data
JavonDavis 5b67b1f
fix device tests html file
JavonDavis 6179d5a
include cache again
JavonDavis 0469e42
fix error to accept licenses
JavonDavis 27426a2
wait for sdkmanager license acceptance
JavonDavis 43449b0
resolve merge conflict with develop
JavonDavis 197accb
ignore non zero exit status on run ios failure
JavonDavis 2302279
localize accessibilitylabel search in editor page
JavonDavis 628bb9e
fixed linter error and merged in develop
JavonDavis a0fb6a8
changes to labels and indentation in certain areas
JavonDavis f045042
fixed linter error with extra space
JavonDavis 92e359b
code indentation cleanup and undo change in scheme config
JavonDavis 0743395
redo config change
JavonDavis 8da08a7
remove react native install and add bundle scripts to package.json
JavonDavis 339c207
remove unnecessary config owner update
JavonDavis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** @flow | ||
* @format */ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import wd from 'wd'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { isAndroid } from '../helpers/utils'; | ||
|
||
// Common code across used to interact with all blocks | ||
export default class BlockInteraction { | ||
driver: wd.PromiseChainWebdriver; | ||
accessibilityIdKey: string; | ||
name: string; | ||
blockName: string; | ||
element: wd.PromiseChainWebdriver.Element; | ||
accessibilityId: string; | ||
accessibilityIdXPathAttrib: string; | ||
static index = 0; | ||
|
||
constructor( driver: wd.PromiseChainWebdriver, name: string = 'Unsupported Block' ) { | ||
this.driver = driver; | ||
this.accessibilityIdKey = 'name'; | ||
this.accessibilityIdXPathAttrib = 'name'; | ||
this.name = name; | ||
|
||
if ( isAndroid() ) { | ||
this.accessibilityIdXPathAttrib = 'content-desc'; | ||
this.accessibilityIdKey = 'contentDescription'; | ||
} | ||
} | ||
|
||
// Each subclass must include a method to do the following: | ||
// * Initialise the element and accessibilityId(By calling this.setupElement in most cases) | ||
// * Initialise any elements specific to interactions with that block | ||
async setup() { | ||
throw 'Unimplemented setup function for this block'; | ||
} | ||
|
||
async getAttribute( attributeName: string ) { | ||
return await this.element.getAttribute( attributeName ); | ||
} | ||
|
||
// Finds the wd element for new block that was added and sets the element attribute | ||
// and accessibilityId attributes on this object | ||
async setupElement( blockName: string, blocks: Set<string> ) { | ||
await this.driver.sleep( 2000 ); | ||
const blockLocator = `block-${ BlockInteraction.index }-${ blockName }`; | ||
this.element = await this.driver.elementByAccessibilityId( blockLocator ); | ||
this.accessibilityId = await this.getAttribute( this.accessibilityIdKey ); | ||
|
||
BlockInteraction.index += 1; | ||
return blocks; | ||
} | ||
|
||
// attempts to type a string to a given element, need for this stems from | ||
// https://github.com/appium/appium/issues/12285#issuecomment-471872239 | ||
// https://github.com/facebook/WebDriverAgent/issues/1084 | ||
async typeString( element: wd.PromiseChainWebdriver.Element, str: string ) { | ||
await element.clear(); | ||
if ( isAndroid() ) { | ||
return await element.type( str ); | ||
} | ||
// iOS: Problem with Appium type function requiring me to do a little hacking to get it work, | ||
// as a result typing on iOS will be slower | ||
for ( let i = 0; i < str.length; i++ ) { | ||
await element.type( str.charAt( i ) ); | ||
} | ||
} | ||
} |
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,56 @@ | ||
/** @flow | ||
* @format */ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockInteraction from './block-interaction'; | ||
/** | ||
* External dependencies | ||
*/ | ||
import wd from 'wd'; | ||
import { isAndroid } from '../helpers/utils'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
export default class ParagraphBlockInteraction extends BlockInteraction { | ||
// FLow complaining about type annotation on Set class here but Set<string>(); doesn't resolve | ||
// $FlowFixMe | ||
static blocks = new Set(); | ||
textViewElement: wd.PromiseChainWebdriver.Element; | ||
|
||
constructor( driver: wd.PromiseChainWebdriver ) { | ||
super( driver, __( 'Paragraph' ) ); | ||
this.driver = driver; | ||
this.blockName = 'core/paragraph'; | ||
} | ||
|
||
// gets the TextView wd element for this paragraph block and sets it to | ||
// the textViewElement attribute for this object | ||
async setupTextView() { | ||
await this.driver.sleep( 2000 ); | ||
let textViewElement = 'XCUIElementTypeTextView'; | ||
if ( isAndroid() ) { | ||
textViewElement = 'android.widget.EditText'; | ||
} | ||
const blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ this.accessibilityId }"]//${ textViewElement }`; | ||
this.textViewElement = await this.driver.elementByXPath( blockLocator ); | ||
} | ||
|
||
async setup() { | ||
await this.setupElement( this.blockName, ParagraphBlockInteraction.blocks ); | ||
await this.setupTextView(); | ||
} | ||
|
||
async sendText( str: string ) { | ||
return await this.typeString( this.textViewElement, str ); | ||
} | ||
|
||
async getText() { | ||
const text = await this.textViewElement.text(); | ||
return text.toString().trim(); | ||
} | ||
} |
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,74 @@ | ||
/** | ||
* @format | ||
* */ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import EditorPage from './pages/editor-page'; | ||
import ParagraphBlockInteraction from './blocks/paragraph-block-interaction'; | ||
import { setupAppium, setupDriver, isLocalEnvironment, timer } from './helpers/utils'; | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000; | ||
|
||
describe( 'Gutenberg Editor tests', () => { | ||
let appium; | ||
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 () => { | ||
if ( isLocalEnvironment() ) { | ||
appium = await setupAppium(); | ||
} | ||
|
||
driver = await setupDriver(); | ||
} ); | ||
|
||
it( 'should be able to see visual editor', async () => { | ||
editorPage = new EditorPage( driver ); | ||
await editorPage.expect(); | ||
} ); | ||
|
||
it( 'should be able to add a new Paragraph block', async () => { | ||
let paragraphBlockInteraction = new ParagraphBlockInteraction( driver ); | ||
paragraphBlockInteraction = await editorPage.addNewBlock( paragraphBlockInteraction ); | ||
await paragraphBlockInteraction.sendText( 'Hello Gutenberg!' ); | ||
await timer( 3000 ); | ||
expect( await paragraphBlockInteraction.getText() ).toBe( 'Hello Gutenberg!' ); | ||
} ); | ||
|
||
afterAll( async () => { | ||
if ( isLocalEnvironment() ) { | ||
if ( driver === undefined ) { | ||
if ( appium !== undefined ) { | ||
await appium.kill( 'SIGINT' ); | ||
} | ||
return; | ||
} | ||
|
||
await driver.quit(); | ||
await appium.kill( 'SIGINT' ); | ||
} else { | ||
if ( driver === undefined ) { | ||
if ( appium !== undefined ) { | ||
await appium.kill( 'SIGINT' ); | ||
} | ||
return; | ||
} | ||
driver.sauceJobStatus( allPassed ); | ||
await driver.quit(); | ||
} | ||
} ); | ||
} ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like installing appium globally is actually necessary. It seems to work fine if we add it to our dev dependencies and just boot it using
yarn appium
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! I'll make that change, thanks!