Skip to content
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

Add comprehensive tests for DataView #2383

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

jordankoschei-okta
Copy link
Contributor

This PR adds test coverage for DataView, attempting to be comprehensive but not overwhelming.

For simplicity, most of the tests use an example data set of 7 characters from Star Wars (7 being an easy enough number of items to reason about).

I've tried to avoid adding data-testid wherever possible, opting for implicit attributes like aria-label instead. However, in a few circumstances, adding a test id was the most efficient route; in those cases, I used data-testid.

Due to the way DataView loads data, I've needed to make heavy use of waitFor and await to detect when the component is truly ready to be tested. In many instances, the tests were receiving a false positive that the table was ready, even though it was empty. I used a few different ways to validate that the test was ready, based on the circumstance:

  • Detect if more than 1 row has loaded (tables always have 1 row loaded, representing the thead row)
  • Detect if the text of the first data item is present, indicating that the data has been loaded in

List of tests

Display modes

  1. displays a table view
  2. displays a list view
  3. displays a grid view
  4. displays the layout switcher

Auxiliary controls

  1. can display meta text
  2. can filter rows
  3. can search rows
  4. can clear the search input
  5. can display row action menu
  6. can display row action buttons

Table-specific options

  1. can sort rows
  2. can change row density
  3. can change column visibility
  4. can resize columns

Row selection

  1. can select table rows
  2. can select card rows
  3. can select all rows
  4. can deselect rows
  5. can deselect all rows
  6. can perform bulk actions on rows

Row reordering

  1. can reorder rows
  2. can reorder to front
  3. can reorder to back

Row expansion

  1. can expand table rows
  2. can expand card rows

Additional states

  1. can display empty state
  2. can display no-results state

Pagination

  1. displays paged pagination
  2. displays loadMore pagination
  3. can load more rows via loadMore pagination
  4. can go to the next page
  5. can go to the previous page
  6. can disable the next page button based on max rows

@jordankoschei-okta jordankoschei-okta requested a review from a team as a code owner October 10, 2024 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants