Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detox issue #618

Merged
merged 14 commits into from
Jan 31, 2024
8 changes: 6 additions & 2 deletions .detoxrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"testRunner": "jest",
"runnerConfig": "e2e/config.json",
"testRunner": {
"$0": "jest",
"args": {
"config": "e2e/jest.config.js"
}
},
"apps": {
"ios.example.debug": {
"type": "ios.app",
Expand Down
2 changes: 0 additions & 2 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: react-native
Expand Down Expand Up @@ -36,7 +35,6 @@ workflows:
steps:
- save-npm-cache@1: {}
- save-cocoapods-cache@1: {}
- deploy-to-bitrise-io@2: {}
deploy-firebase-android:
steps:
- fastlane@3:
Expand Down
6 changes: 3 additions & 3 deletions dev-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@react-native-picker/picker": "^2.5.1",
"@react-navigation/native": "^5.x",
"@react-navigation/stack": "^5.x",
"@types/jest": "^27.0.2",
"jest": "^27.3.1",
"@types/jest": "^29.5.11",
"jest": "^29.7.0",
"postinstall-postinstall": "^2.1.0",
"react": "18.2.0",
"react-native": "0.72.7",
Expand All @@ -39,7 +39,7 @@
"babel-plugin-inline-dotenv": "^1.7.0",
"babel-plugin-module-resolver": "^4.0.0",
"concurrently": "^7.0.0",
"detox": "^19.4.3",
"detox": "^20.17.0",
"metro-config": "^0.80.1",
"metro-react-native-babel-preset": "^0.67.0",
"metro-runtime": "^0.80.1",
Expand Down
4 changes: 3 additions & 1 deletion dev-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ export default function App() {
}
}
if (Platform.OS === 'android') {
handlePermissions();
setTimeout(() => {
handlePermissions();
}, 1000); // delay of 1 second
Comment on lines +178 to +180
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not new for this PR so no need to block on it but why do we need this in the app layer? Won't the native SDK request and prompt for the permissions when needed? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The native Android SDK doesn't prompt for permissions itself, it requires the integration to do so.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, TIL! thanks 👍

} else {
handlePermissionsSuccess();
}
Expand Down
1 change: 1 addition & 0 deletions dev-app/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default function HomeScreen() {
</Text>
{account && (
<View
testID="online-indicator"
style={[
styles.indicator,
{ backgroundColor: online ? colors.green : colors.red },
Expand Down
8 changes: 0 additions & 8 deletions e2e/config.json

This file was deleted.

20 changes: 0 additions & 20 deletions e2e/environment.js

This file was deleted.

11 changes: 11 additions & 0 deletions e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
maxWorkers: 1,
testTimeout: 200000,
rootDir: '.',
testMatch: ['<rootDir>/*.e2e.js'],
reporters: ['detox/runners/jest/reporter'],
globalSetup: 'detox/runners/jest/globalSetup',
globalTeardown: 'detox/runners/jest/globalTeardown',
testEnvironment: 'detox/runners/jest/testEnvironment',
verbose: true,
};
8 changes: 6 additions & 2 deletions e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ export const setSelectedCurrency = async (currency = 'USD') => {

export const setSimulatedUpdatePlan = async (plan = 'Update required') => {
const picker = element(by.id('update-plan-picker'));

const touchable = element(by.id('close-picker'));
await picker.tap();

if (device.getPlatform() === 'ios') {
await element(by.type('UIPickerView')).setColumnToValue(0, plan);
await picker.tap();
await touchable.tap();
} else {
await element(by.text(plan)).tap();
}
Expand Down Expand Up @@ -97,6 +97,10 @@ const discBtnMap = {
};

export const changeDiscoveryMethod = async (method) => {
await waitFor(element(by.id('online-indicator')))
.toBeVisible()
.withTimeout(10000);

const btnId = discBtnMap[method];
const button = element(by.id('discovery-method-button'));
await waitFor(button).toBeVisible().withTimeout(10000);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@commitlint/config-conventional": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@expo/config-plugins": "^4.0.18",
"@react-native-community/bob": "^0.16.2",
"@react-native-community/eslint-config": "^2.0.0",
"@types/base-64": "^1.0.0",
"@types/jest": "^27.0.2",
"@types/jest": "^29.5.11",
"@types/react": "^16.9.19",
"@types/react-native": "0.63.18",
"commitlint": "^11.0.0",
"detox": "^19.4.3",
"detox": "^20.17.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-detox": "^1.0.0",
Expand Down
Loading