Skip to content

Commit 0a521a9

Browse files
authored
feat!: Update Ariakit to 0.4.19 (#981)
* chore: Update Ariakit to 0.4.19 * Wait for tabs to be visible in tests * Loosen Ariakit peer dependency version
1 parent 389931a commit 0a521a9

File tree

3 files changed

+54
-24
lines changed

3 files changed

+54
-24
lines changed

package-lock.json

Lines changed: 26 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@
6161
"plop": "plop"
6262
},
6363
"peerDependencies": {
64+
"@ariakit/react": "~0.4.19",
6465
"classnames": "^2.2.5",
6566
"prop-types": "^15.6.2",
6667
"react": "^17.0.0 || ^18.0.0",
6768
"react-dom": "^17.0.0 || ^18.0.0"
6869
},
6970
"devDependencies": {
71+
"@ariakit/react": "0.4.19",
7072
"@babel/core": "^7.9.6",
7173
"@babel/plugin-proposal-class-properties": "^7.10.1",
7274
"@babel/plugin-proposal-export-default-from": "^7.0.0",
@@ -161,7 +163,6 @@
161163
"webpack": "^4.43.0"
162164
},
163165
"dependencies": {
164-
"@ariakit/react": "0.4.5",
165166
"aria-hidden": "^1.2.1",
166167
"dayjs": "^1.8.10",
167168
"patch-package": "^6.4.6",

src/tabs/tabs.test.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,24 @@ describe('Tabs', () => {
2727
expect(screen.getByText('Content of tab 3')).not.toBeVisible()
2828

2929
userEvent.click(screen.getByRole('tab', { name: 'Tab 2' }))
30-
expect(screen.getByText('Content of tab 1')).not.toBeVisible()
30+
31+
await waitFor(() => {
32+
expect(screen.getByText('Content of tab 1')).not.toBeVisible()
33+
})
34+
3135
expect(screen.getByRole('tabpanel', { name: 'Tab 2' })).toBeVisible()
3236
expect(screen.getByText('Content of tab 2')).toBeVisible()
3337
expect(screen.getByText('Content of tab 3')).not.toBeVisible()
3438

3539
userEvent.click(screen.getByRole('tab', { name: 'Tab 3' }))
40+
41+
await waitFor(() => {
42+
expect(screen.getByText('Content of tab 2')).not.toBeVisible()
43+
})
44+
3645
expect(screen.getByText('Content of tab 1')).not.toBeVisible()
37-
expect(screen.getByText('Content of tab 2')).not.toBeVisible()
38-
expect(screen.getByRole('tabpanel', { name: 'Tab 3' })).toBeVisible()
3946
expect(screen.getByText('Content of tab 3')).toBeVisible()
47+
expect(screen.getByRole('tabpanel', { name: 'Tab 3' })).toBeVisible()
4048
})
4149

4250
it("renders a tab's content only when they're active when each TabPanel's `render` prop is set to 'active'", async () => {
@@ -103,19 +111,27 @@ describe('Tabs', () => {
103111
expect(screen.queryByText('Content of tab 3')).not.toBeInTheDocument()
104112

105113
userEvent.click(screen.getByRole('tab', { name: 'Tab 2' }))
106-
expect(screen.getByText('Content of tab 1')).not.toBeVisible()
114+
115+
await waitFor(() => {
116+
expect(screen.getByText('Content of tab 1')).not.toBeVisible()
117+
})
118+
107119
expect(screen.getByRole('tabpanel', { name: 'Tab 2' })).toBeVisible()
108120
expect(screen.getByText('Content of tab 2')).toBeVisible()
109121
expect(screen.queryByText('Content of tab 3')).not.toBeInTheDocument()
110122

111123
userEvent.click(screen.getByRole('tab', { name: 'Tab 3' }))
124+
125+
await waitFor(() => {
126+
expect(screen.getByText('Content of tab 2')).not.toBeVisible()
127+
})
128+
112129
expect(screen.getByText('Content of tab 1')).not.toBeVisible()
113-
expect(screen.getByText('Content of tab 2')).not.toBeVisible()
114130
expect(screen.getByRole('tabpanel', { name: 'Tab 3' })).toBeVisible()
115131
expect(screen.getByText('Content of tab 3')).toBeVisible()
116132
})
117133

118-
it('becomes a controlled component when selectedId is provided', () => {
134+
it('becomes a controlled component when selectedId is provided', async () => {
119135
const { rerender } = render(
120136
<Tabs>
121137
<TabList aria-label="test-tabs">
@@ -149,9 +165,12 @@ describe('Tabs', () => {
149165
</Tabs>,
150166
)
151167

168+
await waitFor(() => {
169+
expect(screen.getByText('Content of tab 2')).not.toBeVisible()
170+
})
171+
152172
expect(onSelectedIdChange).not.toHaveBeenCalled()
153173
expect(screen.getByText('Content of tab 1')).not.toBeVisible()
154-
expect(screen.getByText('Content of tab 2')).not.toBeVisible()
155174
expect(screen.getByText('Content of tab 3')).toBeVisible()
156175

157176
userEvent.click(screen.getByRole('tab', { name: 'Tab 2' }))

0 commit comments

Comments
 (0)