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

[Mobile] - Update closePicker util and updates Image Block test data #55484

Merged
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 @@ -15,7 +15,7 @@ describe( 'Gutenberg Editor Audio Block tests', () => {

// dismiss the media picker automatically opened when adding an audio block
await waitForMediaLibrary( editorPage.driver );
await editorPage.closePicker();
await editorPage.closeMediaPicker();

// verify there's an audio block
const block = await editorPage.getFirstBlockVisible();
Expand Down Expand Up @@ -50,7 +50,7 @@ describe( 'Gutenberg Editor File Block tests', () => {

// dismiss the media picker automatically opened when adding a file block
await waitForMediaLibrary( editorPage.driver );
await editorPage.closePicker();
await editorPage.closeMediaPicker();

// verify there's a file block
const block = await editorPage.getFirstBlockVisible();
Expand Down Expand Up @@ -82,7 +82,7 @@ onlyOniOS( 'Gutenberg Editor Image Block tests', () => {
it( 'should be able to add an image block', async () => {
await editorPage.initializeEditor();
await editorPage.addNewBlock( blockNames.image );
await editorPage.closePicker();
await editorPage.closeMediaPicker();

const imageBlock = await editorPage.getBlockAtPosition(
blockNames.image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ exports.blockInsertionHtmlFromTitle = `<!-- wp:paragraph -->
<p>The finer continuum interprets the polynomial rabbit. When can the geology runs? An astronomer runs. Should a communist consent?</p>
<!-- /wp:paragraph -->`;

exports.imageCaption = `C'est la vie my friends`;
exports.imageCaption = `Autumn meets winter`;

exports.imageCompletehtml = `<!-- wp:image {"id":1,"sizeslug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/><figcaption>C'est la vie my friends</figcaption></figure>
Expand All @@ -96,7 +96,7 @@ exports.imageCompletehtml = `<!-- wp:image {"id":1,"sizeslug":"large"} -->
<!-- /wp:paragraph -->`;

exports.imageShortHtml = `<!-- wp:image {"id":1,"sizeslug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="A snow-capped mountain top in a cloudy sky with red-leafed trees in the foreground" class="wp-image-1"/><figcaption class="wp-element-caption">C'est la vie my friends</figcaption></figure>
<figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="A snow-capped mountain top in a cloudy sky with red-leafed trees in the foreground" class="wp-image-1"/><figcaption class="wp-element-caption">Autumn meets winter</figcaption></figure>
<!-- /wp:image -->`;

exports.unsupportedBlockHtml = `<!-- wp:jetpack/gif {"giphyUrl":"https://giphy.com/embed/3orieS4jfHJaKwkeli","searchText":"example"} /-->`;
Expand Down
36 changes: 14 additions & 22 deletions packages/react-native-editor/__device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -816,28 +816,20 @@ class EditorPage {
await typeString( this.driver, imageBlockCaptionField, caption, clear );
}

async closePicker() {
if ( isAndroid() ) {
// Wait for media block picker to load before closing
const locator =
'//android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup';
await waitForVisible( this.driver, locator );

const { width, height } = await this.driver.getWindowSize();
await this.driver
.action( 'pointer', {
parameters: { pointerType: 'touch' },
} )
.move( { x: width * 0.5, y: height * 0.1 } )
.down( { button: 0 } )
.up( { button: 0 } )
.perform();
} else {
await clickIfClickable(
this.driver,
'//XCUIElementTypeButton[@name="Cancel"]'
);
}
async closeMediaPicker() {
// Wait for media block picker to load before closing
const locator = '~WordPress Media Library';
await this.driver.$( locator ).waitForDisplayed();

const { width, height } = await this.driver.getWindowSize();
await this.driver
.action( 'pointer', {
parameters: { pointerType: 'touch' },
} )
.move( { x: width * 0.5, y: height * 0.1 } )
.down( { button: 0 } )
.up( { button: 0 } )
.perform();
}

// =============================
Expand Down
Loading