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

test: Update Media Blocks tests for Appium 2 #55222

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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'
);
Comment on lines +813 to +815
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clearValue method did not succeed on the caption Button element. Hence, the utility was expanded to instead type into the TextView.

await typeString( this.driver, imageBlockCaptionField, caption, clear );
}

Expand Down
Loading