Skip to content

Commit

Permalink
test: Increase swipeDown swipe distance
Browse files Browse the repository at this point in the history
The larger swipe distance results in faster scrolling, which will reduce
the time it takes to scroll. The reduced time will mitigate the need to
await longer scroll durations before asserting expectations and reduce
test durations in general.
  • Loading branch information
dcalhoun committed Jan 23, 2024
1 parent 65c1f46 commit 8618276
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
24 changes: 19 additions & 5 deletions packages/react-native-editor/__device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,29 @@ const swipeFromTo = async (
.pause( delay )
.perform();

// Starts from the middle of the screen and swipes downwards
const swipeDown = async ( driver, delay = 3000 ) => {
/**
* Swipe downwards from 20% of the dislay height to 100% of display
*
* @param {Object} driver WebdriverIO driver
* @param {Object} options Options
* @param {number} options.delay Delay between the swipe and the next action
* @param {number} options.percentageOfDisplayToSwipe Percentage of the display to swipe
*/
const swipeDown = async (
driver,
{ delay = 3000, percentageOfDisplayToSwipe = 0 } = {}
) => {
const size = await driver.getWindowSize();
const y = 0;

const startX = size.width / 2;
const startY = y + size.height / 3;
const startY = 0 + size.height / 3;
const endX = startX;
const endY = startY - startY * -1 * 0.5;
const targetedSwipeHeight = size.height * percentageOfDisplayToSwipe;
const minimumSwipeHeight = startY + startY * 0.5;
const endY =
targetedSwipeHeight < minimumSwipeHeight
? minimumSwipeHeight
: targetedSwipeHeight;

await swipeFromTo(
driver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ class EditorPage {

if ( options.autoscroll ) {
if ( isAndroid() ) {
await swipeDown( this.driver );
await swipeDown( this.driver, {
percentageOfDisplayToSwipe: 1,
} );
} else {
await tapStatusBariOS( this.driver );
}
Expand Down

0 comments on commit 8618276

Please sign in to comment.