Skip to content

Commit

Permalink
Revert "e2e: faster selection test (#747)"
Browse files Browse the repository at this point in the history
This reverts commit f096a2f.
  • Loading branch information
kirillzyusko committed Dec 31, 2024
1 parent 52f35ab commit c305450
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
41 changes: 17 additions & 24 deletions e2e/kit/helpers/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import colors from "colors/safe";
import { expect } from "detox";

import { waitForElementById } from "../awaitable";
import { getDevicePreference } from "../env/devicePreferences";
Expand Down Expand Up @@ -128,34 +129,26 @@ export const scrollDownUntilElementIsVisible = async (
.scroll(100, "down", NaN, 0.5);
};

type Frame = {
x: number;
y: number;
width: number;
height: number;
};

export const scrollUpUntilElementIsBarelyVisible = async (
scrollViewId: string,
elementId: string,
threshold = 10,
): Promise<void> => {
// scroll a little bit to update the frame, otherwise
// we may read out of date frame on Android
await element(by.id(scrollViewId)).scroll(1, "up", 0.01, 0.5);
await element(by.id(scrollViewId)).scroll(1, "up", 0.01, 0.5);
const preference = getDevicePreference();
const { frame } = (await element(by.id(elementId)).getAttributes()) as {
frame: Frame;
};
const distance =
preference.height -
preference.keyboard -
frame.y -
frame.height -
threshold;

await element(by.id(scrollViewId)).scroll(distance, "up", 0.01, 0.5);
for (;;) {
await element(by.id(scrollViewId)).scroll(50, "up", 0.01, 0.5);

try {
// verify that we can interact with element
if (device.getPlatform() === "ios") {
await expect(element(by.id(elementId))).toBeVisible();
} else {
// on Android visible is always true
await element(by.id(elementId)).tap({ x: 0, y: 25 });
}
} catch (e) {
await element(by.id(scrollViewId)).scroll(35, "down", 0.01, 0.5);
break;
}
}
};

export const closeKeyboard = async (textInputId: string) => {
Expand Down
7 changes: 0 additions & 7 deletions e2e/kit/helpers/env/devicePreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,37 @@ import parseDeviceName from "../../utils/parseDeviceName";

type Preference = {
emojiButtonCoordinates?: { x: number; y: number };
keyboard: number;
width: number;
height: number;
};

const DEVICE_PREFERENCES: Record<string, Preference> = {
"e2e_emulator_28": {
keyboard: 980,
emojiButtonCoordinates: undefined,
width: 1080,
height: 1920,
},
"e2e_emulator_31": {
keyboard: 830,
emojiButtonCoordinates: { x: 324, y: 1704 },
width: 1080,
height: 1920,
},
"iPhone 16 Pro": {
keyboard: 291,
emojiButtonCoordinates: { x: 40, y: 830 },
width: 393,
height: 852,
},
"iPhone 15 Pro": {
keyboard: 291,
emojiButtonCoordinates: { x: 40, y: 830 },
width: 393,
height: 852,
},
"iPhone 14 Pro": {
keyboard: 291,
emojiButtonCoordinates: { x: 40, y: 830 },
width: 393,
height: 852,
},
"iPhone 13 Pro": {
keyboard: 286,
emojiButtonCoordinates: { x: 40, y: 830 },
width: 390,
height: 844,
Expand Down

0 comments on commit c305450

Please sign in to comment.