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

Fix a few more issues blocking React 17 in tests #22265

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

ecraig12345
Copy link
Member

@ecraig12345 ecraig12345 commented Mar 31, 2022

Current Behavior

Assorted things in tests fail with React 17. I fixed some of them already (#21032) but this PR fixes a few more.

New Behavior

After this PR, at least as far as the things a local yarn test covers, we should be unblocked from upgrading to React 17 (with the community Enzyme adapter @wojtekmaj/enzyme-adapter-react-17).

northstar changes

Add missing act() wrappers in the EventListener test.

In @fluentui/react-northstar-fela-renderer, replace the snapshot serializer from jest-react-fela with a small custom one. The old serializer relied on htmltojsx, which is extremely outdated (depends on React 15) and tries to import something from react-dom which was removed in 17. (This fix could theoretically be contributed upstream later if someone wants, I just won't have time.)

v8 changes

  • ScrollablePane: add a mock of a MutationObserver method which isn't needed and throws with React 17
  • BasePicker: change how inputs are focused. There's one test that I couldn't get working, so that should ideally be ported to Cypress later.

(When I previously attempted this, there wereThere also some really difficult issues with the FocusTrapZone tests in React 17, but we got rid of that problem by moving the tests to Cypress. Same with a few other components and testing-library.)

Related Issue(s)

Part of #20145

@DustyTheBot
Copy link

DustyTheBot commented Mar 31, 2022

Warnings
⚠️ There are no updates provided to CHANGELOG. Ensure there are no publicly visible changes introduced by this PR.

Generated by 🚫 dangerJS against a13f9a8

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 31, 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 a13f9a8:

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

@size-auditor
Copy link

size-auditor bot commented Mar 31, 2022

Asset size changes

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

Baseline commit: fe7dbfd37146a6927bf8bda91c91780423af4599 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 31, 2022

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1077 1043 5000
Button mount 640 648 5000
FluentProvider mount 2092 2159 5000
FluentProviderWithTheme mount 324 329 10
FluentProviderWithTheme virtual-rerender 268 285 10
FluentProviderWithTheme virtual-rerender-with-unmount 352 362 10
MakeStyles mount 1843 1832 50000

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 31, 2022

📊 Bundle size report

Unchanged fixtures
Package & Exports Size (minified/GZIP)
priority-overflow
createOverflowManager
2.836 kB
1.209 kB
react-accordion
Accordion (including children components)
74.792 kB
22.516 kB
react-avatar
Avatar
45.142 kB
13.111 kB
react-badge
Badge
20.895 kB
6.567 kB
react-badge
CounterBadge
21.848 kB
6.883 kB
react-badge
PresenceBadge
21.951 kB
6.565 kB
react-button
Button
28.013 kB
8.059 kB
react-button
CompoundButton
33.508 kB
9.092 kB
react-button
MenuButton
29.796 kB
8.665 kB
react-button
SplitButton
36.268 kB
9.863 kB
react-button
ToggleButton
37.395 kB
8.68 kB
react-card
Card - All
53.619 kB
15.372 kB
react-card
Card
48.904 kB
14.089 kB
react-card
CardFooter
7.686 kB
3.264 kB
react-card
CardHeader
9.251 kB
3.78 kB
react-card
CardPreview
7.658 kB
3.291 kB
react-combobox
Combobox
54.566 kB
18.884 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
176.089 kB
49.113 kB
react-components
react-components: FluentProvider & webLightTheme
32.601 kB
10.668 kB
react-divider
Divider
15.385 kB
5.539 kB
react-image
Image
10.109 kB
3.958 kB
react-input
Input
21.661 kB
7.18 kB
react-label
Label
8.371 kB
3.504 kB
react-link
Link
11.106 kB
4.507 kB
react-menu
Menu (including children components)
105.852 kB
32.433 kB
react-menu
Menu (including selectable components)
109.031 kB
32.897 kB
react-popover
Popover
96.787 kB
29.559 kB
react-portal
Portal
6.272 kB
2.17 kB
react-positioning
usePopper
23.21 kB
8.084 kB
react-priority-overflow
hooks only
10.606 kB
4.087 kB
react-provider
FluentProvider
14.009 kB
5.25 kB
react-select
Select
16.562 kB
6.264 kB
react-slider
Slider
25.549 kB
8.25 kB
react-spinner
Spinner
16.459 kB
5.549 kB
react-switch
Switch
24.279 kB
8.001 kB
react-text
Text - Default
10.797 kB
4.233 kB
react-text
Text - Wrappers
14.113 kB
4.576 kB
react-textarea
Textarea
20.602 kB
7.033 kB
react-theme
Single theme token import
69 B
89 B
react-theme
Teams: all themes
29.676 kB
6.604 kB
react-theme
Teams: Light theme
18.492 kB
5.296 kB
react-tooltip
Tooltip
42.837 kB
14.727 kB
react-utilities
SSRProvider
189 B
161 B
🤖 This report was generated against fe7dbfd37146a6927bf8bda91c91780423af4599

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 31, 2022

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
AccordionMinimalPerf.default 169 147 1.15:1
TreeWith60ListItems.default 200 178 1.12:1
AvatarMinimalPerf.default 219 199 1.1:1
SkeletonMinimalPerf.default 380 344 1.1:1
PortalMinimalPerf.default 196 179 1.09:1
TextAreaMinimalPerf.default 539 496 1.09:1
ButtonSlotsPerf.default 591 550 1.07:1
ReactionMinimalPerf.default 417 390 1.07:1
AttachmentSlotsPerf.default 1179 1113 1.06:1
FlexMinimalPerf.default 315 300 1.05:1
ListCommonPerf.default 692 661 1.05:1
HeaderSlotsPerf.default 831 800 1.04:1
MenuButtonMinimalPerf.default 1870 1796 1.04:1
RefMinimalPerf.default 263 253 1.04:1
SegmentMinimalPerf.default 363 348 1.04:1
ButtonMinimalPerf.default 174 169 1.03:1
DropdownMinimalPerf.default 3414 3322 1.03:1
GridMinimalPerf.default 362 351 1.03:1
RosterPerf.default 1233 1194 1.03:1
RadioGroupMinimalPerf.default 488 475 1.03:1
IconMinimalPerf.default 664 646 1.03:1
ButtonOverridesMissPerf.default 1659 1634 1.02:1
CardMinimalPerf.default 601 590 1.02:1
CarouselMinimalPerf.default 501 492 1.02:1
DividerMinimalPerf.default 386 378 1.02:1
ProviderMinimalPerf.default 450 442 1.02:1
CustomToolbarPrototype.default 3043 2974 1.02:1
ChatMinimalPerf.default 791 784 1.01:1
DialogMinimalPerf.default 837 826 1.01:1
EmbedMinimalPerf.default 4454 4407 1.01:1
ItemLayoutMinimalPerf.default 1257 1245 1.01:1
PopupMinimalPerf.default 682 677 1.01:1
ProviderMergeThemesPerf.default 1390 1370 1.01:1
SplitButtonMinimalPerf.default 4751 4696 1.01:1
TreeMinimalPerf.default 899 886 1.01:1
ChatWithPopoverPerf.default 413 415 1:1
DatepickerMinimalPerf.default 6644 6627 1:1
DropdownManyItemsPerf.default 733 730 1:1
InputMinimalPerf.default 1375 1370 1:1
LabelMinimalPerf.default 405 405 1:1
MenuMinimalPerf.default 911 913 1:1
TextMinimalPerf.default 378 378 1:1
ToolbarMinimalPerf.default 1039 1034 1:1
TooltipMinimalPerf.default 1171 1168 1:1
AnimationMinimalPerf.default 587 591 0.99:1
ImageMinimalPerf.default 379 383 0.99:1
ListMinimalPerf.default 559 565 0.99:1
ListNestedPerf.default 594 599 0.99:1
ListWith60ListItems.default 729 734 0.99:1
TableManyItemsPerf.default 2091 2107 0.99:1
TableMinimalPerf.default 416 422 0.99:1
VideoMinimalPerf.default 691 701 0.99:1
AlertMinimalPerf.default 284 290 0.98:1
AttachmentMinimalPerf.default 157 160 0.98:1
CheckboxMinimalPerf.default 2880 2926 0.98:1
BoxMinimalPerf.default 353 363 0.97:1
SliderMinimalPerf.default 1775 1825 0.97:1
ChatDuplicateMessagesPerf.default 299 312 0.96:1
FormMinimalPerf.default 417 436 0.96:1
HeaderMinimalPerf.default 362 376 0.96:1
LoaderMinimalPerf.default 711 742 0.96:1
LayoutMinimalPerf.default 357 381 0.94:1
StatusMinimalPerf.default 692 735 0.94:1

@fabricteam
Copy link
Collaborator

fabricteam commented Mar 31, 2022

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 893 908 5000
Breadcrumb mount 2743 2733 1000
Checkbox mount 1482 1449 5000
CheckboxBase mount 1248 1263 5000
ChoiceGroup mount 4703 4601 5000
ComboBox mount 954 992 1000
CommandBar mount 10308 10498 1000
ContextualMenu mount 11410 11426 1000
DefaultButton mount 1142 1138 5000
DetailsRow mount 3834 3893 5000
DetailsRowFast mount 3771 3762 5000
DetailsRowNoStyles mount 3607 3643 5000
Dialog mount 2195 2228 1000
DocumentCardTitle mount 156 179 1000
Dropdown mount 3319 3288 5000
FocusTrapZone mount 1793 1807 5000
FocusZone mount 1759 1816 5000
IconButton mount 1746 1758 5000
Label mount 351 354 5000
Layer mount 2888 2988 5000
Link mount 468 480 5000
MenuButton mount 1473 1482 5000
MessageBar mount 2121 2156 5000
Nav mount 3282 3265 1000
OverflowSet mount 1133 1092 5000
Panel mount 2139 2171 1000
Persona mount 1017 978 1000
Pivot mount 1447 1444 1000
PrimaryButton mount 1299 1290 5000
Rating mount 7743 7680 5000
SearchBox mount 1298 1289 5000
Shimmer mount 2502 2496 5000
Slider mount 1957 1953 5000
SpinButton mount 4956 5021 5000
Spinner mount 425 423 5000
SplitButton mount 3152 3121 5000
Stack mount 521 508 5000
StackWithIntrinsicChildren mount 2243 2235 5000
StackWithTextChildren mount 5211 5137 5000
SwatchColorPicker mount 11545 11527 5000
TagPicker mount 2695 2876 5000
TeachingBubble mount 90781 90329 5000
Text mount 440 420 5000
TextField mount 1391 1364 5000
ThemeProvider mount 1187 1173 5000
ThemeProvider virtual-rerender 647 662 5000
ThemeProvider virtual-rerender-with-unmount 1883 1904 5000
Toggle mount 789 792 5000
buttonNative mount 126 135 5000

Copy link
Contributor

@Hotell Hotell left a comment

Choose a reason for hiding this comment

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

🙌

yarn.lock Outdated Show resolved Hide resolved
@ling1726
Copy link
Member

ling1726 commented Apr 1, 2022

@ecraig12345 I tried to check out this PR and test it out. I used a yarn resolution to pin the repo to react 17. However, I'm getting errors when running the test. is there any other steps that are required to test this out ?

I get this error as soon as mount is called in the EventListener tests:
image

@ecraig12345
Copy link
Member Author

I tried to check out this PR and test it out. I used a yarn resolution to pin the repo to react 17. However, I'm getting errors when running the test. is there any other steps that are required to test this out ?

I get this error as soon as mount is called in the EventListener tests: image

Did you update the enzyme adapter (and references) to @wojtekmaj/enzyme-adapter-react-17? Alternatively you can check out the react-17 branch in my fork.

@ecraig12345
Copy link
Member Author

@ling1726 You can try the branch in #22326

@ecraig12345 ecraig12345 closed this Apr 5, 2022
V-Build - @microsoft/fluentui-react-build automation moved this from In progress to Done Apr 5, 2022
@ecraig12345 ecraig12345 reopened this Apr 5, 2022
V-Build - @microsoft/fluentui-react-build automation moved this from Done to In progress Apr 5, 2022
@ecraig12345 ecraig12345 requested review from khmakoto and a team as code owners April 5, 2022 01:25
@@ -1,20 +1,42 @@
import { createFelaRenderer } from '@fluentui/react-northstar-fela-renderer';
import { ICSSInJSStyle } from '@fluentui/styles';
// @ts-ignore
import { createSnapshot } from 'jest-react-fela';
import { renderToString } from 'fela-tools';
Copy link
Member

Choose a reason for hiding this comment

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

Wondering why nothing complains, but probably fela-tools should be added to devDependencies in packages/fluentui/react-northstar-fela-renderer/package.json or to a root package.json.

+"fela-tools": "^10.6.1",

Copy link
Member Author

Choose a reason for hiding this comment

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

It's in react-northstar devDependencies, plus it's a dep of various other things, so maybe it's working implicitly for that reason.

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 added it to react-northstar-fela-renderer for now since we don't currently have any fela stuff at the root. But at some point those dev deps should probably all go to the root for consistency.

V-Build - @microsoft/fluentui-react-build automation moved this from In progress to Reviewer approved Apr 6, 2022
@ecraig12345
Copy link
Member Author

@ling1726 I'm going to merge this to keep moving but let me know if you have more feedback later

@ecraig12345 ecraig12345 merged commit 6fd7a55 into microsoft:master Apr 6, 2022
V-Build - @microsoft/fluentui-react-build automation moved this from Reviewer approved to Done Apr 6, 2022
@ecraig12345 ecraig12345 deleted the react-17-pre branch April 7, 2022 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants