-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve react-18 tests (#25758)
* 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
- Loading branch information
Showing
24 changed files
with
205 additions
and
197 deletions.
There are no files selected for viewing
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,8 +1,5 @@ | ||
{ | ||
"extends": ["plugin:@fluentui/eslint-plugin/react--legacy"], | ||
"extends": ["plugin:@fluentui/eslint-plugin/react"], | ||
"root": true, | ||
"rules": { | ||
"deprecation/deprecation": "off", | ||
"prefer-const": "off" | ||
} | ||
"rules": {} | ||
} |
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
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
45 changes: 0 additions & 45 deletions
45
apps/react-18-tests-v8/src/components/ContextualMenu/ContextualMenu.e2e.tsx
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
apps/react-18-tests-v8/src/components/ContextualMenu/ContextualMenu.test.tsx
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
apps/react-18-tests-v8/src/components/ContextualMenu/ContextualMenuExample.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,19 @@ | ||
import * as React from 'react'; | ||
import { mount } from '@cypress/react'; | ||
|
||
import { ContextualMenuExample } from './ContextualMenuExample'; | ||
|
||
const menuTriggerSelector = '[type="button"]'; | ||
const menuSelector = '[role="menu"]'; | ||
|
||
describe('ContextualMenu in React 18', () => { | ||
it('renders ContextualMenu when trigger button is clicked', () => { | ||
mount( | ||
<React.StrictMode> | ||
<ContextualMenuExample /> | ||
</React.StrictMode>, | ||
); | ||
|
||
cy.get(menuTriggerSelector).click().get(menuSelector).should('be.visible'); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
apps/react-18-tests-v8/src/components/ContextualMenu/ContextualMenuExample.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,29 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import { ContextualMenuExample } from './ContextualMenuExample'; | ||
|
||
describe('ContextualMenu in React 18', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
const noop = () => {}; | ||
|
||
beforeEach(() => { | ||
jest.spyOn(console, 'warn').mockImplementation(noop); | ||
}); | ||
|
||
it('should render ContextualMenu when trigger button is clicked', () => { | ||
const { getByRole, queryAllByRole } = render( | ||
<React.StrictMode> | ||
<ContextualMenuExample /> | ||
</React.StrictMode>, | ||
); | ||
|
||
expect(queryAllByRole('menu').length).toBe(0); | ||
|
||
const menuTrigger = getByRole('button'); | ||
userEvent.click(menuTrigger); | ||
|
||
expect(queryAllByRole('menu').length).toBe(1); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
{ | ||
"extends": ["plugin:@fluentui/eslint-plugin/react--legacy"], | ||
"extends": ["plugin:@fluentui/eslint-plugin/react"], | ||
"root": true, | ||
"rules": { | ||
"deprecation/deprecation": "off", | ||
"prefer-const": "off" | ||
} | ||
"rules": {} | ||
} |
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
Oops, something went wrong.