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

Combobox (v8): convert tests to use testing-library #22297

Conversation

TristanWatanabe
Copy link
Member

Current Behavior

  • v8 Combobox tests don't use testing-library

New Behavior

  • Convert Combobox to fully use testing-library

Related Issue(s)

part of #21663

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 2, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 05f29c7:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@size-auditor
Copy link

size-auditor bot commented Apr 2, 2022

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 31e8b97573aeba761d14b937378bb95d578c4c90 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Apr 2, 2022

📊 Bundle size report

🤖 This report was generated against 31e8b97573aeba761d14b937378bb95d578c4c90

@fabricteam
Copy link
Collaborator

fabricteam commented Apr 2, 2022

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 968 943 5000
Breadcrumb mount 2804 2815 1000
Checkbox mount 1531 1542 5000
CheckboxBase mount 1310 1333 5000
ChoiceGroup mount 4909 4860 5000
ComboBox mount 1007 1004 1000
CommandBar mount 10809 10867 1000
ContextualMenu mount 11600 11881 1000
DefaultButton mount 1156 1216 5000
DetailsRow mount 4107 3991 5000
DetailsRowFast mount 3976 4156 5000
DetailsRowNoStyles mount 3776 3686 5000
Dialog mount 2314 2286 1000
DocumentCardTitle mount 164 193 1000
Dropdown mount 3401 3481 5000
FocusTrapZone mount 1838 1869 5000
FocusZone mount 1908 1877 5000
IconButton mount 1803 1823 5000
Label mount 358 352 5000
Layer mount 3024 3102 5000
Link mount 485 485 5000
MenuButton mount 1561 1519 5000
MessageBar mount 2262 2195 5000
Nav mount 3417 3452 1000
OverflowSet mount 1109 1146 5000
Panel mount 2169 2202 1000
Persona mount 1013 1051 1000
Pivot mount 1543 1515 1000
PrimaryButton mount 1400 1337 5000
Rating mount 7942 7944 5000
SearchBox mount 1365 1341 5000
Shimmer mount 2523 2540 5000
Slider mount 2021 2012 5000
SpinButton mount 5113 5165 5000
Spinner mount 459 447 5000
SplitButton mount 3351 3294 5000
Stack mount 531 573 5000
StackWithIntrinsicChildren mount 2347 2403 5000
StackWithTextChildren mount 5435 5411 5000
SwatchColorPicker mount 11899 12074 5000
TagPicker mount 2807 2698 5000
TeachingBubble mount 96303 95526 5000
Text mount 477 450 5000
TextField mount 1586 1544 5000
ThemeProvider mount 1256 1269 5000
ThemeProvider virtual-rerender 689 657 5000
ThemeProvider virtual-rerender-with-unmount 2042 2062 5000
Toggle mount 796 927 5000
buttonNative mount 155 142 5000

@TristanWatanabe TristanWatanabe marked this pull request as ready for review April 4, 2022 17:11
@TristanWatanabe TristanWatanabe requested a review from a team as a code owner April 4, 2022 17:11
Copy link
Member

@ecraig12345 ecraig12345 left a comment

Choose a reason for hiding this comment

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

Soooo many tests 😵 -- thanks for working on this! A few minor comments.

const combobox = getByRole('combobox');
// open combobox to select one option
userEvent.click(combobox);
userEvent.click(getAllByRole('option')[0], undefined, { skipPointerEventsCheck: true });
Copy link
Member

Choose a reason for hiding this comment

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

What's skipPointerEventsCheck for?

Copy link
Member Author

Choose a reason for hiding this comment

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

Was getting the error below where the element apparently has pointer-events: none :
image

packages/react/src/components/ComboBox/ComboBox.test.tsx Outdated Show resolved Hide resolved
packages/react/src/components/ComboBox/ComboBox.test.tsx Outdated Show resolved Hide resolved

// open combobox to check options list
wrapper.find('button').simulate('click');
const caretdownButton = getByRole('presentation', { hidden: true });
Copy link
Member

Choose a reason for hiding this comment

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

Did finding it as a button not work? Finding "something with role presentation" seems not very reliable.

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 agree but I could not get it by role button since this element was explicitly set to role="presentation"

Copy link
Member

Choose a reason for hiding this comment

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

Could you do getByRole('button', { hidden: true })?

Copy link
Member Author

@TristanWatanabe TristanWatanabe Apr 19, 2022

Choose a reason for hiding this comment

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

That doesn't work either since its implicit button role is overwritten by the explicit role=presentation

packages/react/src/components/ComboBox/ComboBox.test.tsx Outdated Show resolved Hide resolved
packages/react/src/components/ComboBox/ComboBox.test.tsx Outdated Show resolved Hide resolved
<ComboBox multiSelect options={DEFAULT_OPTIONS} defaultSelectedKey={['1', '2', '3']} allowFreeform />,
wrapper => {
const inputElement = wrapper.find('input');
_verifyStateVariables(wrapper, 'none', DEFAULT_OPTIONS, [0, 1, 2]);
Copy link
Member

Choose a reason for hiding this comment

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

It might be good if you could find some other way to verify the things this was testing (possibly based on the DOM instead of internal state?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops missed this before but this _verifyStateVariables function was basically testing for stuff like focus status, available options and currently selected options and I basically simplified the tests to only worry about the expected value of the combobox element should be depending on different scenarios like an input text being autoselected onBlur in a freeform combobox.

@TristanWatanabe TristanWatanabe requested a review from a team April 15, 2022 17:19
Copy link
Contributor

@sopranopillow sopranopillow left a comment

Choose a reason for hiding this comment

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

LGTM!

@TristanWatanabe TristanWatanabe merged commit 57b8f7f into microsoft:master Apr 21, 2022
@TristanWatanabe TristanWatanabe deleted the combobox-convert-to-testing-library branch April 21, 2022 17:39
marwan38 pushed a commit to marwan38/fluentui that referenced this pull request Jun 13, 2022
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.

6 participants