Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Poc detox #2484

Merged
merged 11 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .detoxrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"build": "cd android && ENVFILE=.env.mock ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"device": {
"avdName": "Nexus_5X_API_29_x86"
"avdName": "Nexus_6_API_30"
}
},
"android.staging": {
Expand All @@ -33,7 +33,16 @@
"build": "cd android && ENVFILE=.env.mock ./gradlew assembleStagingRelease assembleAndroidTest -DtestBuildType=stagingRelease && cd ..",
"type": "android.emulator",
"device": {
"avdName": "Nexus_5X_API_29_x86"
"avdName": "Nexus_6_API_30"
}
},
"android.staging-ci": {
"binaryPath": "android/app/build/outputs/apk/stagingRelease/app-x86-stagingRelease.apk",
"testBinaryPath": "android/app/build/outputs/apk/androidTest/stagingRelease/app-stagingRelease-androidTest.apk",
"build": "cd android && ENVFILE=.env.mock ./gradlew assembleStagingRelease assembleAndroidTest -DtestBuildType=stagingRelease -PwithTestButler --warning-mode all && cd ..",
"type": "android.emulator",
"device": {
"avdName": "Nexus_6_API_30"
}
}
}
Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/detox-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Detox E2E CI

on:
pull_request:
branches:
- "*"
workflow_dispatch:
inputs:
prNumber:
description: pr number to trigger on
required: true
schedule:
- cron: "0 0 * * *"

jobs:
ios:
runs-on: macos-latest
steps:
- name: Checkout PR
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Install applesimutils
run: |
brew tap wix/brew
brew install applesimutils

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14
cache: 'yarn'

- name: Has hash commit deps
uses: ledgerhq/actions/packages/has-hash-commit-deps@main
id: has-hash-commit-deps
with:
workspace: ${{ github.workspace }}

- name: Install dependencies without network concurrency
if: ${{ steps.has-hash-commit-deps.outputs.has-hash-commit-deps == 'true' }}
env:
JOBS: max
run: yarn --prefer-offline --frozen-lockfile --network-timeout 100000 --network-concurrency 1

- name: Install dependencies with network concurrency
if: ${{ steps.has-hash-commit-deps.outputs.has-hash-commit-deps == 'false' }}
env:
JOBS: max
run: yarn --prefer-offline --frozen-lockfile --network-timeout 100000

- name: Rebuild detox
run: yarn detox clean-framework-cache && yarn detox build-framework-cache

- name: Build iOS app for Detox test run
env:
NODE_OPTIONS: "--max-old-space-size=7168"
run: yarn e2e:build -c ios.staging

- name: Test iOS app
timeout-minutes: 15
run: yarn e2e:test -c ios.staging --loglevel verbose --record-logs failing --record-timeline all --take-screenshots all --record-videos failing --detectOpenHandles
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: test-ios-artifacts
path: artifacts
1 change: 0 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ allprojects {
maven {
url "$rootDir/../node_modules/expo-camera/android/maven"
}
jcenter()
}
configurations.all {
resolutionStrategy {
Expand Down
12 changes: 6 additions & 6 deletions e2e/engine/bridge/client.js → e2e/bridge/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Platform } from "react-native";
import invariant from "invariant";
import { Subject } from "rxjs/Subject";
import type { AccountRaw } from "@ledgerhq/live-common/lib/types";
import { store } from "../../../src/context/LedgerStore";
import { importSettings } from "../../../src/actions/settings";
import { setAccounts } from "../../../src/actions/accounts";
import { acceptTerms } from "../../../src/logic/terms";
import accountModel from "../../../src/logic/accountModel";
import { navigate } from "../../../src/rootnavigation";
import { store } from "../../src/context/LedgerStore";
import { importSettings } from "../../src/actions/settings";
import { setAccounts } from "../../src/actions/accounts";
import { acceptTerms } from "../../src/logic/terms";
import accountModel from "../../src/logic/accountModel";
import { navigate } from "../../src/rootnavigation";

let ws: WebSocket;

Expand Down
8 changes: 2 additions & 6 deletions e2e/engine/bridge/server.js → e2e/bridge/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { Server } from "ws";
import path from "path";
import fs from "fs";
import type { E2EBridgeMessage } from "./client";
import { $waitFor } from "../utils";
import { NavigatorName } from "../../../src/const";
import { NavigatorName } from "../../src/const";

let wss: Server;

Expand Down Expand Up @@ -35,15 +34,12 @@ export async function loadConfig(
const { data } = JSON.parse(f);

postMessage({ type: "importSettngs", payload: data.settings });

navigate(NavigatorName.Base);

if (data.accounts.length) {
postMessage({ type: "importAccounts", payload: data.accounts });
await $waitFor("PortfolioAccountsList", -1, 10000);
return;
}

await $waitFor("PortfolioEmptyAccount");
}

function navigate(name: string) {
Expand Down
8 changes: 5 additions & 3 deletions e2e/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"globalSetup": "./global-setup.js",
"globalTeardown": "./global-teardown.js",
"setupFilesAfterEnv": ["./setup.js"],
"testEnvironment": "./environment",
"testRunner": "jest-circus/runner",
"testTimeout": 120000,
"testTimeout": 300000,
"testRegex": "\\.spec\\.js$",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true,
"setupFilesAfterEnv": ["./init.js"]
"verbose": true
}
2 changes: 1 addition & 1 deletion e2e/e2e-bridge-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
import Config from "react-native-config";

if (Config.MOCK) {
import("./engine/bridge/client").then(({ init }) => init());
import("./bridge/client").then(({ init }) => init());
}
2 changes: 0 additions & 2 deletions e2e/engine/flows/index.js

This file was deleted.

66 changes: 0 additions & 66 deletions e2e/engine/flows/onboarding.js

This file was deleted.

6 changes: 0 additions & 6 deletions e2e/engine/index.js

This file was deleted.

63 changes: 0 additions & 63 deletions e2e/engine/utils.js

This file was deleted.

7 changes: 7 additions & 0 deletions e2e/global-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const detox = require("detox");

async function globalSetup() {
await detox.globalInit();
}

module.exports = globalSetup;
7 changes: 7 additions & 0 deletions e2e/global-teardown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const detox = require("detox");

async function globalTeardown() {
await detox.globalCleanup();
}

module.exports = globalTeardown;
Loading