Skip to content

Commit

Permalink
test: Update Media Blocks tests for Appium 2 (#55222)
Browse files Browse the repository at this point in the history
* test: Replace sleep with pause utility

Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade.

* test: Replace elementsByAccessibilityId usage

Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade.

* test: Replace elementByXPath usage

Update syntax for WebdriverIO, which is a part of the Appium 2 upgrade.

* 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.
  • Loading branch information
dcalhoun authored Oct 11, 2023
1 parent 3027b7e commit 9ffbe9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 );

Expand Down
20 changes: 10 additions & 10 deletions packages/react-native-editor/__device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,8 @@ class EditorPage {
async moveBlockSelectionUp( options = { toRoot: false } ) {
let navigateUpElements = [];
do {
await this.driver.sleep( 2000 );
navigateUpElements =
await this.driver.elementsByAccessibilityId( 'Navigate Up' );
await this.driver.pause( 2000 );
navigateUpElements = await this.driver.$$( `~Navigate Up` );
if ( navigateUpElements.length > 0 ) {
await navigateUpElements[ 0 ].click();
}
Expand Down Expand Up @@ -578,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();
}

Expand Down Expand Up @@ -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();
}

Expand All @@ -795,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();
}

Expand All @@ -809,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 );
}

Expand Down

0 comments on commit 9ffbe9a

Please sign in to comment.