aryella-lacerda / react-native-accessibility-engine

Make accessibility-related assertions on React Native code using React Test Renderer
MIT License
163 stars 13 forks source link

Understanding accessibilityRole Pressable allowed roles #314

Closed elliotmrodriguez closed 1 year ago

elliotmrodriguez commented 1 year ago

In evaluating this library I ran a couple of tests and one in particular keeps coming up as a failure and I don't understand what the AMA related guidance is for enforcing this rule.

The following allowed roles are in pressable-role-required:

const allowedRoles = ['button', 'link', 'imagebutton', 'radio', 'tab'];

In our use case, we have a TS component that contains a Pressable that accepts children, and both role and state are defined, yet this test fails and the output is confusing as it seems to complain on the one hand the role is not valid, but the other failing assertion picks up on the checkbox role:

image

Why is this specific set of roles allow-listed, while others like checkbox are not?

    <Pressable
      accessibilityRole="checkbox"
      accessibilityLabel={accessibilityLabel}
      accessibilityState={{ checked: value, disabled: disabled }}
      testID={testID}
      onPress={onPress}
      disabled={disabled}
      style={style}
    >
      {children}
    </Pressable>
elliotmrodriguez commented 1 year ago

Looks like this is somewhat related to #256 but I am still curious about the rule. I noticed some other implementation details, however, in our component that could be causing this to fail as well.