Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6ea1d57
Release script: Update react-native-editor version to 1.76.0
jhnstn May 11, 2022
bcddcbc
Release script: Update with changes from 'npm run core preios'
jhnstn May 11, 2022
678bd2f
Update Changelog
jhnstn May 11, 2022
21b838c
Release script: Update react-native-editor version to 1.76.1
May 20, 2022
7f79f52
Release script: Update with changes from 'npm run core preios'
May 20, 2022
981471e
[Mobile] - BlockList - Add internal onLayout from CellRendererCompone…
May 18, 2022
0087e3d
[Mobile] - Fix Drag & Drop Chip positioning issue with RTL languages …
May 18, 2022
5c6fe0d
[RNMobile] Add drag & drop help guide in Help & Support screen (#40961)
fluiddot May 19, 2022
09d4368
[RNMobile] Fix drag mode not being enabled when long-pressing over Sh…
fluiddot May 20, 2022
c951e59
Mobile - Update changelog
May 20, 2022
d0b2cea
Translate NEW badge in Move blocks help screen
fluiddot May 20, 2022
132bc3a
Release script: Update react-native-editor version to 1.77.0
SiobhyB May 24, 2022
cb4105f
Release script: Update with changes from 'npm run core preios'
SiobhyB May 24, 2022
639598f
[RNMobile] Improve text read by screen readers for BottomSheetSelectC…
SiobhyB May 13, 2022
3fe5683
[RNMobile] Add 'Insert from URL' option to Image block (#40334)
derekblank May 23, 2022
a6dd494
[RNMobile] - E2E Simplify heading and lists blocks functions (#40670)
jostnes May 16, 2022
1b3391e
Add ruby version file (#41013)
jhnstn May 12, 2022
148f835
[RNMobile] Improvements to Getting Started Guides (#40964)
SiobhyB May 23, 2022
a046a61
update expected html for file block (#41300)
jostnes May 25, 2022
ede6624
Add waitForVisible() to all blocks (#41126)
jostnes May 25, 2022
2daf775
Update CHANGELOG
SiobhyB May 26, 2022
d8fbfbd
Revert "update expected html for file block (#41300)"
SiobhyB May 26, 2022
efc0f2c
[RNMobile] Ensure post title gets focused when is notified from nativ…
fluiddot May 26, 2022
4c714af
Release script: Update react-native-editor version to 1.77.1
fluiddot Jun 2, 2022
9365c4e
Release script: Update with changes from 'npm run core preios'
fluiddot Jun 2, 2022
ad2c8e4
[RNMobile] Bump `react-native-reanimated` version to `2.4.1-wp-3` (#4…
fluiddot Jun 2, 2022
f10a378
Update react-native-editor changelog
fluiddot Jun 2, 2022
4cfbd82
Release script: Update react-native-editor version to 1.78.0
fluiddot Jun 10, 2022
5b447b4
Release script: Update with changes from 'npm run core preios'
fluiddot Jun 10, 2022
8bd8d90
[RNMobile] Bump `react-native-gesture-handler` to version `2.3.2` (#4…
fluiddot May 27, 2022
bdaaf6e
Update react-native-editor changelog
fluiddot Jun 10, 2022
6e13c9e
Release script: Update react-native-editor version to 1.78.1
SiobhyB Jun 16, 2022
32ab484
Release script: Update with changes from 'npm run core preios'
SiobhyB Jun 16, 2022
4ae461c
[RNMobile] Gallery block: Re-introduce `v1` (#41533)
fluiddot Jun 14, 2022
01adee1
[RNMobile] Fix missing translations for locales that include region (…
fluiddot Jun 14, 2022
b1352b7
Update CHANGELOG
SiobhyB Jun 16, 2022
77417b6
Release script: Update react-native-editor version to 1.79.0
dcalhoun Jul 7, 2022
4e35a9d
Release script: Update with changes from 'npm run core preios'
dcalhoun Jul 7, 2022
2f31836
[RNMobile] Add integration tests to cover Drag & Drop functionality (…
fluiddot May 31, 2022
fb5f7e4
[Mobile] - Add E2E tests for the Drag & Drop blocks feature (#41368)
May 31, 2022
aee2a06
Mobile - Skip some of the Drag & Drop E2E on iOS (#41529)
Jun 3, 2022
c7a740c
where it can change to use clickIfClickable(), add new param for wait…
jostnes Jun 2, 2022
83444ec
[RNMobile] Add 'Insert from URL' option to Video block (#41493)
derekblank Jun 9, 2022
d407e8f
Upgrade Aztec to v1.5.9 (#41828)
derekblank Jun 22, 2022
720843b
fix: Image block preserves alt text from media library (#41839)
dcalhoun Jun 23, 2022
94e8c68
[RNMobile] Implement recovery option for invalid blocks (#41988)
SiobhyB Jul 4, 2022
95a1894
docs: Update change log
dcalhoun Jul 7, 2022
c9c1e6b
[RNMobile] Upgrades Gradle to 7.4.2 & Android Gradle Plugin to 7.2.1 …
oguzkocer Jul 7, 2022
581fc70
Update Aztec-Android version to v1.6.0 (#42243)
oguzkocer Jul 7, 2022
5f7855f
Release script: Update react-native-editor version to 1.79.1
dcalhoun Jul 19, 2022
170b21a
Release script: Update with changes from 'npm run core preios'
dcalhoun Jul 19, 2022
62e7ef0
fix: Workaround Android 12 webview crash (#42517)
dcalhoun Jul 19, 2022
c905e8d
Merge branch 'trunk' of github.com:WordPress/gutenberg into rnmobile/…
dcalhoun Jul 20, 2022
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
Prev Previous commit
Next Next commit
Add waitForVisible() to all blocks (#41126)
* add waits to all block - 1st try

* fix failing tests

* correct if else condition

* fix failing cover block test

* update spaces

* update to use new click helper

* wait for blocks to be visible first in getFirstBlock and getLastBlock

* remove length as a parameter

* update timing for long press since it's failing intermittently in ci

* remove deleted param, revert space changes

* remove redundant code

* exit function once condition is met

* increse wait time for long press

* remove unneccesary condition, update message, return click value

Co-authored-by: jos <[email protected]>
  • Loading branch information
2 people authored and SiobhyB committed May 26, 2022
commit ede6624935f67df415872e5433ab9da3170325d3
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {
testData.blockInsertionHtml.toLowerCase()
);

// wait for the block editor to load and for accessibility ids to update
await editorPage.driver.sleep( 3000 );

// Workaround for now since deleting the first element causes a crash on CI for Android
if ( isAndroid() ) {
paragraphBlockElement = await editorPage.getTextBlockAtPosition(
Expand All @@ -55,8 +52,6 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {
await paragraphBlockElement.click();
await editorPage.removeBlockAtPosition( blockNames.paragraph, 3 );
for ( let i = 3; i > 0; i-- ) {
// wait for accessibility ids to update
await editorPage.driver.sleep( 1000 );
paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph,
i,
Expand All @@ -72,8 +67,6 @@ describe( 'Gutenberg Editor tests for Block insertion', () => {
}
} else {
for ( let i = 4; i > 0; i-- ) {
// wait for accessibility ids to update
await editorPage.driver.sleep( 1000 );
paragraphBlockElement = await editorPage.getTextBlockAtPosition(
blockNames.paragraph
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,95 +2,49 @@
* Internal dependencies
*/
import { blockNames } from './pages/editor-page';
import { isAndroid, waitForVisible } from './helpers/utils';
import { isAndroid } from './helpers/utils';
import testData from './helpers/test-data';

describe( 'Gutenberg Editor Cover Block test', () => {
it( 'should displayed properly and have properly converted height (ios only)', async () => {
await editorPage.setHtmlContent( testData.coverHeightWithRemUnit );

const coverBlock = await editorPage.getBlockAtPosition(
blockNames.cover,
1,
{ useWaitForVisible: true }
);

// Temporarily this test is skipped on Android,due to the inconsistency of the results,
// which are related to getting values in raw pixels instead of density pixels on Android.
/* eslint-disable jest/no-conditional-expect */
if ( ! isAndroid() ) {
await editorPage.setHtmlContent( testData.coverHeightWithRemUnit );

const coverBlock = await editorPage.getBlockAtPosition(
blockNames.cover
);

const { height } = await coverBlock.getSize();
// Height is set to 20rem, where 1rem is 16.
// There is also block's vertical padding equal 32.
// Finally, the total height should be 20 * 16 + 32 = 352.
expect( height ).toBe( 352 );
}
/* eslint-enable jest/no-conditional-expect */
/* eslint-enable jest/no-conditional-expect */

await coverBlock.click();
expect( coverBlock ).toBeTruthy();
await editorPage.removeBlockAtPosition( blockNames.cover );
await coverBlock.click();
expect( coverBlock ).toBeTruthy();
await editorPage.removeBlockAtPosition( blockNames.cover );
}
} );

// Testing this for iOS on a device is valuable to ensure that it properly
// handles opening multiple modals, as only one can be open at a time.
it( 'allows modifying media from within block settings', async () => {
await editorPage.setHtmlContent( testData.coverHeightWithRemUnit );

const coverBlock = await editorPage.getBlockAtPosition(
blockNames.cover,
1,
{ useWaitForVisible: true }
);
await coverBlock.click();

// Can only add image from media library on iOS
if ( ! isAndroid() ) {
// Open block settings.
const settingsButton = await editorPage.driver.elementByAccessibilityId(
'Open Settings'
);
await settingsButton.click();
await editorPage.setHtmlContent( testData.coverHeightWithRemUnit );

// Add initial media via button within bottom sheet.
const mediaSection = await editorPage.driver.elementByAccessibilityId(
'Media Add image or video'
);
const addMediaButton = await mediaSection.elementByAccessibilityId(
'Add image or video'
const coverBlock = await editorPage.getBlockAtPosition(
blockNames.cover
);
await addMediaButton.click();
await editorPage.chooseMediaLibrary();
await editorPage.driver.sleep( 2000 ); // Await media load.

// Get Edit image button of block
const editImageButtonLocator =
'//XCUIElementTypeButton[@name="Edit image"][@enabled="true"]';
const blockEditImageButton = await waitForVisible(
editorPage.driver,
editImageButtonLocator
);

// Edit media within block settings.
await settingsButton.click();
await editorPage.driver.sleep( 2000 ); // Await media load.

// Get Edit image button of block settings.
// NOTE: Since we have multiple Edit image buttons at this
// point, we have to filter them to obtain the correct one.
const settingsEditImageButtons = await editorPage.driver.elementsByXPath(
editImageButtonLocator
);
const settingsEditImageButton = settingsEditImageButtons.find(
( element ) => element.value !== blockEditImageButton.value
);
await settingsEditImageButton.click();

// Replace image.
const replaceButton = await editorPage.driver.elementByAccessibilityId(
'Replace'
);
await replaceButton.click();
await editorPage.openBlockSettings( coverBlock );
await editorPage.clickAddMediaFromCoverBlock();
await editorPage.chooseMediaLibrary();
await editorPage.replaceMediaImage();

// First modal should no longer be presented.
const replaceButtons = await editorPage.driver.elementsByAccessibilityId(
Expand All @@ -101,9 +55,9 @@ describe( 'Gutenberg Editor Cover Block test', () => {

// Select different media.
await editorPage.chooseMediaLibrary();
}

expect( coverBlock ).toBeTruthy();
await editorPage.removeBlockAtPosition( blockNames.cover );
expect( coverBlock ).toBeTruthy();
await editorPage.removeBlockAtPosition( blockNames.cover );
}
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ describe( 'Gutenberg Editor Image Block tests', () => {
await editorPage.closePicker();

const imageBlock = await editorPage.getBlockAtPosition(
blockNames.image,
1,
{
useWaitForVisible: true,
}
blockNames.image
);

// Can only add image from media library on iOS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe( 'Gutenberg Editor Search Block tests.', () => {
searchBlock,
'Button inside'
);
await editorPage.isSearchSettingsVisible();
await editorPage.dismissBottomSheet();

// Switch to html and verify.
Expand All @@ -141,6 +142,7 @@ describe( 'Gutenberg Editor Search Block tests.', () => {
searchBlock,
'No button'
);
await editorPage.isSearchSettingsVisible();
await editorPage.dismissBottomSheet();

// Switch to html and verify.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ describe( 'Gutenberg Editor Spacer Block test', () => {
it( 'should be able to add a spacer block', async () => {
await editorPage.addNewBlock( blockNames.spacer );
const spacerBlock = await editorPage.getBlockAtPosition(
blockNames.spacer,
1,
{ useWaitForVisible: true }
blockNames.spacer
);

expect( spacerBlock ).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ describe( 'Gutenberg Editor Unsupported Block Editor Tests', () => {
const editButton = await editorPage.getUnsupportedBlockBottomSheetEditButton();
await editButton.click();

await expect(
editorPage.getUnsupportedBlockWebView()
).resolves.toBeTruthy();
const webView = await editorPage.getUnsupportedBlockWebView();
await expect( webView ).toBeTruthy();
} );
} );
75 changes: 57 additions & 18 deletions packages/react-native-editor/__device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ const longPressMiddleOfElement = async ( driver, element ) => {
const x = location.x + size.width / 2;
const y = location.y + size.height / 2;
action.press( { x, y } );
action.wait( 2000 );
// Setting to wait a bit longer because this is failing more frequently on the CI
action.wait( 5000 );
action.release();
await action.perform();
};
Expand Down Expand Up @@ -419,24 +420,28 @@ const toggleHtmlMode = async ( driver, toggleOn ) => {

const showHtmlButtonXpath =
'/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.TextView[9]';
const showHtmlButton = await driver.elementByXPath(
showHtmlButtonXpath

await clickIfClickable( driver, showHtmlButtonXpath );
} else if ( toggleOn ) {
await clickIfClickable(
driver,
'//XCUIElementTypeButton[@name="..."]'
);
await clickIfClickable(
driver,
'//XCUIElementTypeButton[@name="Switch to HTML"]'
);
await showHtmlButton.click();
} else {
const menuButton = await driver.elementByAccessibilityId( '...' );
await menuButton.click();
let toggleHtmlButton;
if ( toggleOn ) {
toggleHtmlButton = await driver.elementByAccessibilityId(
'Switch to HTML'
);
} else {
toggleHtmlButton = await driver.elementByAccessibilityId(
'Switch To Visual'
);
}
await toggleHtmlButton.click();
// This is to wait for the clipboard paste notification to disappear, currently it overlaps with the menu button
await driver.sleep( 3000 );
await clickIfClickable(
driver,
'//XCUIElementTypeButton[@name="..."]'
);
await clickIfClickable(
driver,
'//XCUIElementTypeButton[@name="Switch To Visual"]'
);
}
};

Expand Down Expand Up @@ -492,7 +497,7 @@ const waitForVisible = async (
}

const element = await driver.elementsByXPath( elementLocator );
if ( element.length !== 1 ) {
if ( element.length === 0 ) {
// if locator is not visible, try again
return waitForVisible(
driver,
Expand Down Expand Up @@ -530,6 +535,39 @@ const isElementVisible = async (
return true;
};

const clickIfClickable = async (
driver,
elementLocator,
maxIteration = 25,
iteration = 0
) => {
const element = await waitForVisible(
driver,
elementLocator,
maxIteration,
iteration
);

try {
return await element.click();
} catch ( error ) {
if ( iteration >= maxIteration ) {
// eslint-disable-next-line no-console
console.error(
`"${ elementLocator }" still not clickable after "${ iteration }" retries`
);
return '';
}

return clickIfClickable(
driver,
elementLocator,
maxIteration,
iteration + 1
);
}
};

// Only for Android
const waitIfAndroid = async () => {
if ( isAndroid() ) {
Expand All @@ -540,6 +578,7 @@ const waitIfAndroid = async () => {
module.exports = {
backspace,
clickBeginningOfElement,
clickIfClickable,
clickMiddleOfElement,
doubleTap,
isAndroid,
Expand Down
Loading