Skip to content

Commit

Permalink
[RNMobile] Add e2e util addBlockUsingAppender (#52736)
Browse files Browse the repository at this point in the history
* Add e2e util `addBlockUsingAppender`

Fix query for Android

* Add group block test data

* Update group block test data
  • Loading branch information
fluiddot authored Aug 1, 2023
1 parent 0f8bb00 commit 1d9352f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/react-native-editor/__device-tests__/helpers/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,33 @@ exports.galleryBlock = `<!-- wp:gallery {"columns":8,"linkTo":"none","className"
<!-- /wp:image -->
</figure>
<!-- /wp:gallery -->`;

exports.groupNestedStructure = `<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:paragraph {"style":{"color":{"background":"#f9d0d0"}}} -->
<p class="has-background" style="background-color:#f9d0d0">Level 1</p>
<!-- /wp:paragraph -->
<!-- wp:spacer {"height":"50px"} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:paragraph {"style":{"color":{"background":"#d5f0ab"}}} -->
<p class="has-background" style="background-color:#d5f0ab">Level 2</p>
<!-- /wp:paragraph -->
<!-- wp:spacer {"height":"50px"} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:paragraph {"style":{"color":{"background":"#c3e5ff"}}} -->
<p class="has-background" style="background-color:#c3e5ff">Level 3</p>
<!-- /wp:paragraph -->
<!-- wp:spacer {"height":"50px"} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer --></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->`;
23 changes: 23 additions & 0 deletions packages/react-native-editor/__device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,29 @@ class EditorPage {
} while ( navigateUpElements.length > 0 );
}

// Adds a block by tapping on the appender button of blocks with inner blocks (e.g. Group block)
async addBlockUsingAppender( block, blockName ) {
const appenderButton = isAndroid()
? await this.waitForElementToBeDisplayedByXPath(
`//android.widget.Button[@resource-id="appender-button"]`
)
: await this.waitForElementToBeDisplayedById( 'appender-button' );
await appenderButton.click();

// Click on block of choice.
const blockButton = await this.findBlockButton( blockName );

if ( isAndroid() ) {
await blockButton.click();
} else {
await this.driver.execute( 'mobile: tap', {
element: blockButton,
x: 10,
y: 10,
} );
}
}

// =========================
// Inline toolbar functions
// =========================
Expand Down

0 comments on commit 1d9352f

Please sign in to comment.