-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(config): default app permissions (iOS) #3493
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const _ = require('lodash'); | ||
|
||
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError'); | ||
const debug = require('../../utils/debug'); // debug utils, leave here even if unused | ||
const { traceCall } = require('../../utils/trace'); | ||
|
@@ -56,6 +58,7 @@ class RuntimeDevice { | |
this._emitter = eventEmitter; | ||
this._errorComposer = runtimeErrorComposer; | ||
|
||
/** @type {Detox.DetoxAppConfig | null} */ | ||
this._currentApp = null; | ||
this._currentAppLaunchArgs = new LaunchArgsEditor(); | ||
this._processes = {}; | ||
|
@@ -189,9 +192,13 @@ class RuntimeDevice { | |
} | ||
|
||
async installApp(binaryPath, testBinaryPath) { | ||
await traceCall('appInstall', () => { | ||
await traceCall('appInstall', async () => { | ||
/** @type {*} */ | ||
const currentApp = binaryPath ? { binaryPath, testBinaryPath } : this._getCurrentApp(); | ||
return this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath); | ||
await this.deviceDriver.installApp(currentApp.binaryPath, currentApp.testBinaryPath); | ||
if (!_.isEmpty(currentApp.permissions)) { | ||
await this.deviceDriver.setPermissions(currentApp.bundleId, currentApp.permissions); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well I didn't go deeply into this but something about this approach feels a bit off. It assumes that the permissions can be set in such a global way - before an instance of the app is launched. While it works on iOS, I can't 100% say the same about Android / a theoretical future platform. What about applying a similar solution to the launch-args technique, which is set in advance and handled on-site (i.e. in launch app)? |
||
}); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,8 @@ await device.launchApp({permissions: {calendar: 'YES'}}); | |
|
||
Detox uses [AppleSimUtils](https://github.com/wix/AppleSimulatorUtils) to implement this functionality for iOS simulators. Read about the different types of permissions and how to set them in AppleSimUtils' documentation and by checking out Detox’s [own test suite](https://github.com/wix/Detox/tree/a9a09246c05733f6b91cfcc0dba05a4714abca92/detox/test/e2e/13.permissions.test.js). | ||
|
||
As a reference, you can also use this [table of possible permissions](#permissions-ios-only). | ||
|
||
##### 3. `url`—Launching with URL | ||
|
||
Launches the app with the specified URL to test your app’s deep link handling mechanism. | ||
|
@@ -528,3 +530,32 @@ Exposes [`UiAutomator`’s `UiDevice` API](https://developer.android.com/referen | |
**This is not a part of the official Detox API**, it may break and change whenever an update to `UiDevice` or `UiAutomator` Gradle dependencies (`androidx.test.uiautomator:uiautomator`) is introduced. | ||
|
||
[`UiDevice`’s autogenerated code](https://github.com/wix/Detox/tree/a9a09246c05733f6b91cfcc0dba05a4714abca92/detox/src/android/espressoapi/UIDevice.js) | ||
|
||
### Permissions (iOS only) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add link in ToC |
||
|
||
When you are [configuring the apps](APIRef.Configuration.md#apps-configurations) list in your | ||
Detox config file or [launching the app](#2-permissionsset-runtime-permissions-ios-only), | ||
you can give certain permissions beforehand to it to avoid this inconvenient modal: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A simple and elegant explanation |
||
|
||
 | ||
|
||
So, here is the exhaustive permissions list that Detox currently supports for iOS: | ||
|
||
| Permission | Values | | ||
|---------------|---------------------------------------------------------| | ||
| calendar | `'YES' | 'NO' | 'unset'` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| camera | `'YES' | 'NO' | 'unset'` | | ||
| contacts | `'YES' | 'NO' | 'unset'` | | ||
| faceid | `'YES' | 'NO' | 'unset'` | | ||
| health | `'YES' | 'NO' | 'unset'` | | ||
| homekit | `'YES' | 'NO' | 'unset'` | | ||
| location | `'always' | 'inuse' | 'never' | 'unset'` | | ||
| medialibrary | `'YES' | 'NO' | 'unset'` | | ||
| microphone | `'YES' | 'NO' | 'unset'` | | ||
| motion | `'YES' | 'NO' | 'unset'` | | ||
| notification | `'YES' | 'NO' | 'unset'` | | ||
| photos | `'YES' | 'NO' | 'unset'` | | ||
| reminders | `'YES' | 'NO' | 'unset'` | | ||
| siri | `'YES' | 'NO' | 'unset'` | | ||
| speech | `'YES' | 'NO' | 'unset'` | | ||
| userTracking | `'YES' | 'NO' | 'unset'` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant?