infinitered / ignite

Infinite Red's battle-tested React Native project boilerplate, along with a CLI, component/model generators, and more!
MIT License
17.37k stars 1.38k forks source link

TestIds not working correctly for Maestro #2743

Open ChristopherGabba opened 1 month ago

ChristopherGabba commented 1 month ago

Describe the bug

I am using Maestro and the Ignite boilerplate, and no matter what I name my text fields testId field, maestro never picks it up. I'm not sure if this is a bug with Maestro, or if this is a bug with the ignite TextField component. If it turns out to be Maestro, please feel free to close this issue.

        <TextField
          ref={firstNameInput}
          value={firstName}
          onChangeText={(e) => setProp("firstName", e)}
          autoCapitalize="words"
          autoComplete="name-given"
          autoCorrect={false}
          labelTx="enterNameScreen.firstNameLabel"
          helper={firstNameError}
          status={firstNameError ? "error" : undefined}
          onSubmitEditing={() => lastNameInput.current?.focus()}
          testID={'firstNameTextField'} // <---------------------------- `worthless` field :)
        />
# test.yaml
# TEST ENTERNAMESCREEN
appId: com.chris.testapp
---

- tapOn: 
     id: "firstNameTextField" # never focuses text field, have to use point: 50%,30%

Ignite version

9.8

Additional info

System platform darwin
arch arm64
cpu 10 cores Apple M2 Pro
directory TestApp /Users/christophergabba/Documents/TestApp

JavaScript (and globally-installed packages) node 22.6.0 /opt/homebrew/bin/node npm 10.8.2 /opt/homebrew/bin/npm
@aws-amplify/cli-internal 12.12.0
@aws-amplify/cli 12.12.1
@react-native-community/netinfo 9.4.1
eas-cli 10.2.2
expo-cli 6.3.10
firebase-tools 11.24.1
n 9.1.0
node-gyp 10.0.1
node 20.6.0
npm 10.7.0
pod-install 0.2.2
react-native-spinkit 1.5.1
test-app -
testappwebsite 0.0.0
typescript 5.4.5
yarn 1.22.22
yarn 1.22.22 /opt/homebrew/bin/yarn create-amplify 1.0.1
pnpm - not installed
bun - not installed
expo 51.0.26 managed

Ignite ignite-cli 9.8.2 /Users/christophergabba/.npm/_npx/e31027f3785124a8/node_modules/.bin/ignite
ignite src build /Users/christophergabba/.npm/_npx/e31027f3785124a8/node_modules/ignite-cli/build

Android java 1.8.0_371 /usr/bin/java
android home - /Users/christophergabba/Library/Android/sdk

iOS xcode 15.4
cocoapods 1.12.1 /opt/homebrew/bin/pod

Tools git git version 2.39.2 /opt/homebrew/bin/git

frankcalise commented 1 month ago

Hi @ChristopherGabba thanks for the report, sorry you're having trouble.

It very well could be something with the component, we'll look into that. We do have an example of logging into the app in a maestro test, but yeah this isn't using test ID - you don't however have to rely on point, we used placeholder here as an example: https://github.com/infinitered/ignite/blob/master/boilerplate/.maestro/Login.yaml

Will check into it, thanks!

ChristopherGabba commented 4 weeks ago

That's correct, the placeholder field seems to work fine, my app just doesn't use them. Without the testIds I have to use the screen coordinates which is super tedious haha

frankcalise commented 4 weeks ago

@ChristopherGabba can you let me know what platforms you were testing with this so I can properly reproduce?

ChristopherGabba commented 4 weeks ago

@frankcalise Sorry about that,Expo Managed Workflow on iPhone simulator build

frankcalise commented 4 weeks ago

@ChristopherGabba thanks. Confirmed it is working on Android.

After my first pass, it seems to do with the TouchableOpacity that is over the TextInput not allowing access to the testID perhaps. The testID is properly set on the RCTUITextField (I confirmed this with Xcode).

As a workaround for now, you can try setting the testID prop on TouchableOpacity around line 179 in app/components/TextField.tsx.

<TouchableOpacity
      activeOpacity={1}
      style={$containerStyles}
      onPress={focusInput}
      accessibilityState={{ disabled }}
      testID={TextInputProps.testID} // you could also just make this change for iOS specifically
    >
ChristopherGabba commented 4 weeks ago

Ah perfect! That's a super simple workaround, will do! This will speed up so much. The same issue may be on the Button and Icon component as well, I'm not 100% sure yet but remember I may have had issues with one of those as well. I'm not near my computer for the next couple of days but I'll look to see if those act the same.

Thanks @frankcalise!!