From b6852e8eadba93511cfaf30a7bc37f5e6ff0a8fe Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 10 Oct 2023 15:05:21 -0400 Subject: [PATCH 1/4] test: Replace sleep with pause utility Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade. --- .../gutenberg-editor-media-blocks-@canary.test.js | 4 ++-- .../react-native-editor/__device-tests__/pages/editor-page.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js b/packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js index ddc7bd8131c44..fe849db2817f9 100644 --- a/packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js +++ b/packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js @@ -30,7 +30,7 @@ describe( 'Gutenberg Editor Audio Block tests', () => { // tap on Media Library option await editorPage.chooseMediaLibrary(); // wait until the media is added - await editorPage.driver.sleep( 500 ); + await editorPage.driver.pause( 500 ); // get the html version of the content const html = await editorPage.getHtmlContent(); @@ -65,7 +65,7 @@ describe( 'Gutenberg Editor File Block tests', () => { // tap on Media Library option await editorPage.chooseMediaLibrary(); // wait until the media is added - await editorPage.driver.sleep( 500 ); + await editorPage.driver.pause( 500 ); // get the html version of the content const html = await editorPage.getHtmlContent(); diff --git a/packages/react-native-editor/__device-tests__/pages/editor-page.js b/packages/react-native-editor/__device-tests__/pages/editor-page.js index b4a433d5c1ab9..a4f43738f8ee5 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -527,7 +527,7 @@ class EditorPage { async moveBlockSelectionUp( options = { toRoot: false } ) { let navigateUpElements = []; do { - await this.driver.sleep( 2000 ); + await this.driver.pause( 2000 ); navigateUpElements = await this.driver.elementsByAccessibilityId( 'Navigate Up' ); if ( navigateUpElements.length > 0 ) { From fb5b3ca0020bd85b3dd9c299467bb7e43ce9b237 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 10 Oct 2023 15:06:12 -0400 Subject: [PATCH 2/4] test: Replace elementsByAccessibilityId usage Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade. --- .../gutenberg-editor-media-blocks-@canary.test.js | 3 +-- .../__device-tests__/pages/editor-page.js | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js b/packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js index fe849db2817f9..e9f1b57c82f57 100644 --- a/packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js +++ b/packages/react-native-editor/__device-tests__/gutenberg-editor-media-blocks-@canary.test.js @@ -151,8 +151,7 @@ onlyOniOS( 'Gutenberg Editor Cover Block test', () => { await editorPage.replaceMediaImage(); // First modal should no longer be presented. - const replaceButtons = - await editorPage.driver.elementsByAccessibilityId( 'Replace' ); + const replaceButtons = await editorPage.driver.$$( '~Replace' ); // eslint-disable-next-line jest/no-conditional-expect expect( replaceButtons.length ).toBe( 0 ); diff --git a/packages/react-native-editor/__device-tests__/pages/editor-page.js b/packages/react-native-editor/__device-tests__/pages/editor-page.js index a4f43738f8ee5..f1577c5a01994 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -528,8 +528,7 @@ class EditorPage { let navigateUpElements = []; do { await this.driver.pause( 2000 ); - navigateUpElements = - await this.driver.elementsByAccessibilityId( 'Navigate Up' ); + navigateUpElements = await this.driver.$$( `~Navigate Up` ); if ( navigateUpElements.length > 0 ) { await navigateUpElements[ 0 ].click(); } @@ -770,8 +769,7 @@ class EditorPage { this.driver, '//XCUIElementTypeOther[@name="Media Add image or video"]' ); - const addMediaButton = - await mediaSection.elementByAccessibilityId( 'Add image or video' ); + const addMediaButton = await mediaSection.$( '~Add image or video' ); await addMediaButton.click(); } From 56922c747eb368c670b9dd536b1e4f1ce44ad434 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 10 Oct 2023 15:06:57 -0400 Subject: [PATCH 3/4] test: Replace elementByXPath usage Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade. --- .../__device-tests__/pages/editor-page.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/pages/editor-page.js b/packages/react-native-editor/__device-tests__/pages/editor-page.js index f1577c5a01994..4d11285ea9326 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -577,7 +577,7 @@ class EditorPage { blockLocator += `[@${ this.accessibilityIdXPathAttrib }="Move block up from row ${ position } to row ${ position - 1 }"]`; - const moveUpButton = await this.driver.elementByXPath( blockLocator ); + const moveUpButton = await this.driver.$( `~${ blockLocator }` ); await moveUpButton.click(); } @@ -793,8 +793,7 @@ class EditorPage { this.accessibilityIdKey ); const blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ accessibilityId }"]//XCUIElementTypeButton[@name="Image block. Empty"]`; - const imageBlockInnerElement = - await this.driver.elementByXPath( blockLocator ); + const imageBlockInnerElement = await this.driver.$( blockLocator ); await imageBlockInnerElement.click(); } From 90d8bb9ac5835b2cefbc0db245f088705db77541 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 10 Oct 2023 15:07:42 -0400 Subject: [PATCH 4/4] test: Repair enterCaptionToSelectedImageBlock utility Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade. Additionally, the `clearValue` method did not succeed on the caption Button element. Hence, the utility was expanded to instead type into the TextView. --- .../__device-tests__/pages/editor-page.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-native-editor/__device-tests__/pages/editor-page.js b/packages/react-native-editor/__device-tests__/pages/editor-page.js index 4d11285ea9326..c4ede7c1daa0c 100644 --- a/packages/react-native-editor/__device-tests__/pages/editor-page.js +++ b/packages/react-native-editor/__device-tests__/pages/editor-page.js @@ -806,10 +806,13 @@ class EditorPage { } async enterCaptionToSelectedImageBlock( caption, clear = true ) { - const imageBlockCaptionField = await this.driver.elementByXPath( + const imageBlockCaptionButton = await this.driver.$( '//XCUIElementTypeButton[starts-with(@name, "Image caption.")]' ); - await imageBlockCaptionField.click(); + await imageBlockCaptionButton.click(); + const imageBlockCaptionField = await imageBlockCaptionButton.$( + '//XCUIElementTypeTextView' + ); await typeString( this.driver, imageBlockCaptionField, caption, clear ); }