Improvement Summary
We should refactor the way that tests select GameCard elements in the DOM to use helper functions and the ids of cards, rather then rank-suit strings
Detailed Description
Currently all the cypress tests identify cards in the DOM via a selector pattern of data-{location}-card={rank-suit} e.g. data-player-hand-card=0-13 for the king of clubs in the player's hand. We can simplify this in two ways:
- Update these selectors in the DOM to use the cards' ids rather than rank-suit strings e.g. `data-player-hand-card=KC for the king of clubs in the player's hand
- Define an enum with all the values for where cards can be e.g.
CardLocation.PLAYER_HAND, CardLocation.OPPONENT_POINTS with string values for all the different selector locations
- Create a function
getCard(card, location) which inputs a card object and location (string enum) that calls cy.get() to get the chosen card in the chosen location
- e.g. this would call
cy.get(data-${location}-card="${card.id}" to get the selected card and allow chaining
- Update all the existing test code selecting cards to call the above helper.
- Update the docs to describe this new pattern
This will offer a more transparent selector pattern for test code that supports better autocompletion
Improvement Summary
We should refactor the way that tests select GameCard elements in the DOM to use helper functions and the ids of cards, rather then rank-suit strings
Detailed Description
Currently all the cypress tests identify cards in the DOM via a selector pattern of
data-{location}-card={rank-suit}e.g.data-player-hand-card=0-13for the king of clubs in the player's hand. We can simplify this in two ways:CardLocation.PLAYER_HAND,CardLocation.OPPONENT_POINTSwith string values for all the different selector locationsgetCard(card, location)which inputs a card object and location (string enum) that callscy.get()to get the chosen card in the chosen locationcy.get(data-${location}-card="${card.id}"to get the selected card and allow chainingThis will offer a more transparent selector pattern for test code that supports better autocompletion