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

Cannot enable notification permissions #1368

Closed
nirre7 opened this issue May 7, 2019 · 4 comments
Closed

Cannot enable notification permissions #1368

nirre7 opened this issue May 7, 2019 · 4 comments

Comments

@nirre7
Copy link

nirre7 commented May 7, 2019

Describe the bug
Cannot enable notifications.

To Reproduce

  • [x ] I have tested this issue on the latest Detox release and it still reproduces

Provide the steps necessary to reproduce the issue. If you are seeing a regression, try to provide the last known version where the issue did not reproduce.

  1. Start an app app witch pops the notifications permission dialog

If possible, please provide a small demo project that reproduces the issue, or attach a video with the reproduction - this would be very appreciated.

Expected behavior
A clear and concise description of what you expected to happen.

Similar to
Cannot enable notifications, i.e:

await device.launchApp({
      permissions: {
        notifications: 'YES',
      }, newInstance: true
    });

In init.js and firstTest.spec.js, with and withoout "newInstance: true"
Added console log when when params.permissions is suppose to be handled but it is never called with "permissions" ..

IF I click the notification permission popup then the test passes.
Seems that applesimutils is not called.
Trying on a newly initialised detox project:

Init.js:

const detox = require('detox');
const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');

jest.setTimeout(120000);
jasmine.getEnv().addReporter(adapter);

beforeAll(async () => {
  await detox.init(config);

  await device.launchApp({
    permissions: {
      notifications: 'YES',
    },
  });
});

beforeEach(async () => {
  await adapter.beforeEach();
});

afterAll(async () => {
  await adapter.afterAll();
  await detox.cleanup();
});

firstTest.spec.js

describe('Example', () => {

  beforeEach(async () => {

    console.log("before device.launchApp")

    await device.launchApp({
      permissions: {
        notifications: 'YES',
      }, newInstance: true
    });

    console.log("after device.launchApp")

    await device.reloadReactNative();
  });

  it('should be able to tap login btn', async () => {
    await element(by.label('Login')).tap();
  });
});

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Detox: 12.6.2
  • React Native: 0.59.5
  • Node:10.15.1
  • Device: ios simulator ipone x, 12.2
  • Xcode: 10.2.1
  • iOS:12.2
  • macOS: 10.14.4

Device and Verbose Detox Logs
Provide the device and "trace" Detox logs so we can understand what happened. You can obtain them by passing the loglevel param: detox test --loglevel trace

detox[32323] INFO:  [test.js] configuration="ios.sim.debug" loglevel="verbose" artifactsLocation="artifacts/ios.sim.debug.2019-05-07 06-46-42Z" recordLogs="none" takeScreenshots="manual" recordVideos="none" recordPerformance="none" node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$' "e2e"
console.log e2e/init.js:11
BEFORE init !!!

detox[32323] INFO:  [test.js] configuration="ios.sim.debug" loglevel="verbose" artifactsLocation="artifacts/ios.sim.debug.2019-05-07 06-46-42Z" recordLogs="none" takeScreenshots="manual" recordVideos="none" recordPerformance="none" node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)*$' "e2e"
console.log e2e/init.js:11
BEFORE init !!!

detox[32324] INFO:  [DetoxServer.js] server listening on localhost:52080...
detox[32324] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:52080
detox[32324] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=cf48b1b3-35c6-4452-f5cf-9429fea7c984
detox[32324] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=cf48b1b3-35c6-4452-f5cf-9429fea7c984
detox[32324] DEBUG: [exec.js/EXEC_CMD, #0] /usr/bin/xcrun simctl list -j
detox[32324] DEBUG: [exec.js/EXEC_CMD, #1] applesimutils --list --byType "iPhone X" --byOS "12.2"
detox[32324] DEBUG: [exec.js/EXEC_TRY, #1] Searching for device matching iPhone X...
detox[32324] DEBUG: [exec.js/EXEC_CMD, #2] applesimutils --list --byId "88RTF92F-DED0-40DA-BBDE-BA742220F0A8"
detox[32324] DEBUG: [exec.js/EXEC_CMD, #3] /usr/bin/xcrun simctl uninstall 88RTF92F-DED0-40DA-BBDE-BA742220F0A8 com.something
detox[32324] DEBUG: [exec.js/EXEC_TRY, #3] Uninstalling com.something...
detox[32324] DEBUG: [exec.js/EXEC_SUCCESS, #3] com.something uninstalled
detox[32324] DEBUG: [exec.js/EXEC_CMD, #4] /usr/bin/xcrun simctl install 88RTF92F-DED0-40DA-BBDE-BA742220F0A8 "/Users/niso/dev/git/stuff-device/ios/build/Build/Products/Debug-iphonesimulator/someApp.app"
detox[32324] DEBUG: [exec.js/EXEC_TRY, #4] Installing /Users/niso/dev/git/stuff-device/ios/build/Build/Products/Debug-iphonesimulator/someApp.app...
detox[32324] DEBUG: [exec.js/EXEC_SUCCESS, #4] /Users/niso/dev/git/stuff-device/ios/build/Build/Products/Debug-iphonesimulator/someApp.app installed
detox[32324] DEBUG: [exec.js/EXEC_CMD, #5] /usr/bin/xcrun simctl terminate 88RTF92F-DED0-40DA-BBDE-BA742220F0A8 com.something
detox[32324] DEBUG: [exec.js/EXEC_TRY, #5] Terminating com.something...
detox[32324] DEBUG: [exec.js/EXEC_SUCCESS, #5] com.something terminated
console.log node_modules/detox/src/devices/Device.js:69
{ newInstance: true }

detox[32324] DEBUG: [exec.js/EXEC_CMD, #6] /bin/cat /dev/null >/Users/niso/Library/Developer/CoreSimulator/Devices/88RTF92F-DED0-40DA-BBDE-BA742220F0A8/data/tmp/detox.last_launch_app_log.out 2>/Users/niso/Library/Developer/CoreSimulator/Devices/88RTF92F-DED0-40DA-BBDE-BA742220F0A8/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/niso/Library/Detox/ios/f242ac36fc1dc256c1d32c27d334d056f2b83bc2/Detox.framework/Detox" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err 88RTF92F-DED0-40DA-BBDE-BA742220F0A8 com.something --args -detoxServer "ws://localhost:52080" -detoxSessionId "cf48b1b3-35c6-4452-f5cf-9429fea7c984"
detox[32324] DEBUG: [exec.js/EXEC_TRY, #6] Launching com.something...
detox[32324] INFO:  [AppleSimUtils.js] com.something launched. The stdout and stderr logs were recreated, you can watch them with:
tail -F /Users/niso/Library/Developer/CoreSimulator/Devices/88RTF92F-DED0-40DA-BBDE-BA742220F0A8/data/tmp/detox.last_launch_app_log.{out,err}
detox[32324] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=cf48b1b3-35c6-4452-f5cf-9429fea7c984)
detox[32324] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=cf48b1b3-35c6-4452-f5cf-9429fea7c984
detox[32324] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=cf48b1b3-35c6-4452-f5cf-9429fea7c984

 FAIL  e2e/firstTest.spec.js (51.248s)

iOS Framework Build Logs
If you are seeing a build problem (e.g. during npm install), provide the log found here: ~/Library/Detox/ios/{...}/detox_ios.log

@nirre7
Copy link
Author

nirre7 commented May 7, 2019

Similar too #653

Thanks in advance and please let me know if you need more information.

@LeoNatan
Copy link
Contributor

LeoNatan commented May 7, 2019

It seems like setPermission is not called. @noomorph can you pls take a look?

@nirre7
Copy link
Author

nirre7 commented May 20, 2019

I took another stab at it and it works.

Seems like this config does not work

await detox.init(config);

  await device.launchApp({
    permissions: {
      notifications: 'YES',
    },
  });

This does work, if I don't launch the app while doing the init.

  await detox.init(config, { launchApp: false });

  await device.launchApp({
    permissions: {
      notifications: 'YES',
    },
  });

Maybe its just a noob error (I'm new to the lib so maybe this is common knowledge) or maybe you/me should update/add the docs? I can create a "document pr" if you think it is needed.

Anyway it works great now. Cheers

@LeoNatan
Copy link
Contributor

Ah I see, hehe
Yes, if you launch the app before setting permissions, it will not work. You can also make a change of newInstace: true which should also work.

@lock lock bot locked as resolved and limited conversation to collaborators May 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants