@@ -2,11 +2,10 @@ import {render as HTMLRender, fireEvent} from '@testing-library/react'
22import { axe } from 'jest-axe'
33import React , { useCallback , useRef , useState } from 'react'
44
5- import { ActionMenu } from '../ActionMenu'
6- import { ActionList } from '../ActionList'
5+ import { ActionMenu } from '../deprecated/ActionMenu'
76import BaseStyles from '../BaseStyles'
87import Box from '../Box'
9- import { Button } from '../Button'
8+ import Button from '../deprecated/Button /Button'
109import { ConfirmationDialog , useConfirm } from '../Dialog/ConfirmationDialog'
1110import theme from '../theme'
1211import { ThemeProvider } from '../ThemeProvider'
@@ -63,14 +62,10 @@ const ShorthandHookFromActionMenu = () => {
6362 < SSRProvider >
6463 < BaseStyles >
6564 < Box display = "flex" flexDirection = "column" alignItems = "flex-start" >
66- < ActionMenu >
67- < ActionMenu . Button > { text } </ ActionMenu . Button >
68- < ActionMenu . Overlay >
69- < ActionList >
70- < ActionList . Item onSelect = { onButtonClick } > Show dialog</ ActionList . Item >
71- </ ActionList >
72- </ ActionMenu . Overlay >
73- </ ActionMenu >
65+ < ActionMenu
66+ renderAnchor = { props => < Button { ...props } > { text } </ Button > }
67+ items = { [ { text : 'Show dialog' , onAction : onButtonClick } ] }
68+ />
7469 </ Box >
7570 </ BaseStyles >
7671 </ SSRProvider >
@@ -100,36 +95,36 @@ describe('ConfirmationDialog', () => {
10095 } )
10196
10297 it ( 'focuses the primary action when opened and the confirmButtonType is not set' , async ( ) => {
103- const { getByText, getByRole } = HTMLRender ( < Basic /> )
98+ const { getByText} = HTMLRender ( < Basic /> )
10499 fireEvent . click ( getByText ( 'Show dialog' ) )
105- expect ( getByRole ( 'button' , { name : ' Primary'} ) ) . toEqual ( document . activeElement )
100+ expect ( getByText ( ' Primary') ) . toEqual ( document . activeElement )
106101 expect ( getByText ( 'Secondary' ) ) . not . toEqual ( document . activeElement )
107102 } )
108103
109104 it ( 'focuses the primary action when opened and the confirmButtonType is not danger' , async ( ) => {
110- const { getByText, getByRole } = HTMLRender ( < Basic confirmButtonType = "primary" /> )
105+ const { getByText} = HTMLRender ( < Basic confirmButtonType = "primary" /> )
111106 fireEvent . click ( getByText ( 'Show dialog' ) )
112- expect ( getByRole ( 'button' , { name : ' Primary'} ) ) . toEqual ( document . activeElement )
107+ expect ( getByText ( ' Primary') ) . toEqual ( document . activeElement )
113108 expect ( getByText ( 'Secondary' ) ) . not . toEqual ( document . activeElement )
114109 } )
115110
116111 it ( 'focuses the secondary action when opened and the confirmButtonType is danger' , async ( ) => {
117- const { getByText, getByRole } = HTMLRender ( < Basic confirmButtonType = "danger" /> )
112+ const { getByText} = HTMLRender ( < Basic confirmButtonType = "danger" /> )
118113 fireEvent . click ( getByText ( 'Show dialog' ) )
119- expect ( getByRole ( 'button' , { name : ' Primary'} ) ) . not . toEqual ( document . activeElement )
120- expect ( getByRole ( 'button' , { name : ' Secondary'} ) ) . toEqual ( document . activeElement )
114+ expect ( getByText ( ' Primary') ) . not . toEqual ( document . activeElement )
115+ expect ( getByText ( ' Secondary') ) . toEqual ( document . activeElement )
121116 } )
122117
123118 it ( 'supports nested `focusTrap`s' , async ( ) => {
124119 const spy = jest . spyOn ( console , 'error' ) . mockImplementationOnce ( ( ) => { } )
125120
126- const { getByText, getByRole } = HTMLRender ( < ShorthandHookFromActionMenu /> )
121+ const { getByText} = HTMLRender ( < ShorthandHookFromActionMenu /> )
127122
128123 fireEvent . click ( getByText ( 'Show menu' ) )
129124 fireEvent . click ( getByText ( 'Show dialog' ) )
130125
131- expect ( getByRole ( 'button' , { name : ' Primary'} ) ) . toEqual ( document . activeElement )
132- expect ( getByRole ( 'button' , { name : ' Secondary'} ) ) . not . toEqual ( document . activeElement )
126+ expect ( getByText ( ' Primary') ) . toEqual ( document . activeElement )
127+ expect ( getByText ( ' Secondary') ) . not . toEqual ( document . activeElement )
133128
134129 // REACT_VERSION_LATEST should be treated as a constant for the test
135130 // environment
0 commit comments