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

Experiment: Move unselected block accessibility handling to block-holder #937

Merged
merged 42 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
433d8c8
Update gutenberg ref
pinarol Apr 25, 2019
92b55a4
Update gutenberg ref
pinarol Apr 25, 2019
acf87e8
Update gutenberg ref
pinarol Apr 25, 2019
e7a7e14
Update gutenberg ref
pinarol Apr 26, 2019
764581f
Add unselected block accessibility
pinarol Apr 26, 2019
f487087
Move block unselected state accessibility handling to block-holder
pinarol Apr 26, 2019
f8b3f2c
Update gutenberg ref
pinarol Apr 26, 2019
76fe327
Merge branch 'develop' into issue/update-unselected-accessibility
pinarol Apr 26, 2019
81450c6
Add getAccessibilityLabel to block settings
Tug Apr 26, 2019
7f3dcb3
Update gb ref and use __experimentalGetAccessibilityLabel
Tug May 15, 2019
d3294f7
Merge remote-tracking branch 'origin/develop' into issue/update-unsel…
Tug May 16, 2019
8d7ebda
Update gutenberg ref
Tug May 16, 2019
e83fde4
Update gutenberg ref
Tug May 17, 2019
f9daad9
Update gutenberg ref
Tug May 17, 2019
fbeba8c
Fix type def in BlockHolder
Tug May 17, 2019
4bbd25b
Update gutenberg ref
Tug May 23, 2019
95166be
Update gutenberg ref
Tug May 23, 2019
3199fab
Handle setting UnrecognizedBlock accessibility label in BlockHolder
Tug May 23, 2019
1d752c9
Handle setting UnrecognizedBlock accessibility label in BlockHolder
Tug May 23, 2019
d3d17f8
Merge remote-tracking branch 'origin/develop' into issue/update-unsel…
Tug May 23, 2019
cd4bb11
Merge remote-tracking branch 'origin/develop' into issue/update-unsel…
Tug May 23, 2019
1836bf6
Use order props instead of passing getBlockIndex
Tug May 27, 2019
20038ca
Merge remote-tracking branch 'origin/develop' into issue/update-unsel…
Tug May 28, 2019
4c7809c
Fix lint errors
Tug May 28, 2019
db6a23a
Make sure the block attributes have updated before searching using th…
Tug May 28, 2019
a781649
Handle case where no blockType is found
Tug May 28, 2019
4cb4ad7
Revert unnecessary changes to e2e
Tug May 28, 2019
4400544
Update e2e test descriptions
Tug May 28, 2019
a55b735
* Use deepest element when retrieving block
JavonDavis May 28, 2019
ac1efc5
Use element.sendKeys instead of element.type to avoid Keyboard not fo…
Tug May 29, 2019
ec967ea
Move accessible prop to TouchableWithoutFeedback
Tug May 29, 2019
a39aef6
Revert to using type
Tug May 29, 2019
8ba8904
Fix lint error
Tug May 29, 2019
ef0a086
Move all accessibility props to TouchableWithoutFeedback
Tug Jun 3, 2019
a036757
Update gutenberg ref
Tug Jun 3, 2019
0436928
Merge remote-tracking branch 'origin/develop' into issue/update-unsel…
Tug Jun 3, 2019
121b7d8
Merge remote-tracking branch 'origin/develop' into issue/update-unsel…
Tug Jun 3, 2019
ab3f0a3
Have accessibilityLabel prop in the View to fix e2e tests
Tug Jun 5, 2019
ab049ed
Update gutenberg ref
Tug Jun 5, 2019
01320c3
Merge remote-tracking branch 'origin/develop' into issue/update-unsel…
Tug Jun 5, 2019
47aeee4
Update gutenberg ref after merge
Tug Jun 6, 2019
2077aac
Merge remote-tracking branch 'origin/develop' into issue/update-unsel…
Tug Jun 6, 2019
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
2 changes: 1 addition & 1 deletion __device-tests__/gutenberg-editor-lists-end.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000;

describe( 'Gutenberg Editor tests', () => {
describe( 'Gutenberg Editor tests for List block (end)', () => {
let driver;
let editorPage;
let allPassed = true;
Expand Down
2 changes: 1 addition & 1 deletion __device-tests__/gutenberg-editor-lists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import testData from './helpers/test-data';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 240000;

describe( 'Gutenberg Editor tests', () => {
describe( 'Gutenberg Editor tests for List block', () => {
let driver;
let editorPage;
let allPassed = true;
Expand Down
8 changes: 3 additions & 5 deletions __device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import childProcess from 'child_process';
import wd from 'wd';
import crypto from 'crypto';
import path from 'path';

/**
* Internal dependencies
Expand Down Expand Up @@ -72,7 +73,7 @@ const setupDriver = async () => {
if ( isAndroid() ) {
desiredCaps = _.clone( android8 );
if ( isLocalEnvironment() ) {
desiredCaps.app = localAndroidAppPath;
desiredCaps.app = path.resolve( localAndroidAppPath );
try {
const androidVersion = childProcess
.execSync( 'adb shell getprop ro.build.version.release' )
Expand All @@ -92,7 +93,7 @@ const setupDriver = async () => {
} else {
desiredCaps = _.clone( ios12 );
if ( isLocalEnvironment() ) {
desiredCaps.app = localIOSAppPath;
desiredCaps.app = path.resolve( localIOSAppPath );
} else {
desiredCaps.app = 'sauce-storage:Gutenberg.app.zip'; // App should be preloaded to sauce storage, this can also be a URL
}
Expand Down Expand Up @@ -137,9 +138,6 @@ const stopDriver = async ( driver: wd.PromiseChainWebdriver ) => {
}
};

// 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
const typeString = async ( driver: wd.PromiseChainWebdriver, element: wd.PromiseChainWebdriver.Element, str: string, clear: boolean = false ) => {
if ( clear ) {
await element.clear();
Expand Down
67 changes: 22 additions & 45 deletions __device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
import wd from 'wd';
import { Platform } from 'react-native';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
Expand Down Expand Up @@ -44,19 +39,13 @@ export default class EditorPage {
// and accessibilityId attributes on this object and selects the block
// position uses one based numbering
async getBlockAtPosition( position: number, blockName: string ) {
const blockLocator = `${ blockName } Block. Row ${ position }.`;
return await this.driver.elementByAccessibilityId( blockLocator );
const blockLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`;
const elements = await this.driver.elementsByXPath( blockLocator );
return elements[ elements.length - 1 ];
}

async hasBlockAtPosition( position: number, blockName: string = '' ) {
if ( blockName !== '' ) {
const blockLocator = `${ blockName } Block. Row ${ position }.`;
const elements = await this.driver.elementsByAccessibilityId( blockLocator );
return elements.length > 0;
}
const blockLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "Block. Row ${ position }.")]`;
const elements = await this.driver.elementsByXPath( blockLocator );
return elements.length > 0;
return undefined !== await this.getBlockAtPosition( position, blockName );
}

// =========================
Expand All @@ -69,7 +58,7 @@ export default class EditorPage {
if ( isAndroid() ) {
identifier = 'Add block, Double tap to add a block';
}
const addButton = await this.driver.elementByAccessibilityId( __( identifier ) );
const addButton = await this.driver.elementByAccessibilityId( identifier );
await addButton.click();

// Click on block of choice
Expand All @@ -83,15 +72,11 @@ export default class EditorPage {

// position of the block to move up
async moveBlockUpAtPosition( position: number, blockName: string = '' ) {
if ( ! this.hasBlockAtPosition( position, blockName ) ) {
throw `No Block at position ${ position }`;
}

let parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "Block. Row ${ position }.")]`;
if ( blockName !== '' ) {
parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ blockName } Block. Row ${ position }."]`;
if ( ! await this.hasBlockAtPosition( position, blockName ) ) {
throw Error( `No Block at position ${ position }` );
}

const parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ blockName } Block. Row ${ position }."]`;
let blockLocator = `${ parentLocator }/following-sibling::*`;
blockLocator += isAndroid() ? '' : '//*';
blockLocator += `[@${ this.accessibilityIdXPathAttrib }="Move block up from row ${ position } to row ${ position - 1 }"]`;
Expand All @@ -101,15 +86,11 @@ export default class EditorPage {

// position of the block to move down
async moveBlockDownAtPosition( position: number, blockName: string = '' ) {
if ( ! this.hasBlockAtPosition( position, blockName ) ) {
throw `No Block at position ${ position }`;
}

let parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "Block. Row ${ position }.")]`;
if ( blockName !== '' ) {
parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ blockName } Block. Row ${ position }."]`;
if ( ! await this.hasBlockAtPosition( position, blockName ) ) {
throw Error( `No Block at position ${ position }` );
}

const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`;
let blockLocator = `${ parentLocator }/following-sibling::*`;
blockLocator += isAndroid() ? '' : '//*';
blockLocator += `[@${ this.accessibilityIdXPathAttrib }="Move block down from row ${ position } to row ${ position + 1 }"]`;
Expand All @@ -120,15 +101,11 @@ export default class EditorPage {
// position of the block to remove
// Block will no longer be present if this succeeds
async removeBlockAtPosition( position: number, blockName: string = '' ) {
if ( ! this.hasBlockAtPosition( position, blockName ) ) {
throw `No Block at position ${ position }`;
}

let parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "Block. Row ${ position }.")]`;
if ( blockName !== '' ) {
parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ blockName } Block. Row ${ position }."]`;
if ( ! await this.hasBlockAtPosition( position, blockName ) ) {
throw Error( `No Block at position ${ position }` );
}

const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`;
let removeBlockLocator = `${ parentLocator }/following-sibling::*`;
removeBlockLocator += isAndroid() ? '' : '//*';
let removeButtonIdentifier = `Remove block at row ${ position }`;
Expand All @@ -144,7 +121,6 @@ export default class EditorPage {
}

removeBlockLocator += `[@${ this.accessibilityIdXPathAttrib }="${ removeButtonIdentifier }"]`;

const removeButton = await this.driver.elementByXPath( removeBlockLocator );
await removeButton.click();
}
Expand All @@ -162,7 +138,7 @@ export default class EditorPage {
}

async hasParagraphBlockAtPosition( position: number ) {
return await this.hasBlockAtPosition( position, this.paragraphBlockName );
return this.hasBlockAtPosition( position, this.paragraphBlockName );
}

async getTextViewForParagraphBlock( block: wd.PromiseChainWebdriver.Element ) {
Expand All @@ -172,13 +148,14 @@ export default class EditorPage {
}

const accessibilityId = await block.getAttribute( this.accessibilityIdKey );
const blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ accessibilityId }"]//${ textViewElementName }`;
const blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }=${ JSON.stringify( accessibilityId ) }]//${ textViewElementName }`;
return await this.driver.elementByXPath( blockLocator );
}

async sendTextToParagraphBlock( block: wd.PromiseChainWebdriver.Element, text: string ) {
const textViewElement = await this.getTextViewForParagraphBlock( block );
return await typeString( this.driver, textViewElement, text );
await typeString( this.driver, textViewElement, text );
await this.driver.sleep( 1000 ); // Give time for the block to rerender (such as for accessibility)
}

async sendTextToParagraphBlockAtPosition( position: number, text: string ) {
Expand All @@ -202,7 +179,7 @@ export default class EditorPage {
}

async removeParagraphBlockAtPosition( position: number ) {
return await this.removeBlockAtPosition( position, this.paragraphBlockName );
await this.removeBlockAtPosition( position, this.paragraphBlockName );
}

async getTextForParagraphBlockAtPosition( position: number ) {
Expand All @@ -228,7 +205,7 @@ export default class EditorPage {
}

async hasListBlockAtPosition( position: number ) {
return await this.hasBlockAtPosition( position, this.listBlockName );
return this.hasBlockAtPosition( position, this.listBlockName );
}

async getTextViewForListBlock( block: wd.PromiseChainWebdriver.Element ) {
Expand All @@ -238,7 +215,7 @@ export default class EditorPage {
}

const accessibilityId = await block.getAttribute( this.accessibilityIdKey );
const blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ accessibilityId }"]//${ textViewElementName }`;
const blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }=${ JSON.stringify( accessibilityId ) }]//${ textViewElementName }`;
return await this.driver.elementByXPath( blockLocator );
}

Expand All @@ -265,7 +242,7 @@ export default class EditorPage {

async getTextViewForHtmlViewContent() {
const accessibilityId = 'html-view-content';
const blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ accessibilityId }"]`;
const blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }=${ JSON.stringify( accessibilityId ) }]`;
return await this.driver.elementByXPath( blockLocator );
}

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
Loading