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

[POC] Appium #2191

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
"start": "react-native start",
"ios": "react-native run-ios",
"android": "react-native run-android --appIdSuffix=debug",
"android-staging": "react-native run-android",
"detox": "./node_modules/.bin/detox",
"e2e:build": "yarn detox build",
"e2e:test": "yarn detox test",
"prebeta": "bundle install",
"beta": "bundle exec fastlane beta --env production",
"ios:debug": "ENVFILE=.env.mock react-native run-ios",
"ios:staging": "ENVFILE=.env.staging react-native run-ios --configuration Staging",
"ios:test": "wdio ./tests/config/wdio.ios.app.conf.js",
"preios:local:adhoc": "bundle install",
"ios:local:adhoc": "bundle exec fastlane ios local_adhoc --env adhoc",
"preoios:local:beta": "bundle install",
Expand All @@ -42,8 +45,11 @@
"android:staging": "cd android && ./gradlew assembleStagingRelease",
"android:install": "./scripts/install-and-run-apk.sh",
"android:clean": "$ANDROID_HOME/platform-tools/adb shell pm clear com.ledger.live",
"android:debug": "cd android && ENVFILE=.env.mock ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"android:mock": "cd android && ENVFILE=.env.mock ./gradlew assembleStagingRelease",
"android:release": "./scripts/android-release.sh",
"android:test": "wdio ./tests/config/wdio.android.app.conf.js",
"android:test-debug": "wdio ./tests/config/wdio.android-debug.app.conf.js",
"mock-android": "yarn android:mock && yarn android:install",
"staging-android": "yarn android:staging && yarn android:install",
"prettier": "prettier --write \"src/**/*.js\"",
Expand All @@ -53,7 +59,8 @@
"sync-flowtyped": "NODE_OPTIONS=--max_old_space_size=10000 flow-typed install -s -o && rm flow-typed/npm/axios_*",
"sync-locales": "./scripts/sync-locales.sh",
"hack-for-ios-simulator": "cd node_modules/@ledgerhq/react-native-ledger-core/ios/Frameworks && mv universal real_universal && cp -R x86 universal",
"test-deep-links": "ws --spa ./deep-links-test-page.html"
"test-deep-links": "ws --spa ./deep-links-test-page.html",
"wdio": "wdio run test/wdio.conf.ts"
},
"jest": {
"preset": "react-native",
Expand Down Expand Up @@ -196,6 +203,12 @@
"@types/react": "^17.0.30",
"@types/react-native": "^0.65.8",
"@types/react-test-renderer": "^17.0.1",
"@wdio/appium-service": "^7.16.14",
"@wdio/cli": "^7.16.14",
"@wdio/local-runner": "^7.16.14",
"@wdio/mocha-framework": "^7.16.14",
"@wdio/spec-reporter": "^7.16.14",
"appium": "^1.22.2",
"babel-jest": "^26.6.3",
"detox": "^19.4.3",
"eslint": "7.32.0",
Expand Down Expand Up @@ -223,6 +236,7 @@
"react-native-debugger-open": "^0.3.25",
"rn-nodeify": "10.3.0",
"typescript": "^4.4.4",
"wdio-wait-for": "^2.2.1",
"ws": "^7.5.2",
"yarn-deduplicate": "^3.1.0"
},
Expand Down
5 changes: 5 additions & 0 deletions src/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ export function BaseButton({
{...containerSpecificProps}
{...otherProps}
testID={testID}
accessibilityLabel={
otherProps.buttonAccessibilityId
? otherProps.buttonAccessibilityId
: testID
}
>
{needsBorder ? <View style={borderStyle} /> : null}

Expand Down
9 changes: 8 additions & 1 deletion src/components/CheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Props = {
disabled?: boolean,
iconCheckSize?: number,
style?: *,
checkBoxAccessibilityLabel?: string,
};

const checkBoxHitSlop = {
Expand All @@ -27,6 +28,7 @@ function CheckBox({
onChange,
iconCheckSize = 16,
style,
checkBoxAccessibilityLabel,
}: Props) {
const { colors } = useTheme();
const onPress = useCallback(() => {
Expand Down Expand Up @@ -60,13 +62,18 @@ function CheckBox({
{...commonProps}
onPress={onPress}
hitSlop={checkBoxHitSlop}
accessibilityLabel={checkBoxAccessibilityLabel}
>
{isChecked ? body : null}
</TouchableOpacity>
);
}

return <View {...commonProps}>{body}</View>;
return (
<View {...commonProps} accessibilityLabel={checkBoxAccessibilityLabel}>
{body}
</View>
);
}

const styles = StyleSheet.create({
Expand Down
3 changes: 3 additions & 0 deletions src/components/Touchable.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Props = {
eventProperties?: { [key: string]: any },
style?: *,
testID?: string,
touchableAccessibilityId?: string,
};

export default class Touchable extends Component<
Expand Down Expand Up @@ -68,6 +69,7 @@ export default class Touchable extends Component<
event,
eventProperties,
testID,
touchableAccessibilityId,
...rest
} = this.props;
const { pending } = this.state;
Expand All @@ -80,6 +82,7 @@ export default class Touchable extends Component<
disabled={disabled}
hitSlop={defaultHitSlop}
testID={testID ?? event}
accessibilityLabel={touchableAccessibilityId}
{...rest}
>
{children}
Expand Down
15 changes: 8 additions & 7 deletions src/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ if (__DEV__ && process.env.NODE_ENV !== "test") {
// it logs weird things without the timeout...
try {
// just for tests
require("react-native").LogBox.ignoreLogs([
"Warning: isMounted(...) is deprecated in plain JavaScript React classes. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.",
"Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.",
"Warning: componentWillReceiveProps has been renamed",
"Warning: componentWillUpdate has been renamed",
"Warning: componentWillMount has been renamed",
]);
// require("react-native").LogBox.ignoreLogs([
// "Warning: isMounted(...) is deprecated in plain JavaScript React classes. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.",
// "Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.",
// "Warning: componentWillReceiveProps has been renamed",
// "Warning: componentWillUpdate has been renamed",
// "Warning: componentWillMount has been renamed",
// ]);
require("react-native").LogBox.ignoreAllLogs();
} catch (e) {
console.warn(e);
}
Expand Down
1 change: 1 addition & 0 deletions src/screens/Onboarding/steps/deviceSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function OnboardingStepDeviceSelection({ navigation }: *) {
event="Onboarding Device - Selection"
eventProperties={{ deviceId }}
testID={`Onboarding Device - Selection|${deviceId}`}
touchableAccessibilityId={`Onboarding Device - Selection|${deviceId}`}
style={[styles.deviceButton, { backgroundColor: colors.lightLive }]}
onPress={() => next(deviceId)}
>
Expand Down
7 changes: 6 additions & 1 deletion src/screens/Onboarding/steps/terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ function OnboardingStepTerms({ navigation }: *) {
onPress={onSwitch}
style={styles.switchRow}
>
<CheckBox style={styles.checkbox} isChecked={toggle} />
<CheckBox
style={styles.checkbox}
isChecked={toggle}
checkBoxAccessibilityLabel="terms-checkbox"
/>
<LText semiBold style={styles.switchLabel}>
<Trans i18nKey="Terms.switchLabelFull" />
</LText>
Expand All @@ -89,6 +93,7 @@ function OnboardingStepTerms({ navigation }: *) {
onPress={next}
title={<Trans i18nKey="Terms.cta" />}
IconRight={ArrowRight}
buttonAccessibilityId="enter-app-button"
/>
</View>
}
Expand Down
2 changes: 2 additions & 0 deletions src/screens/Onboarding/steps/useCaseSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function OnboardingStepUseCaseSelection({ navigation, route }: Props) {
<TrackScreen category="Onboarding" name="UseCase" />
<FlatList
data={useCases}
accessibilityLabel="use-case-container"
renderItem={({ item, index }) => (
<Fragment key={item.key + index}>
{index < 2 && (
Expand All @@ -95,6 +96,7 @@ function OnboardingStepUseCaseSelection({ navigation, route }: Props) {
testID={`${item.event}|${deviceModelId}`}
onPress={() => next(item)}
style={[styles.button, { backgroundColor: colors.lightLive }]}
touchableAccessibilityId={`${item.event}|${deviceModelId}`}
>
<LText semiBold style={[styles.label]} color="live">
<Trans i18nKey={`onboarding.stepUseCase.${item.key}.label`} />
Expand Down
2 changes: 2 additions & 0 deletions src/screens/Onboarding/steps/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function OnboardingStepWelcome({ navigation }: *) {
<TouchableOpacity
style={[styles.languageButton, { borderColor: colors.fog }]}
onPress={onLanguageSelect}
accessibilityId="onboarding-langauge-selection-button"
>
<LText semiBold style={styles.languageLabel}>
{i18n.language}
Expand Down Expand Up @@ -194,6 +195,7 @@ function OnboardingStepWelcome({ navigation }: *) {
event="Onboarding - Start"
onPress={next}
title={t("onboarding.stepWelcome.start")}
buttonAccessibilityId="get-started-button"
/>
<View style={commonStyles.footer}>
<LText style={styles.subTitle} color="grey">
Expand Down
40 changes: 40 additions & 0 deletions tests/config/wdio.android-debug.app.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { join } = require("path");
const { config } = require("./wdio.shared.conf");

// ============
// Specs
// ============
config.specs = ["./tests/specs/**/*.spec.js"];

// ============
// Capabilities
// ============
// For all capabilities please check
// http://appium.io/docs/en/writing-running-appium/caps/#general-capabilities
config.capabilities = [
{
// The defaults you need to have in your config
platformName: "Android",
maxInstances: 1,
// For W3C the appium capabilities need to have an extension prefix
// http://appium.io/docs/en/writing-running-appium/caps/
// This is `appium:` for all Appium Capabilities which can be found here
"appium:deviceName": "Nexus 5 API 30",
"appium:platformVersion": "11",
"appium:orientation": "PORTRAIT",
// `automationName` will be mandatory, see
// https://github.com/appium/appium/releases/tag/v1.13.0
"appium:automationName": "UiAutomator2",
// The path to the app
"appium:app": join(
process.cwd(),
"android/app/build/outputs/apk/debug/app-x86-debug.apk",
),
// Read the reset strategies very well, they differ per platform, see
// http://appium.io/docs/en/writing-running-appium/other/reset-strategies/
"appium:noReset": true,
"appium:newCommandTimeout": 240,
},
];

exports.config = config;
40 changes: 40 additions & 0 deletions tests/config/wdio.android.app.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { join } = require("path");
const { config } = require("./wdio.shared.conf");

// ============
// Specs
// ============
config.specs = ["./tests/specs/**/*.spec.js"];

// ============
// Capabilities
// ============
// For all capabilities please check
// http://appium.io/docs/en/writing-running-appium/caps/#general-capabilities
config.capabilities = [
{
// The defaults you need to have in your config
platformName: "Android",
maxInstances: 1,
// For W3C the appium capabilities need to have an extension prefix
// http://appium.io/docs/en/writing-running-appium/caps/
// This is `appium:` for all Appium Capabilities which can be found here
"appium:deviceName": "Pixel XL API 30",
"appium:platformVersion": "11",
"appium:orientation": "PORTRAIT",
// `automationName` will be mandatory, see
// https://github.com/appium/appium/releases/tag/v1.13.0
"appium:automationName": "UiAutomator2",
// The path to the app
"appium:app": join(
process.cwd(),
"android/app/build/outputs/apk/stagingRelease/app-x86-stagingRelease.apk",
),
// Read the reset strategies very well, they differ per platform, see
// http://appium.io/docs/en/writing-running-appium/other/reset-strategies/
"appium:noReset": true,
"appium:newCommandTimeout": 240,
},
];

exports.config = config;
40 changes: 40 additions & 0 deletions tests/config/wdio.ios.app.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { join } = require("path");
const { config } = require("./wdio.shared.conf");

// ============
// Specs
// ============
config.specs = ["./tests/specs/**/*.spec.js"];

// ============
// Capabilities
// ============
// For all capabilities please check
// http://appium.io/docs/en/writing-running-appium/caps/#general-capabilities
config.capabilities = [
{
// The defaults you need to have in your config
platformName: "iOS",
maxInstances: 1,
// For W3C the appium capabilities need to have an extension prefix
// This is `appium:` for all Appium Capabilities which can be found here
// http://appium.io/docs/en/writing-running-appium/caps/
"appium:deviceName": "iPhone 11 Pro",
"appium:platformVersion": "15.0",
"appium:orientation": "PORTRAIT",
// `automationName` will be mandatory, see
// https://github.com/appium/appium/releases/tag/v1.13.0
"appium:automationName": "XCUITest",
// The path to the app
"appium:app": join(
process.cwd(),
"ios/build/ledgerlivemobile/Build/Products/Staging-iphonesimulator/ledgerlivemobile.app",
),
// Read the reset strategies very well, they differ per platform, see
// http://appium.io/docs/en/writing-running-appium/other/reset-strategies/
"appium:noReset": false,
"appium:newCommandTimeout": 240,
},
];

exports.config = config;
42 changes: 42 additions & 0 deletions tests/config/wdio.shared.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
exports.config = {
// ====================
// Runner and framework
// Configuration
// ====================
runner: "local",
framework: "mocha",
mochaOpts: {
timeout: 100000000,
},
sync: true,
logLevel: "info",
deprecationWarnings: true,
bail: 0,
waitforTimeout: 10000000,
connectionRetryTimeout: 90000000,
connectionRetryCount: 3,
reporters: ["spec"],

// ====================
// Appium Configuration
// ====================
services: ["appium"],
appium: {
// For options see
// https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-appium-service
args: {
// For arguments see
// https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-appium-service
},
command: "./node_modules/.bin/appium",
},

port: 4723,

// ====================
// Some hooks
// ====================
// beforeSession: (config, capabilities, specs) => {
// require("@babel/register");
// },
};
Loading