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: improve react-18 tests #25758

Merged
merged 7 commits into from
Nov 25, 2022

Conversation

Hotell
Copy link
Contributor

@Hotell Hotell commented Nov 22, 2022

Previous Behavior

tests and app code is more or less copy paste that can get out of sync quickly. Also this approach goes against good testing practices.

v8:

  • all tasks need prior call of lage build --to - (undocumented, not good DX)

v9:

  • has not e2e defined thus tests are not run on ci

New Behavior

tests follow best practices and use application code within

v8:

  • test,start,e2e works without build

v9:

  • e2e runs on ci

Related Issue(s)

@Hotell Hotell changed the title Hotell/build/tweak react 18 tests feat: improve react-18 tests Nov 22, 2022
@Hotell Hotell removed this from the October Project Cycle Q4 2022 milestone Nov 22, 2022
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
moduleNameMapper: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

previous setup was using path mappings for v9 which is has no effect

@@ -1,7 +1,7 @@
{
"name": "@fluentui/react-18-tests-v8",
"description": "React 18 test application",
"version": "1.0.0",
"version": "8.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is needed as tooling checks version and tweaks its behaviours based on that ( cypress )

"@fluentui/scripts": "^1.0.0",
"@types/react": "18.0.14",
"@types/react-dom": "18.0.6",
"swc-loader": "^0.2.3"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

swc-loader is in root package version already - single version policy conformance

it('renders ContextualMenu when trigger button is clicked', () => {
mount(
<React.StrictMode>
<ContextualMenuExample />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this uses implementation instead of having the same code on 3 places


const providerSelector = '.fui-FluentProvider';

describe('App with React 18', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

propagated these test to Root as they are rendering the App instead of manually re-creating Provider

</React.StrictMode>,
);

cy.get(providerSelector)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

curious what's the purpose of testing this on both e2e(cypress) and unit(jest) level @TristanWatanabe @micahgodbolt as it creates duplication.

Also I'm not sure about robustness of this test. what has that className to do with react 18 compatibility ?

Note - same questions for v8 react-18-tests

Copy link
Member

@ling1726 ling1726 Nov 24, 2022

Choose a reason for hiding this comment

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

I would guess that it's currently a simple to to check that the app does not crash (i.e. provider exists). Honestly I would try to leverage our existing cypress tests instead instead of having separate tests just for react 18 🤔

@@ -10,6 +10,19 @@ const applyV8WebpackConfig: (config: Configuration) => Configuration = require('

const isLocalRun = !process.env.DEPLOYURL;

function isV8() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

context aware check instead of hard-coding path.

refactor later: ideally this shouln't be here but somewhere else

Copy link
Member

Choose a reason for hiding this comment

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

probably should be some kind of utility like isV8ExecutionContext

@size-auditor
Copy link

size-auditor bot commented Nov 22, 2022

Asset size changes

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

Baseline commit: c093fbbbcdabefd2603cbd840b039d583fb0ff0e (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 22, 2022

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1287 1298 5000
Button mount 915 931 5000
FluentProvider mount 1482 1491 5000
FluentProviderWithTheme mount 576 572 10
FluentProviderWithTheme virtual-rerender 542 538 10
FluentProviderWithTheme virtual-rerender-with-unmount 584 568 10
MakeStyles mount 1974 1968 50000
SpinButton mount 2320 2283 5000

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 22, 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 84e0eab:

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

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 22, 2022

🕵 fluentuiv8 Open the Visual Regressions report to inspect the 2 screenshots

✅ There was 0 screenshots added, 2 screenshots removed, 1037 screenshots unchanged, 0 screenshots with different dimensions and 0 screenshots with visible difference.

unknown 2 screenshots
Image Name Diff(in Pixels) Image Type
Pivot - Overflow.Root.Narrow - Last tab selected.chromium.png 0 Removed
Pivot - Overflow.Root.Narrow - Overflow menu.chromium.png 0 Removed

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 22, 2022

📊 Bundle size report

Unchanged fixtures
Package & Exports Size (minified/GZIP)
global-context
createContext
533 B
341 B
global-context
createContextSelector
554 B
348 B
priority-overflow
createOverflowManager
3.153 kB
1.299 kB
react-accordion
Accordion (including children components)
79.294 kB
24.443 kB
react-alert
Alert
86.891 kB
21.708 kB
react-avatar
Avatar
51.076 kB
14.285 kB
react-avatar
AvatarGroup
15.006 kB
6.009 kB
react-avatar
AvatarGroupItem
65.654 kB
18.382 kB
react-badge
Badge
23.357 kB
7.361 kB
react-badge
CounterBadge
24.247 kB
7.643 kB
react-badge
PresenceBadge
24.001 kB
7.049 kB
react-button
Button
36.86 kB
9.913 kB
react-button
CompoundButton
43.885 kB
11.131 kB
react-button
MenuButton
41.537 kB
11.187 kB
react-button
SplitButton
48.983 kB
12.588 kB
react-button
ToggleButton
52.685 kB
11.415 kB
react-card
Card - All
71.873 kB
20.936 kB
react-card
Card
67.651 kB
19.892 kB
react-card
CardFooter
8.617 kB
3.62 kB
react-card
CardHeader
9.792 kB
3.995 kB
react-card
CardPreview
8.718 kB
3.674 kB
react-combobox
Combobox (including child components)
78.244 kB
25.015 kB
react-combobox
Dropdown (including child components)
77.531 kB
24.927 kB
react-components
react-components: Button, FluentProvider & webLightTheme
62.975 kB
17.687 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
190.411 kB
53.077 kB
react-components
react-components: FluentProvider & webLightTheme
33.48 kB
11.037 kB
react-dialog
Dialog (including children components)
83.036 kB
24.754 kB
react-divider
Divider
16.515 kB
5.921 kB
react-image
Image
10.836 kB
4.283 kB
react-infobutton
InfoButton
117.922 kB
35.391 kB
react-input
Input
24.194 kB
7.89 kB
react-label
Label
9.394 kB
3.88 kB
react-link
Link
11.862 kB
4.885 kB
react-menu
Menu (including children components)
117.61 kB
36.287 kB
react-menu
Menu (including selectable components)
120.679 kB
36.82 kB
react-overflow
hooks only
11.004 kB
4.188 kB
react-persona
Persona
57.131 kB
15.951 kB
react-popover
Popover
103.666 kB
31.858 kB
react-portal
Portal
10.495 kB
3.851 kB
react-portal-compat
PortalCompatProvider
5.857 kB
1.978 kB
react-positioning
usePositioning
19.826 kB
7.417 kB
react-progress
Progress
13.536 kB
5.107 kB
react-provider
FluentProvider
15.817 kB
5.905 kB
react-radio
Radio
36.446 kB
12.123 kB
react-radio
RadioGroup
14.304 kB
5.72 kB
react-select
Select
23.474 kB
8.017 kB
react-slider
Slider
32.118 kB
10.192 kB
react-spinbutton
SpinButton
44.502 kB
12.812 kB
react-spinner
Spinner
20.013 kB
6.446 kB
react-switch
Switch
33.453 kB
10.581 kB
react-text
Text - Default
11.838 kB
4.625 kB
react-text
Text - Wrappers
15.148 kB
5.06 kB
react-textarea
Textarea
25.733 kB
8.328 kB
react-theme
Single theme token import
69 B
89 B
react-theme
Teams: all themes
29.722 kB
6.462 kB
react-theme
Teams: Light theme
17.51 kB
5.075 kB
react-tooltip
Tooltip
42.032 kB
14.739 kB
react-utilities
SSRProvider
180 B
159 B
🤖 This report was generated against c093fbbbcdabefd2603cbd840b039d583fb0ff0e

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 22, 2022

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
TreeWith60ListItems.default 143 122 1.17:1
RefMinimalPerf.default 199 186 1.07:1
GridMinimalPerf.default 305 288 1.06:1
LayoutMinimalPerf.default 329 309 1.06:1
TextAreaMinimalPerf.default 429 405 1.06:1
FlexMinimalPerf.default 257 248 1.04:1
TextMinimalPerf.default 313 301 1.04:1
CardMinimalPerf.default 472 460 1.03:1
ListNestedPerf.default 487 472 1.03:1
LoaderMinimalPerf.default 268 259 1.03:1
ReactionMinimalPerf.default 337 328 1.03:1
StatusMinimalPerf.default 616 599 1.03:1
VideoMinimalPerf.default 642 625 1.03:1
AvatarMinimalPerf.default 165 162 1.02:1
ChatDuplicateMessagesPerf.default 215 210 1.02:1
ChatMinimalPerf.default 639 627 1.02:1
DividerMinimalPerf.default 316 309 1.02:1
FormMinimalPerf.default 329 323 1.02:1
HeaderSlotsPerf.default 699 685 1.02:1
ListMinimalPerf.default 463 455 1.02:1
MenuButtonMinimalPerf.default 1369 1347 1.02:1
PortalMinimalPerf.default 141 138 1.02:1
ProviderMergeThemesPerf.default 1009 990 1.02:1
ProviderMinimalPerf.default 319 314 1.02:1
SegmentMinimalPerf.default 306 299 1.02:1
SkeletonMinimalPerf.default 307 300 1.02:1
IconMinimalPerf.default 582 569 1.02:1
AnimationMinimalPerf.default 479 472 1.01:1
DialogMinimalPerf.default 685 680 1.01:1
ItemLayoutMinimalPerf.default 981 970 1.01:1
LabelMinimalPerf.default 344 341 1.01:1
ListWith60ListItems.default 503 499 1.01:1
PopupMinimalPerf.default 567 559 1.01:1
SliderMinimalPerf.default 1239 1231 1.01:1
SplitButtonMinimalPerf.default 3311 3263 1.01:1
TableMinimalPerf.default 363 358 1.01:1
CustomToolbarPrototype.default 2162 2148 1.01:1
TooltipMinimalPerf.default 1911 1883 1.01:1
TreeMinimalPerf.default 706 700 1.01:1
AttachmentMinimalPerf.default 122 122 1:1
AttachmentSlotsPerf.default 884 881 1:1
ButtonOverridesMissPerf.default 1029 1024 1:1
ChatWithPopoverPerf.default 294 293 1:1
CheckboxMinimalPerf.default 1520 1527 1:1
DropdownMinimalPerf.default 2170 2170 1:1
EmbedMinimalPerf.default 2627 2631 1:1
ListCommonPerf.default 511 511 1:1
MenuMinimalPerf.default 739 741 1:1
RosterPerf.default 1710 1702 1:1
RadioGroupMinimalPerf.default 391 390 1:1
TableManyItemsPerf.default 1574 1577 1:1
ToolbarMinimalPerf.default 804 800 1:1
CarouselMinimalPerf.default 357 360 0.99:1
ImageMinimalPerf.default 333 338 0.99:1
DatepickerMinimalPerf.default 4671 4743 0.98:1
DropdownManyItemsPerf.default 540 551 0.98:1
HeaderMinimalPerf.default 315 321 0.98:1
InputMinimalPerf.default 842 856 0.98:1
AlertMinimalPerf.default 221 229 0.97:1
BoxMinimalPerf.default 295 305 0.97:1
ButtonMinimalPerf.default 134 138 0.97:1
ButtonSlotsPerf.default 420 432 0.97:1
AccordionMinimalPerf.default 122 129 0.95:1

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 22, 2022

🕵 fluentuiv9 Open the Visual Regressions report to inspect the 2 screenshots

✅ There was 0 screenshots added, 0 screenshots removed, 1749 screenshots unchanged, 0 screenshots with different dimensions and 2 screenshots with visible difference.

unknown 2 screenshots
Image Name Diff(in Pixels) Image Type
Avatar Converged.size+active+badge.normal.chromium.png 13 Changed
Avatar Converged.size+active+ring-shadow.normal.chromium.png 14 Changed

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 22, 2022

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 1207 1179 5000
Breadcrumb mount 2781 2818 1000
Checkbox mount 2646 2695 5000
CheckboxBase mount 2383 2390 5000
ChoiceGroup mount 4309 4298 5000
ComboBox mount 1181 1198 1000
CommandBar mount 9376 9313 1000
ContextualMenu mount 10473 10614 1000
DefaultButton mount 1366 1377 5000
DetailsRow mount 3375 3383 5000
DetailsRowFast mount 3412 3391 5000
DetailsRowNoStyles mount 3241 3249 5000
Dialog mount 2980 2978 1000
DocumentCardTitle mount 582 585 1000
Dropdown mount 3191 3177 5000
FocusTrapZone mount 1976 1972 5000
FocusZone mount 1929 1909 5000
GroupedList mount 1854 2073 2
GroupedList virtual-rerender 1107 1132 2
GroupedList virtual-rerender-with-unmount 1639 1610 2
GroupedListV2 mount 556 572 2
GroupedListV2 virtual-rerender 541 553 2
GroupedListV2 virtual-rerender-with-unmount 570 569 2
IconButton mount 1801 1807 5000
Label mount 760 753 5000
Layer mount 4179 4228 5000
Link mount 862 872 5000
MenuButton mount 1615 1604 5000
MessageBar mount 2322 2307 5000
Nav mount 3094 3085 1000
OverflowSet mount 1416 1416 5000
Panel mount 2541 2540 1000
Persona mount 1285 1298 1000
Pivot mount 1517 1518 1000
PrimaryButton mount 1487 1493 5000
Rating mount 7011 7032 5000
SearchBox mount 1511 1512 5000
Shimmer mount 2934 2958 5000
Slider mount 2126 2117 5000
SpinButton mount 4331 4274 5000
Spinner mount 821 841 5000
SplitButton mount 2947 2833 5000
Stack mount 867 859 5000
StackWithIntrinsicChildren mount 2359 2354 5000
StackWithTextChildren mount 5063 5042 5000
SwatchColorPicker mount 9559 9546 5000
TagPicker mount 2345 2332 5000
TeachingBubble mount 76837 75904 5000
Text mount 808 831 5000
TextField mount 1543 1547 5000
ThemeProvider mount 1447 1447 5000
ThemeProvider virtual-rerender 1141 1152 5000
ThemeProvider virtual-rerender-with-unmount 1998 2010 5000
Toggle mount 1139 1140 5000
buttonNative mount 534 538 5000

@Hotell Hotell force-pushed the hotell/build/tweak-react-18-tests branch from df82d58 to cba9aba Compare November 23, 2022 14:30
@@ -9,12 +12,18 @@ module.exports = {
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
diagnostics: { warnOnly: true, exclude: ['packages/**'] },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this exposed lot of warnings from v8 packages - caused by not following isolateModules.

this will resolve it #25774

@Hotell Hotell marked this pull request as ready for review November 24, 2022 14:24
@Hotell Hotell requested a review from a team as a code owner November 24, 2022 14:24
@Hotell Hotell removed this from the October Project Cycle Q4 2022 milestone Nov 24, 2022
},
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: 'swc-loader',
use: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

v8 cannot be compiled with swc, switching to esbuild for now swc-project/swc#2037

},
},
{
test: /\.scss$/,
Copy link
Member

Choose a reason for hiding this comment

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

why are sass and css loaders only added now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously v8 needed to build everything prior to run. also it was misconfigured to use v9 path aliases etc. more info is in PR description

@@ -10,6 +10,19 @@ const applyV8WebpackConfig: (config: Configuration) => Configuration = require('

const isLocalRun = !process.env.DEPLOYURL;

function isV8() {
const packageJsonPath = path.join(process.cwd(), 'package.json');
Copy link
Member

Choose a reason for hiding this comment

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

this assumes that the cwd is in the root of a package, perhaps use findUp ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

curios why ? cypress is always invoked from root of a package

Copy link
Member

Choose a reason for hiding this comment

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

is that always the case? I've worked on component packages before and ran yarn somewhere from src

Copy link
Contributor Author

@Hotell Hotell Nov 25, 2022

Choose a reason for hiding this comment

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

I see, well that's definitely not supported behaviour as it adds magic to our DX. you should execute task always from root.

ATM the dev flow we support is like this:

  • yarn workspace <package-name> <npm-script> recommended
  • cd packages/<package> && yarn <npm-script> not recommended

in future, with nx in place, this will be kinda enforced as well (running task from root).

@Hotell Hotell requested a review from ling1726 November 24, 2022 16:26
@Hotell Hotell enabled auto-merge (squash) November 25, 2022 10:49
@Hotell Hotell removed this from the October Project Cycle Q4 2022 milestone Nov 25, 2022
@Hotell Hotell merged commit 56a61fc into microsoft:master Nov 25, 2022
@Hotell Hotell deleted the hotell/build/tweak-react-18-tests branch November 25, 2022 11:59
marcosmoura added a commit to marcosmoura/fluentui that referenced this pull request Nov 29, 2022
* master: (34 commits)
  chore(react-tooltip): migrate to new package structure (microsoft#25818)
  chore(react-field): migrate to new package structure (microsoft#25817)
  Update vr screenshotdiff lib to accept vr host url as param (microsoft#25772)
  feat(scripts): enable strict checking for additional sub-folders(packages) v4 (microsoft#25710)
  fix(tools): bump norhtstar packages v9 deps on dep mismatch resolution (microsoft#25806)
  feat: remove react-storybook and replace its functionality via standard react-storybook-addon package (microsoft#25786)
  applying package updates
  chore(react-spinbutton): migrate to new package structure (microsoft#25813)
  chore(react-spinner): migrate to new package structure (microsoft#25814)
  chore(react-provider): migrate to new package structure (microsoft#25809)
  chore(react-radio, shared-contexts): migrate to new package structure (microsoft#25810)
  chore(react-theme): migrate to new package structure (microsoft#25812)
  docs: add Fluent UI Insights EP04 to README (microsoft#25775)
  chore(react-migration-v8-v9): use same build process/setup as v9/ts-solution packages (microsoft#25679)
  docs: Improves `Table` documentation (microsoft#25787)
  feat: improve react-18 tests (microsoft#25758)
  docs: Add examples for DataGrid (microsoft#25783)
  chore(react-tree): scaffold TreeItemLayout (microsoft#25781)
  perf: make ts-minbar test compilation faster and asset preparation simpler (microsoft#25754)
  chore: creates TreeItem and basic Tree (microsoft#25742)
  ...
Hotell added a commit to Hotell/fluentui that referenced this pull request Feb 9, 2023
* fix(react-18-tests-v9): enable e2e run on ci and normalize all test scenarios
* feat(scripts): resolve cypress webpack config based on packageJson.version instead hardcoded folder name
* feat(react-18-tests-v8): enable build-less DX for start,test,e2e and normalize all test scenarios
* feat(react-18-tests-v9): use react-components suite with type checking enabled
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