forked from GaloyMoney/blink-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add mobile e2e testing webdriver * fix: jest version mismatch * fix: lock files * feat: swipe and selector helpers * feat: script to find test device and env vars * feat: login flow and selector utils * feat: keyboard enter helper * chore: PR comments
- Loading branch information
Showing
30 changed files
with
3,664 additions
and
371 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# search for android device | ||
if [ "$TEST_DEVICE_ANDROID" ]; then | ||
echo "android exists" | ||
else | ||
TEST_DEVICE_ANDROID=$(adb devices -l | grep model | awk -F':' '{print $3}' | awk '{split($0,a," "); print a[1]}') | ||
fi | ||
echo $TEST_DEVICE_ANDROID | ||
|
||
|
||
# search for ios simulator | ||
if [ "$TEST_DEVICE_IOS" ]; then | ||
echo "ios exists" | ||
else | ||
TEST_DEVICE_IOS=$(xcrun simctl list devices booted | grep Booted | awk -F'(' '{print $1}' ) | ||
fi | ||
echo $TEST_DEVICE_IOS | ||
|
||
# TODO - TO SEARCH FOR A PHYSICAL DEVICE | ||
# xcrun xctrace list devices | ||
|
||
export TEST_DEVICE_ANDROID=$TEST_DEVICE_ANDROID | ||
export TEST_DEVICE_IOS=$TEST_DEVICE_IOS | ||
|
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,42 @@ | ||
# E2E Testing | ||
|
||
## To Test locally with Appium and Webdriver: | ||
|
||
1. run the debug version of the app `yarn android` or `yarn ios` | ||
2. In a new terminal run `yarn start:appium` | ||
3. In a new terminal run `yarn test:e2e:android` or `yarn test:e2e:ios` | ||
|
||
## To Test with Browserstack (cloud devices): | ||
|
||
\*\* this will eventually be integrated into CI, but for now you can test locally if you have | ||
access to browserstack.com | ||
|
||
``` | ||
export BROWSERSTACK_USER=YOURUSER | ||
export BROWSERSTACK_ACCESS_KEY=YOURKEY | ||
export BROWSERSTACK_APP_ID=bs://YOURAPPID | ||
``` | ||
|
||
run `yarn test:browserstack:android` | ||
|
||
## Getting the Name of an Android or IOS device | ||
|
||
There is a script in `bin/get-testing-device.sh` that will automatically get the name of the android or ios device and set the env vars `TEST_DEVICE_ANDROID` and `TEST_DEVICE_IOS` | ||
|
||
You can also manually set the environment variable for the test device like this: | ||
|
||
Android | ||
|
||
``` | ||
TEST_DEVICE_ANDROID="Pixel 3 API 29" yarn test:e2e:android | ||
``` | ||
|
||
IOS | ||
|
||
``` | ||
TEST_DEVICE_IOS="iPhone 13" yarn test:e2e:ios | ||
``` | ||
|
||
## Authenticated Tests | ||
|
||
To run the authenticated tests you need to set the env variable `GALOY_TOKEN`. The e2e test will navigate to the settings/build version page and input the token |
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,47 @@ | ||
import { i18nObject } from "../app/i18n/i18n-util" | ||
import { loadLocale } from "../app/i18n/i18n-util.sync" | ||
import { swipe, selector } from "./utils" | ||
|
||
describe("Welcome Screen Flow", async () => { | ||
loadLocale("en") | ||
const LL = i18nObject("en") | ||
const timeout = 30000 | ||
beforeEach(async () => { | ||
console.info("[beforeAll]") | ||
}) | ||
afterEach(async () => { | ||
console.info("[afterAll] Done with testing!") | ||
await browser.pause(1500) | ||
}) | ||
it("loads and clicks 'Get Started button' ", async () => { | ||
const getStartedButton = await $(selector(LL.GetStartedScreen.getStarted())) | ||
await getStartedButton.waitForDisplayed({ timeout }) | ||
await getStartedButton.click() | ||
expect(true).toBeTruthy() | ||
}) | ||
|
||
it("swipes Why Should I Care?", async () => { | ||
const caresText = await $(selector(LL.WelcomeFirstScreen.care(), "StaticText")) | ||
await caresText.waitForDisplayed({ timeout }) | ||
await swipe() | ||
}) | ||
|
||
it("swipes Bitcoin is designed to let you...bank", async () => { | ||
const bankText = await $(selector(LL.WelcomeFirstScreen.bank(), "StaticText")) | ||
await bankText.waitForDisplayed({ timeout }) | ||
await swipe() | ||
}) | ||
|
||
it("swipes Before Bitcoin people had to...", async () => { | ||
const beforeText = await $(selector(LL.WelcomeFirstScreen.before(), "StaticText")) | ||
await beforeText.waitForDisplayed({ timeout }) | ||
await swipe() | ||
}) | ||
|
||
it("clicks 'Learn to Earn' and enters the main app", async () => { | ||
const learnButton = await $(selector(LL.WelcomeFirstScreen.learnToEarn())) | ||
await learnButton.waitForDisplayed({ timeout }) | ||
await learnButton.click() | ||
expect(true).toBeTruthy() | ||
}) | ||
}) |
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,72 @@ | ||
import { i18nObject } from "../app/i18n/i18n-util" | ||
import { loadLocale } from "../app/i18n/i18n-util.sync" | ||
import { goBack, selector, enter } from "./utils" | ||
|
||
describe("Login Flow", async () => { | ||
loadLocale("en") | ||
const LL = i18nObject("en") | ||
const timeout = 30000 | ||
beforeEach(async () => { | ||
console.info("[beforeAll]") | ||
}) | ||
afterEach(async () => { | ||
console.info("[afterAll] Done with testing!") | ||
await browser.pause(5000) | ||
}) | ||
it("clicks Settings Icon", async () => { | ||
const settingsButton = await $(selector("Settings Button")) | ||
await settingsButton.waitForDisplayed({ timeout }) | ||
await settingsButton.click() | ||
}) | ||
|
||
it("taps Build version 3 times", async () => { | ||
const buildButton = await $(selector("Version Build Text", "StaticText")) | ||
await buildButton.waitForDisplayed({ timeout }) | ||
await buildButton.click() | ||
await buildButton.click() | ||
await buildButton.click() | ||
}) | ||
|
||
it("click staging environment", async () => { | ||
await browser.pause(1000) | ||
const instanceButton = await $(selector("Galoy Instance Button", "Other")) | ||
await instanceButton.waitForDisplayed({ timeout }) | ||
const { x, y } = await instanceButton.getLocation() | ||
const { width, height } = await instanceButton.getSize() | ||
// calc the midpoint center because we want to click the second button - in the middle | ||
const midpointX = width / 2 + x | ||
const midpointY = height / 2 + y | ||
await browser.touchAction({ action: "tap", x: midpointX, y: midpointY }) | ||
}) | ||
|
||
it("input token", async () => { | ||
try { | ||
const tokenInput = await $(selector("Input access token", "TextField")) | ||
await tokenInput.waitForDisplayed({ timeout }) | ||
await tokenInput.click() | ||
await browser.pause(500) | ||
await tokenInput.sendKeys(process.env.GALOY_TOKEN?.split("")) | ||
await enter(tokenInput) | ||
} catch (e) { | ||
// TODO this passes but throws an error on ios even tho it works | ||
} | ||
}) | ||
|
||
it("click change token", async () => { | ||
const changeTokenButton = await $(selector("Change Token Button")) | ||
await changeTokenButton.waitForDisplayed({ timeout }) | ||
await changeTokenButton.click() | ||
}) | ||
|
||
it("click go back to settings screen", async () => { | ||
const backButton = await $(goBack()) | ||
await backButton.waitForDisplayed({ timeout }) | ||
await backButton.click() | ||
}) | ||
|
||
it("click go back to home screen", async () => { | ||
const backButton = await $(goBack()) | ||
await backButton.waitForDisplayed({ timeout }) | ||
await backButton.click() | ||
}) | ||
}) |
Oops, something went wrong.