This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor and implement dialog methods * refactor tests to use snap_dialog * update documentation * fix comments * fix type logic * fix automation param in snap test
- Loading branch information
Showing
20 changed files
with
240 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { clickOnButton, retry } from "../../helpers"; | ||
import { DappeteerPage } from "../../page"; | ||
import { ensureIsInDialog } from "./helpers"; | ||
|
||
export const acceptDialog = | ||
(page: DappeteerPage) => async (): Promise<void> => { | ||
await retry(async () => { | ||
await ensureIsInDialog(page); | ||
await Promise.race([ | ||
clickOnButton(page, "Approve", { timeout: 1000 }), | ||
clickOnButton(page, "Ok", { timeout: 1000 }), | ||
clickOnButton(page, "Submit", { timeout: 1000 }), | ||
]); | ||
}, 5); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { DappeteerPage } from "../../page"; | ||
import { waitForOverlay } from "../../helpers"; | ||
|
||
export const ensureIsInDialog = async (page: DappeteerPage): Promise<void> => { | ||
await page.bringToFront(); | ||
if ( | ||
await page | ||
.waitForSelector(".snap-delineator__wrapper", { timeout: 500 }) | ||
.catch(() => false) | ||
) | ||
return; | ||
await page.reload(); | ||
await waitForOverlay(page); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { DappeteerPage } from "../../page"; | ||
import { Dappeteer } from "../../types"; | ||
import { acceptDialog } from "./acceptDialog"; | ||
import { rejectDialog } from "./rejectDialog"; | ||
import { typeDialog } from "./typeDialog"; | ||
|
||
export const createDialogMethods = ( | ||
page: DappeteerPage | ||
): Dappeteer["snaps"]["dialog"] => ({ | ||
accept: acceptDialog(page), | ||
reject: rejectDialog(page), | ||
type: typeDialog(page), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { clickOnButton, retry } from "../../helpers"; | ||
import { DappeteerPage } from "../../page"; | ||
import { ensureIsInDialog } from "./helpers"; | ||
|
||
export const rejectDialog = | ||
(page: DappeteerPage) => async (): Promise<void> => { | ||
await retry(async () => { | ||
await ensureIsInDialog(page); | ||
await Promise.race([ | ||
clickOnButton(page, "Reject", { timeout: 1000 }), | ||
clickOnButton(page, "Cancel", { timeout: 1000 }), | ||
]); | ||
}, 5); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { DappeteerPage } from "../../page"; | ||
import { retry } from "../../helpers"; | ||
import { ensureIsInDialog } from "./helpers"; | ||
|
||
export const typeDialog = | ||
(page: DappeteerPage) => | ||
async (value: string): Promise<void> => { | ||
await retry(async () => { | ||
await ensureIsInDialog(page); | ||
await page.type(".snap-prompt input", value); | ||
}, 5); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.