- 
                Notifications
    
You must be signed in to change notification settings  - Fork 276
 
feat: option for queries to respect accessibility #1064
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 31 commits
      Commits
    
    
            Show all changes
          
          
            32 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      fc1f724
              
                chore: fix typo
              
              
                 de92da5
              
                feat: add options to isInaccessible
              
              
                 13b0d73
              
                feat: implement new findAll helper including hidden option
              
              
                 be19318
              
                feat: use new findAll with hiden option in all queries
              
              
                 f0c9e56
              
                test: add tests for the queries to check hidden option support
              
              
                 42f04e6
              
                chore: fix typo
              
              
                 b188843
              
                feat: use global config for default hidden
              
              
                 56e3b20
              
                refactor: simplify cache handling for accessibiilty
              
              
                 102664a
              
                refactor: correct cache default
              
              
                 726dd72
              
                refactor: rename options file
              
              
                 a88ac5d
              
                refactor: rename AccessibiilityOption to BaseOptions
              
              
                 8d71039
              
                refactor: move TextMatchOptiond'
              
              
                 8abf657
              
                fixup! feat: implement new findAll helper including hidden option
              
              
                 fb830bd
              
                refactor: simplify naming in findAll
              
              
                 97225d0
              
                refactor: simplify options syntax for findAll'
              
              
                 0971813
              
                refactor: renaming in findAll args
              
              
                 e9bebb6
              
                refactor: clean type ByRoleOptions
              
              
                 f0d6244
              
                refactor: rename type BaseOptions to CommonQueryoptions
              
              
                 18bca34
              
                chore: remove deprecated common
              
              
                 58816b0
              
                refactor: separate query and findAll types
              
              
                 32651fa
              
                fix: add options to flow types for queryByTestId
              
              
                 61a11f8
              
                feat: update flow types
              
              
                 b7824d9
              
                test: fix config test
              
              
                 c97446e
              
                doc: add doc on hidden option
              
              
                 63f3e86
              
                doc: correct docs for hidden option
              
              
                 ee4addd
              
                doc: add doc for configure api
              
              
                 eec0c1b
              
                doc: few tweaks to hidden option
              
              
                 8557eaa
              
                refactor: rename hidden global option to defaultHidden
              
              
                 7e869de
              
                refactor: formatting
              
              
                mdjastrzebski b9d6404
              
                refactor: final tweaks
              
              
                mdjastrzebski 66b4fcb
              
                chore: run prettier
              
              
                mdjastrzebski dbccaf5
              
                docs: add hidden option to queries doc
              
              
                mdjastrzebski File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { ReactTestInstance } from 'react-test-renderer'; | ||
| import { getConfig } from '../config'; | ||
| import { isInaccessible } from './accessiblity'; | ||
| 
     | 
||
| interface FindAllOptions { | ||
| hidden?: boolean; | ||
| } | ||
| 
     | 
||
| export function findAll( | ||
| root: ReactTestInstance, | ||
| predicate: (node: ReactTestInstance) => boolean, | ||
| options?: FindAllOptions | ||
| ) { | ||
| const results = root.findAll(predicate); | ||
| 
     | 
||
| const hidden = options?.hidden ?? getConfig().defaultHidden; | ||
| if (hidden) { | ||
| return results; | ||
| } | ||
| 
     | 
||
| const cache = new WeakMap<ReactTestInstance>(); | ||
| return results.filter((element) => !isInaccessible(element, { cache })); | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.