Skip to content

Commit

Permalink
E2E Helpers - Adds typeKeyString and toggleHighlightColor
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo committed Jan 22, 2024
1 parent 3958f69 commit d8c6e5a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 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 @@ -107,6 +107,16 @@ class EditorPage {
await typeString( this.driver, block, text, clear );
}

async typeKeyString( inputString ) {
const actions = this.driver.action( 'key' );

for ( const char of inputString ) {
await actions.down( char ).up( char );
}

await actions.perform();
}

async pasteClipboardToTextBlock( element, { timeout = 1000 } = {} ) {
if ( this.driver.isAndroid ) {
await longPressMiddleOfElement( this.driver, element );
Expand Down Expand Up @@ -728,6 +738,22 @@ class EditorPage {
await element.click();
}

async toggleHighlightColor( color ) {
await this.toggleFormatting( 'Text color' );
let element = `~${ color }`;

if ( ! color ) {
element = isAndroid()
? '~Clear selected color'
: '(//XCUIElementTypeOther[@name="Clear selected color"])[2]';
}

await this.driver.waitUntil( this.driver.$( element ).isDisplayed );
const button = await this.driver.$( element );
await button.click();
await this.dismissBottomSheet();
}

// =========================
// Paragraph Block functions
// =========================
Expand Down

0 comments on commit d8c6e5a

Please sign in to comment.