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

feat: Initial aria test util docs and listbox/tabs/tree utils #7145

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

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented Oct 3, 2024

Closes

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

RSP

category: Concepts
---

# Testing
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually this testing page will have more than just documenting the aria test utils

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open to any suggestion as to the structure of this page and how in-depth the documentation should be. I figure it is easier and clearer to document each individual tester api in the RAC/RSP component page itself but happy to field opinions


See below for the full definition of the `User` object.

<ClassAPI links={testUtilDocs.links} class={testUtilDocs.exports.User} />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that PatternNames in the rendered type doesn't actually the true type, still trying to figure out how to handle this... It works just fine in the typescript
image

@rspbot
Copy link

rspbot commented Oct 4, 2024

@LFDanLu LFDanLu marked this pull request as ready for review October 4, 2024 23:00
/**
* The index of the row to toggle selection for.
*/
index?: number,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if an index isn't supplied?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's either text OR index, maybe overloads would be more suitable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll give overloads a shot

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to instead unify index/label selection into a single option along with allowing users to directly provide a node as well. Felt simpler to do

packages/@react-spectrum/combobox/docs/ComboBox.mdx Outdated Show resolved Hide resolved
packages/@react-spectrum/combobox/docs/ComboBox.mdx Outdated Show resolved Hide resolved
packages/@react-spectrum/combobox/docs/ComboBox.mdx Outdated Show resolved Hide resolved
packages/dev/docs/pages/react-aria/testing.mdx Outdated Show resolved Hide resolved
packages/dev/docs/pages/react-aria/testing.mdx Outdated Show resolved Hide resolved
packages/dev/docs/pages/react-aria/testing.mdx Outdated Show resolved Hide resolved
packages/dev/docs/pages/react-aria/testing.mdx Outdated Show resolved Hide resolved
@LFDanLu
Copy link
Member Author

LFDanLu commented Nov 14, 2024

TODO: JSDOCs

@LFDanLu LFDanLu changed the title Initial aria test util docs docs: Initial aria test util docs Dec 9, 2024
@rspbot
Copy link

rspbot commented Dec 10, 2024

@rspbot
Copy link

rspbot commented Dec 10, 2024

* adding listbox test utils and clean up of other utils

* check that util works in tests

* add docs

* test listbox util get options section scoping

* tabs test utils

* add tests for tab test utils

* add docs for tabs testing

* update jsdoc and adding version badge

* pulling in tree utils from s2-treeview branch

modified some of the utils for consistency, but otherwise kept most of it the same. Changes to be discussed

* update docs and use the utils in the spectrum tests

* making things more consistent

* fix tests temporarily

* fix keyboard navigation if row is disabled
@rspbot
Copy link

rspbot commented Dec 13, 2024

@rspbot
Copy link

rspbot commented Dec 13, 2024

## API Changes

@react-aria/test-utils

/@react-aria/test-utils:User

 User {
   advanceTimer: UserOpts['advanceTimer']
   constructor: (UserOpts) => void
-  createTester: (T, ObjectOptionsTypes<T>) => ObjectType<T>
-  interactionType: UserOpts['interactionType']
-  user: any
+  createTester: (T, TesterOpts<T>) => Tester<T>
+  interactionType: UserOpts['interactionType'] = mouse
 }

/@react-aria/test-utils:UserOpts

 UserOpts {
   advanceTimer?: (number) => void | Promise<unknown>
-  interactionType?: 'mouse' | 'touch' | 'keyboard'
+  interactionType?: 'mouse' | 'touch' | 'keyboard' = mouse
 }

@react-spectrum/test-utils

/@react-spectrum/test-utils:User

 User {
   advanceTimer: UserOpts['advanceTimer']
   constructor: (UserOpts) => void
-  createTester: (T, ObjectOptionsTypes<T>) => ObjectType<T>
-  interactionType: UserOpts['interactionType']
-  user: any
+  createTester: (T, TesterOpts<T>) => Tester<T>
+  interactionType: UserOpts['interactionType'] = mouse
 }

/@react-spectrum/test-utils:UserOpts

 UserOpts {
   advanceTimer?: (number) => void | Promise<unknown>
-  interactionType?: 'mouse' | 'touch' | 'keyboard'
+  interactionType?: 'mouse' | 'touch' | 'keyboard' = mouse
 }

@LFDanLu
Copy link
Member Author

LFDanLu commented Dec 13, 2024

If you want to look at the new utils aka tabs/listbox/tree (thanks @snowystinger!) more closely feel free to look at #7505. That PR also had a bunch of consistency updates and stuff so I just merged it in

@LFDanLu LFDanLu changed the title docs: Initial aria test util docs feat: Initial aria test util docs and listbox/tabs/tree utils Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants