fix: improve accessibility of UI elements #1034
                
     Merged
            
            
          
  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.
  
    
  
    
When testing the Epic Stack app as a part of my recent workshop, I've noticed that certain UI elements have poor accessibility, which resulted in them being rather difficult to properly target during the tests.
The user menu dropdown is one such example. Right now, it has an accessible name comprised of the username repeated twice:
This happens because the dropdown has two elements, each of which has user's username as the accessible text:
imgasalt={user.name}user.name.That results into the element's accessible name being "Kody Kody", which looks broken, especially if you want to target this user dropdown in tests.
Instead, the element's accessible text should describe what that element is or does. In this case, I propose it should be something like "User menu".
There's a similar problem for the search results:
"Kody Kody Kody" isn't a very nice accessible name that describes what that link is/does. I propose
{user.name || user.username} profileinstead because that's what happens when you click on that link—it brings you to that user's profile page.Test Plan
Checklist
Screenshots
Why wasn't this caught in tests?
Because the current tests target this element by inclusive name, not exact name:
Saying
{ name: 'Kody' }will matchKody Kodywithout ever surfacing that the element's accessible name is problematic. This is a +1 for usingexact: trueas the default.