-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
refactor: reorganize folder structure of React 18 tests for v9 #34051
Open
marcosmoura
wants to merge
1
commit into
microsoft:master
Choose a base branch
from
marcosmoura:refactor/react-18-test-for-v9
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
31 changes: 31 additions & 0 deletions
31
apps/react-18-tests-v9/src/components/Dialog/Dialog.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from 'react'; | ||
import { mount as mountBase } from '@cypress/react'; | ||
import { Dialog, DialogSurface, DialogTrigger, DialogBody, Button } from '@fluentui/react-components'; | ||
|
||
import { Provider } from '../Provider/Provider'; | ||
|
||
const mount = (element: JSX.Element) => { | ||
mountBase(<Provider>{element}</Provider>); | ||
}; | ||
|
||
describe('Dialog', () => { | ||
it('should render a Dialog', () => { | ||
mount( | ||
<Dialog> | ||
<DialogTrigger> | ||
<Button>Open dialog</Button> | ||
</DialogTrigger> | ||
|
||
<DialogSurface> | ||
<DialogBody> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam exercitationem cumque repellendus eaque | ||
est dolor eius expedita nulla ullam? Tenetur reprehenderit aut voluptatum impedit voluptates in natus iure | ||
cumque eaque? | ||
</DialogBody> | ||
</DialogSurface> | ||
</Dialog>, | ||
); | ||
|
||
cy.get('button').click().get('.fui-DialogSurface').should('exist'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react'; | ||
import { mount as mountBase } from '@cypress/react'; | ||
import { Menu, MenuTrigger, MenuPopover, MenuList, MenuItem } from '@fluentui/react-components'; | ||
|
||
import { Provider } from '../Provider/Provider'; | ||
|
||
const mount = (element: JSX.Element) => { | ||
mountBase(<Provider>{element}</Provider>); | ||
}; | ||
|
||
describe('Menu', () => { | ||
it('should render a Menu', () => { | ||
mount( | ||
<Menu> | ||
<MenuTrigger> | ||
<button>Click Me</button> | ||
</MenuTrigger> | ||
|
||
<MenuPopover> | ||
<MenuList> | ||
<MenuItem>Item</MenuItem> | ||
<MenuItem>Item</MenuItem> | ||
<MenuItem>Item</MenuItem> | ||
<MenuItem>Item</MenuItem> | ||
</MenuList> | ||
</MenuPopover> | ||
</Menu>, | ||
); | ||
|
||
cy.get('button').click().get('.fui-MenuList').should('exist'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
apps/react-18-tests-v9/src/components/Popover/Popover.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as React from 'react'; | ||
import { mount as mountBase } from '@cypress/react'; | ||
|
||
import { CustomPopover as Popover } from './Popover'; | ||
import { Provider } from '../Provider/Provider'; | ||
|
||
const mount = (element: JSX.Element) => { | ||
mountBase(<Provider>{element}</Provider>); | ||
}; | ||
|
||
describe('Popover with React 18', () => { | ||
it('should render a Popover', () => { | ||
mount(<Popover />); | ||
|
||
cy.get('button').click().get('.fui-PopoverSurface').should('exist'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from 'react'; | ||
import { Button, Popover, PopoverTrigger, PopoverSurface } from '@fluentui/react-components'; | ||
import { Provider } from '../Provider/Provider'; | ||
|
||
export const CustomPopover = () => { | ||
return ( | ||
<Provider> | ||
<Popover> | ||
<PopoverTrigger> | ||
<Button>Click Me</Button> | ||
</PopoverTrigger> | ||
<PopoverSurface>This is a popover</PopoverSurface> | ||
</Popover> | ||
</Provider> | ||
); | ||
}; |
11 changes: 6 additions & 5 deletions
11
apps/react-18-tests-v9/src/App.cy.tsx → ...9/src/components/Provider/Provider.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
apps/react-18-tests-v9/src/components/Provider/Provider.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { render } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
|
||
import { Button } from '@fluentui/react-components'; | ||
import { resetIdsForTests } from '@fluentui/react-utilities'; | ||
|
||
import { Provider } from './Provider'; | ||
|
||
describe('Provider with React 18', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
const noop = () => {}; | ||
|
||
beforeEach(() => { | ||
jest.spyOn(console, 'warn').mockImplementation(noop); | ||
}); | ||
|
||
afterEach(() => { | ||
resetIdsForTests(); | ||
}); | ||
|
||
describe('FluentProvider', () => { | ||
it('should apply matching className in strict mode', () => { | ||
const { getByText } = render( | ||
<Provider> | ||
<Button>Click Me</Button> | ||
</Provider>, | ||
); | ||
const element = getByText('Click Me'); | ||
const elementProviderClassName = element.className.split(' ')[1]; | ||
const matchingStyleTag = document.getElementById(elementProviderClassName); | ||
|
||
expect(matchingStyleTag).toBeDefined(); | ||
}); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
apps/react-18-tests-v9/src/components/Provider/Provider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
import { webLightTheme, FluentProvider } from '@fluentui/react-components'; | ||
|
||
export const Provider = ({ children }: React.PropsWithChildren) => { | ||
return ( | ||
<React.StrictMode> | ||
<FluentProvider theme={webLightTheme}>{children}</FluentProvider> | ||
</React.StrictMode> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
import * as React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import { App } from './App'; | ||
|
||
const root = createRoot(document.getElementById('root') as HTMLElement); | ||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
); | ||
export {}; |
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we actually testing with a version of Cypress that supports React 18? If not, it seems like the cypress mount might not be using createRoot from the React 18
react-dom/client
API.Currently, we have cypress/[email protected] in the root and we're still using [email protected], which, as I see also inside using cypress/react that does not support 18.
From migration docs of cypress 14:

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't add any support for React 18 yet. This just reorganize the files and folders so we can add the tests correctly later.
This dependency change will be applied in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks ;) I know it's a bit unrelated to the PR purpose, but I was not sure if it's known, as package already supposed to be setup for testing against React 18.