Skip to content

Commit

Permalink
Merge branch 'master' into feat/long-press-point
Browse files Browse the repository at this point in the history
  • Loading branch information
asafkorem committed May 12, 2024
2 parents dfa182a + 4c1c05e commit afb5603
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
39 changes: 21 additions & 18 deletions detox/detox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1279,12 +1279,31 @@ declare global {
* Performs the action repeatedly on the element until an expectation is met
* @example await waitFor(element(by.text('Item #5'))).toBeVisible().whileElement(by.id('itemsList')).scroll(50, 'down');
*/
whileElement(by: NativeMatcher): NativeElement & WaitFor;
whileElement(by: NativeMatcher): NativeElementWaitableActions & WaitFor;

// TODO: not sure about & WaitFor - check if we can chain whileElement multiple times
}

interface NativeElementActions {
interface NativeElementWaitableActions {

/**
* Scrolls a given amount of pixels in the provided direction, starting from the provided start positions.
* @param pixels - independent device pixels
* @param direction - left/right/up/down
* @param startPositionX - the X starting scroll position, in percentage; valid input: `[0.0, 1.0]`, `NaN`; default: `NaN`—choose the best value automatically
* @param startPositionY - the Y starting scroll position, in percentage; valid input: `[0.0, 1.0]`, `NaN`; default: `NaN`—choose the best value automatically
* @example await element(by.id('scrollView')).scroll(100, 'down', NaN, 0.85);
* @example await element(by.id('scrollView')).scroll(100, 'up');
*/
scroll(
pixels: number,
direction: Direction,
startPositionX?: number,
startPositionY?: number
): Promise<void>;
}

interface NativeElementActions extends NativeElementWaitableActions{
/**
* Simulate tap on an element
* @param point coordinates in the element's coordinate space. Optional (default is the center of the element).
Expand Down Expand Up @@ -1361,22 +1380,6 @@ declare global {
*/
tapReturnKey(): Promise<void>;

/**
* Scrolls a given amount of pixels in the provided direction, starting from the provided start positions.
* @param pixels - independent device pixels
* @param direction - left/right/up/down
* @param startPositionX - the X starting scroll position, in percentage; valid input: `[0.0, 1.0]`, `NaN`; default: `NaN`—choose the best value automatically
* @param startPositionY - the Y starting scroll position, in percentage; valid input: `[0.0, 1.0]`, `NaN`; default: `NaN`—choose the best value automatically
* @example await element(by.id('scrollView')).scroll(100, 'down', NaN, 0.85);
* @example await element(by.id('scrollView')).scroll(100, 'up');
*/
scroll(
pixels: number,
direction: Direction,
startPositionX?: number,
startPositionY?: number
): Promise<void>;

/**
* Scroll to index.
* @example await element(by.id('scrollView')).scrollToIndex(10);
Expand Down
8 changes: 8 additions & 0 deletions detox/test/types/detox-global-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ describe("Test", () => {
.whileElement(by.id("ScrollView630"))
.scroll(50, "down");

await waitFor(element(by.text("Text5")))
.toBeVisible()
.whileElement(by.id("ScrollView630"))
.scroll(50, "down", 0.5, 0.5);

// @ts-expect-error
await waitFor(element(by.text("Text5"))).toBeVisible().whileElement(by.id("ScrollView630")).tap();

await web.element(by.web.id("btnSave")).tap();
await web.element(by.web.id("btnSave")).runScript('(el) => el.click()');
const scriptResult = await web.element(by.web.id("btnSave")).runScript(function (el: any, text: string) {
Expand Down

0 comments on commit afb5603

Please sign in to comment.