Detox: Support TouchID functionality

Created on 28 Sep 2018  路  7Comments  路  Source: wix/Detox

Description

I want to know if there is a way to test TouchID, currently i'm using Detox as e2e framwork, and i have touchID logic in my app. It would be nice simulate success and failure and interactions with system alerts binding to the process.

accepteenhancement looking for contributors

Most helpful comment

All 7 comments

Hello,

Starting with version 0.6.0, AppleSimulatorUtils fully supports the simulator biometric system. You can enable or disable enrollment, as well as approve or fail authentication attempts using face or finger.

Now the matter of implementing it in Detox. While not a hard task at all, it will take time, and we are currently busy with other tasks. If you would like to contribute a PR implementing this functionality, we will be very happy to assist.

In the mean time, as a workaround, you can call applesimutils directly with the appropriate commands. Search the issues (open and closed) for examples of how to do that. You will need to obtain the current simulator ID from Detox, which is also possible.

Thank @LeoNatan appreciate it. I don't have much time free in the future, but maybe i can work on an PR for this. Thanks for the help

Thank you

Claiming this - will start work on it now.

@abunsen Fantastic, thank you!
I've reopened the issue, and we can discuss here if you need help.

So I believe all that needs to be done is a few functions need to be added to detox/src/devices/ios/AppleSimUtils.js, this is what I was thinking:

async matchBiometric(udid, matchType) {
    if (!['face', 'finger'].include(matchType)) {
      return;
    }
    const statusLogs = {
      trying: `Trying to match ${matchType}...`,
      successful: `Matched ${matchType}!`
    };

    await this._execAppleSimUtils({ args: `--byId ${udid} --${matchType}}` }, statusLogs, 1);
  }

  async unmatchBiometric(udid, matchType) {
    if (!['Face', 'Finger'].include(matchType)) {
      return;
    }
    const statusLogs = {
      trying: `Trying to match ${matchType}...`,
      successful: `Matched ${matchType}!`
    };

    await this._execAppleSimUtils({ args: `--byId ${udid} --unmatch${matchType}}` }, statusLogs, 1);
  }

  async setBiometricEnrollment(udid, toggle) {
    let yesOrNo = toggle ? 'YES' : 'NO'
    const statusLogs = {
      trying: `Turning ${toggle ? 'on' : 'off'} biometric enrollment`,
      successful: toggle ? 'Activated!' : 'Deactivated!'
    };
    await this._execAppleSimUtils({ args: `--byId ${udid} --biometricEnrollment ${yesOrNo}` }, statusLogs, 1);
  }

Then tests need to be added in detox/src/devices/Device.test.js. Does that sound about right @LeoNatan?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pranaybiswas2611 picture pranaybiswas2611  路  3Comments

kceb picture kceb  路  4Comments

carlosalmonte04 picture carlosalmonte04  路  4Comments

mhyousefi picture mhyousefi  路  3Comments

gtRfnkN picture gtRfnkN  路  4Comments