Skip to content

Commit f21a50c

Browse files
authored
test: update test suites for React 19 (#7209)
1 parent 9605a30 commit f21a50c

File tree

12 files changed

+85
-2694
lines changed

12 files changed

+85
-2694
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ jobs:
8383
uses: docker://mcr.microsoft.com/playwright:v1.55.0-jammy
8484
with:
8585
args: npm test
86-
continue-on-error: ${{ matrix.react-version == 'react-19' }}
8786

8887
type-check:
8988
runs-on: ubuntu-latest

packages/react/src/ActionList/Group.test.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import {describe, it, expect, vi} from 'vitest'
1+
import {describe, it, expect} from 'vitest'
22
import {render as HTMLRender} from '@testing-library/react'
33
import BaseStyles from '../BaseStyles'
44
import {ActionList} from '.'
55
import {ActionMenu} from '..'
66

77
describe('ActionList.Group', () => {
88
it('should throw an error when ActionList.GroupHeading has an `as` prop when it is used within ActionMenu context', async () => {
9-
const spy = vi.spyOn(console, 'error').mockImplementation(() => vi.fn())
109
expect(() =>
1110
HTMLRender(
1211
<BaseStyles>
@@ -25,8 +24,6 @@ describe('ActionList.Group', () => {
2524
).toThrow(
2625
"Looks like you are trying to set a heading level to a menu role. Group headings for menu type action lists are for representational purposes, and rendered as divs. Therefore they don't need a heading level.",
2726
)
28-
expect(spy).toHaveBeenCalled()
29-
spy.mockRestore()
3027
})
3128

3229
it('should render the ActionList.GroupHeading component as a heading with the given heading level', async () => {
@@ -43,7 +40,6 @@ describe('ActionList.Group', () => {
4340
expect(heading).toHaveTextContent('Group Heading')
4441
})
4542
it('should throw an error if ActionList.GroupHeading is used without an `as` prop when no role is specified (for list role)', async () => {
46-
const spy = vi.spyOn(console, 'error').mockImplementation(() => vi.fn())
4743
expect(() =>
4844
HTMLRender(
4945
<ActionList>
@@ -57,8 +53,6 @@ describe('ActionList.Group', () => {
5753
).toThrow(
5854
"You are setting a heading for a list, that requires a heading level. Please use 'as' prop to set a proper heading level.",
5955
)
60-
expect(spy).toHaveBeenCalled()
61-
spy.mockRestore()
6256
})
6357
it('should render the ActionList.GroupHeading component as a span (not a heading tag) when role is specified as listbox', async () => {
6458
const container = HTMLRender(

packages/react/src/ActionList/Heading.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {describe, it, expect, vi} from 'vitest'
1+
import {describe, it, expect} from 'vitest'
22
import {render as HTMLRender} from '@testing-library/react'
33
import BaseStyles from '../BaseStyles'
44
import {ActionList} from '.'
@@ -29,7 +29,6 @@ describe('ActionList.Heading', () => {
2929
})
3030

3131
it('should throw an error when ActionList.Heading is used within ActionMenu context', async () => {
32-
const spy = vi.spyOn(console, 'error').mockImplementation(() => vi.fn())
3332
expect(() =>
3433
HTMLRender(
3534
<BaseStyles>
@@ -47,8 +46,6 @@ describe('ActionList.Heading', () => {
4746
).toThrow(
4847
"ActionList.Heading shouldn't be used within an ActionMenu container. Menus are labelled by the menu button's name.",
4948
)
50-
expect(spy).toHaveBeenCalled()
51-
spy.mockRestore()
5249
})
5350

5451
it('should support a custom `className` on the outermost element', () => {

packages/react/src/AnchoredOverlay/AnchoredOverlay.test.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ describe('AnchoredOverlay', () => {
122122
expect(mockCloseCallback).toHaveBeenCalledWith('escape')
123123
})
124124

125-
it('should render consistently when open', () => {
126-
const {container} = render(<AnchoredOverlayTestComponent initiallyOpen={true} />)
127-
expect(container).toMatchSnapshot()
128-
})
129-
130125
it('should call onPositionChange when provided', async () => {
131126
const mockPositionChangeCallback = vi.fn(({position}: {position: AnchorPosition}) => position)
132127
render(<AnchoredOverlayTestComponent initiallyOpen={true} onPositionChange={mockPositionChangeCallback} />)

packages/react/src/AnchoredOverlay/__snapshots__/AnchoredOverlay.test.tsx.snap

Lines changed: 0 additions & 75 deletions
This file was deleted.

packages/react/src/NavList/NavList.test.tsx

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,6 @@ const NextJSLikeLink = React.forwardRef<HTMLAnchorElement, NextJSLinkProps>(
2121
)
2222

2323
describe('NavList', () => {
24-
it('renders a simple list', () => {
25-
const {container} = render(
26-
<NavList>
27-
<NavList.Item href="/" aria-current="page">
28-
Home
29-
</NavList.Item>
30-
<NavList.Item href="/about">About</NavList.Item>
31-
<NavList.Item href="/contact">Contact</NavList.Item>
32-
</NavList>,
33-
)
34-
expect(container).toMatchSnapshot()
35-
})
36-
37-
it('renders with groups', () => {
38-
const {container} = render(
39-
<NavList>
40-
<NavList.Group title="Overview">
41-
<NavList.Item href="/getting-started" aria-current="page">
42-
Getting started
43-
</NavList.Item>
44-
</NavList.Group>
45-
<NavList.Group title="Components">
46-
<NavList.Item href="/Avatar">Avatar</NavList.Item>
47-
</NavList.Group>
48-
</NavList>,
49-
)
50-
expect(container).toMatchSnapshot()
51-
})
52-
5324
it('supports TrailingAction', async () => {
5425
const {getByRole} = render(
5526
<NavList>
@@ -196,54 +167,6 @@ describe('NavList.Item with NavList.SubNav', () => {
196167
expect(queryByRole('list', {name: 'Item 2'})).toBeNull()
197168
})
198169

199-
it('has active styles if SubNav contains the current item and is closed', () => {
200-
const {container, getByRole, queryByRole} = render(
201-
<NavList>
202-
<NavList.Item>
203-
Item
204-
<NavList.SubNav>
205-
<NavList.Item href="#" aria-current="page">
206-
Sub Item
207-
</NavList.Item>
208-
</NavList.SubNav>
209-
</NavList.Item>
210-
</NavList>,
211-
)
212-
213-
const button = getByRole('button')
214-
215-
// Starts open
216-
expect(queryByRole('list', {name: 'Item'})).toBeVisible()
217-
218-
// Click to close
219-
fireEvent.click(button)
220-
expect(queryByRole('list', {name: 'Item'})).toBeNull()
221-
222-
// Snapshot styles
223-
expect(container).toMatchSnapshot()
224-
})
225-
226-
it('does not have active styles if SubNav contains the current item and is open', () => {
227-
const {container, queryByRole} = render(
228-
<NavList>
229-
<NavList.Item>
230-
Item
231-
<NavList.SubNav>
232-
<NavList.Item href="#" aria-current="page">
233-
Sub Item
234-
</NavList.Item>
235-
</NavList.SubNav>
236-
</NavList.Item>
237-
</NavList>,
238-
)
239-
240-
// Starts open
241-
expect(queryByRole('list', {name: 'Item'})).toBeVisible()
242-
243-
// Snapshot styles
244-
expect(container).toMatchSnapshot()
245-
})
246-
247170
it('prevents more than 4 levels of nested SubNavs', () => {
248171
const consoleSpy = vi
249172
.spyOn(console, 'error')

0 commit comments

Comments
 (0)