-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0144f7
commit 546b4a9
Showing
13 changed files
with
595 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** @type {Detox.DetoxConfig} */ | ||
module.exports = { | ||
testRunner: { | ||
args: { | ||
$0: "jest", | ||
config: "e2e/detox/jest.config.js", | ||
}, | ||
jest: { | ||
setupTimeout: 120000, | ||
}, | ||
}, | ||
apps: { | ||
"ios.debug": { | ||
type: "ios.app", | ||
binaryPath: "ios/build/Build/Products/Debug-iphonesimulator/Blink.app", | ||
build: | ||
"xcodebuild -workspace ios/GaloyApp.xcworkspace -scheme GaloyApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", | ||
}, | ||
"android.debug": { | ||
type: "android.apk", | ||
binaryPath: "android/app/build/outputs/apk/debug/app-universal-debug.apk", | ||
testBinaryPath: | ||
"android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk", | ||
build: | ||
"cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug", | ||
reversePorts: [8081], | ||
}, | ||
}, | ||
devices: { | ||
simulator: { | ||
type: "ios.simulator", | ||
device: { | ||
type: "iPhone SE (3rd generation)", | ||
}, | ||
}, | ||
emulator: { | ||
type: "android.emulator", | ||
device: { | ||
avdName: "Pixel_API_29_AOSP", | ||
}, | ||
}, | ||
}, | ||
configurations: { | ||
"ios.sim.debug": { | ||
device: "simulator", | ||
app: "ios.debug", | ||
}, | ||
"android.emu.debug": { | ||
device: "emulator", | ||
app: "android.debug", | ||
}, | ||
}, | ||
} |
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
29 changes: 29 additions & 0 deletions
29
android/app/src/androidTest/java/com/galoyapp/DetoxTest.java
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,29 @@ | ||
package com.galoyapp; // (1) | ||
|
||
import com.wix.detox.Detox; | ||
import com.wix.detox.config.DetoxConfig; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import androidx.test.filters.LargeTest; | ||
import androidx.test.rule.ActivityTestRule; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class DetoxTest { | ||
@Rule // (2) | ||
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); | ||
|
||
@Test | ||
public void runDetoxTests() { | ||
DetoxConfig detoxConfig = new DetoxConfig(); | ||
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; | ||
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; | ||
detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60); | ||
|
||
Detox.runTests(mActivityRule, detoxConfig); | ||
} | ||
} |
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<network-security-config> | ||
<domain-config cleartextTrafficPermitted="true"> | ||
<domain includeSubdomains="true">10.0.2.2</domain> | ||
<domain includeSubdomains="true">localhost</domain> | ||
</domain-config> | ||
</network-security-config> |
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,71 @@ | ||
import { expect } from "detox" | ||
|
||
import { timeout, otp, ALICE_PHONE } from "./utils/config" | ||
|
||
import { i18nObject } from "../../app/i18n/i18n-util" | ||
import { loadLocale } from "../../app/i18n/i18n-util.sync" | ||
|
||
const tap = async (match: Detox.NativeMatcher) => { | ||
const el = element(match) | ||
await waitFor(el).toBeVisible().withTimeout(timeout) | ||
await el.tap() | ||
} | ||
|
||
describe("Login with Phone Flow", () => { | ||
loadLocale("en") | ||
const LL = i18nObject("en") | ||
|
||
beforeAll(async () => { | ||
await device.launchApp() | ||
}) | ||
|
||
it("set environment", async () => { | ||
const buildBtn = element(by.id("logo-button")) | ||
// Wait for 2 mins because metro bundler might not finish sync | ||
await waitFor(buildBtn).toBeVisible().withTimeout(1200000) | ||
await buildBtn.multiTap(3) | ||
|
||
const logoutBtn = element(by.id("logout button")) | ||
await expect(logoutBtn).toBeVisible() | ||
|
||
const envBtn = element(by.id("Local Button")) | ||
const developerScreenSV = by.id("developer-screen-scroll-view") | ||
|
||
await waitFor(envBtn) | ||
.toBeVisible() | ||
.whileElement(developerScreenSV) | ||
.scroll(400, "down", NaN, 0.85) | ||
await envBtn.tap() | ||
|
||
const saveChangesBtn = element(by.id("Save Changes")) | ||
await saveChangesBtn.tap() | ||
|
||
const stagingInstanceText = element(by.text(`Galoy Instance: Local`)) | ||
await waitFor(stagingInstanceText).toBeVisible().withTimeout(10000) | ||
|
||
await tap(by.id("Back")) | ||
}) | ||
|
||
it("login as an user", async () => { | ||
await tap(by.id(LL.GetStartedScreen.createAccount())) | ||
|
||
const telephoneInput = element(by.id("telephoneNumber")) | ||
await waitFor(telephoneInput).toBeVisible().withTimeout(timeout) | ||
await telephoneInput.clearText() | ||
await telephoneInput.typeText(ALICE_PHONE) | ||
await tap(by.id(LL.PhoneLoginInitiateScreen.sms())) | ||
|
||
const otpInput = element(by.id("oneTimeCode")) | ||
try { | ||
await waitFor(otpInput).toBeVisible().withTimeout(timeout) | ||
await otpInput.clearText() | ||
await otpInput.typeText(otp) | ||
} catch { | ||
/* empty because sometimes the page just moves to the next page coz 000000 is default */ | ||
} | ||
|
||
await waitFor(element(by.text(LL.HomeScreen.myAccounts()))) | ||
.toBeVisible() | ||
.withTimeout(timeout) | ||
}) | ||
}) |
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 @@ | ||
/** @type {import('@jest/types').Config.InitialOptions} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
rootDir: "..", | ||
testMatch: ["<rootDir>/detox/**/*.test.ts"], | ||
testTimeout: 120000, | ||
maxWorkers: 1, | ||
globalSetup: "detox/runners/jest/globalSetup", | ||
globalTeardown: "detox/runners/jest/globalTeardown", | ||
reporters: ["detox/runners/jest/reporter"], | ||
testEnvironment: "detox/runners/jest/testEnvironment", | ||
verbose: true, | ||
} |
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 { config } from "dotenv" | ||
import path from "path" | ||
|
||
config({ path: path.join(__dirname, "../../../dev/.env") }) | ||
|
||
if (!process.env.ALICE_PHONE || !process.env.BOB_PHONE) { | ||
throw new Error("Development environment environment configuration is incorrect") | ||
} | ||
|
||
export const timeout = 3000 | ||
export const otp = process.env.GALOY_STAGING_GLOBAL_OTP || "000000" | ||
|
||
export const ALICE_PHONE = process.env.ALICE_PHONE | ||
export const BOB_PHONE = process.env.BOB_PHONE |
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.