@@ -27,7 +27,6 @@ import { generateId } from '../../../id_generator';
2727import { mountWithProvider } from '../../../mocks' ;
2828import { LayerTypes } from '@kbn/expression-xy-plugin/public' ;
2929import { ReactWrapper } from 'enzyme' ;
30- import { addLayer } from '../../../state_management' ;
3130import { createIndexPatternServiceMock } from '../../../mocks/data_views_service_mock' ;
3231import { AddLayerButton } from '../../../visualizations/xy/add_layer' ;
3332import { LayerType } from '@kbn/visualizations-plugin/common' ;
@@ -190,96 +189,6 @@ describe('ConfigPanel', () => {
190189 ) ;
191190 } ) ;
192191
193- describe ( 'focus behavior when adding or removing layers' , ( ) => {
194- it ( 'should focus the only layer when resetting the layer' , async ( ) => {
195- const { instance } = await prepareAndMountComponent ( getDefaultProps ( ) ) ;
196- const firstLayerFocusable = instance
197- . find ( LayerPanel )
198- . first ( )
199- . find ( 'section' )
200- . first ( )
201- . instance ( ) ;
202- act ( ( ) => {
203- instance . find ( '[data-test-subj="lnsLayerRemove--0"]' ) . first ( ) . simulate ( 'click' ) ;
204- } ) ;
205- instance . update ( ) ;
206-
207- const focusedEl = document . activeElement ;
208- expect ( focusedEl ) . toEqual ( firstLayerFocusable ) ;
209- } ) ;
210-
211- it ( 'should focus the second layer when removing the first layer' , async ( ) => {
212- const datasourceMap = mockDatasourceMap ( ) ;
213- const defaultProps = getDefaultProps ( { datasourceMap } ) ;
214- // overwriting datasourceLayers to test two layers
215- frame . datasourceLayers = {
216- first : datasourceMap . testDatasource . publicAPIMock ,
217- second : datasourceMap . testDatasource . publicAPIMock ,
218- } ;
219-
220- const { instance } = await prepareAndMountComponent ( defaultProps ) ;
221- const secondLayerFocusable = instance
222- . find ( LayerPanel )
223- . at ( 1 )
224- . find ( 'section' )
225- . first ( )
226- . instance ( ) ;
227- act ( ( ) => {
228- instance . find ( '[data-test-subj="lnsLayerRemove--0"]' ) . first ( ) . simulate ( 'click' ) ;
229- } ) ;
230- instance . update ( ) ;
231-
232- const focusedEl = document . activeElement ;
233- expect ( focusedEl ) . toEqual ( secondLayerFocusable ) ;
234- } ) ;
235-
236- it ( 'should focus the first layer when removing the second layer' , async ( ) => {
237- const datasourceMap = mockDatasourceMap ( ) ;
238- const defaultProps = getDefaultProps ( { datasourceMap } ) ;
239- // overwriting datasourceLayers to test two layers
240- frame . datasourceLayers = {
241- first : datasourceMap . testDatasource . publicAPIMock ,
242- second : datasourceMap . testDatasource . publicAPIMock ,
243- } ;
244- const { instance } = await prepareAndMountComponent ( defaultProps ) ;
245- const firstLayerFocusable = instance
246- . find ( LayerPanel )
247- . first ( )
248- . find ( 'section' )
249- . first ( )
250- . instance ( ) ;
251- act ( ( ) => {
252- instance . find ( '[data-test-subj="lnsLayerRemove--1"]' ) . first ( ) . simulate ( 'click' ) ;
253- } ) ;
254- instance . update ( ) ;
255-
256- const focusedEl = document . activeElement ;
257- expect ( focusedEl ) . toEqual ( firstLayerFocusable ) ;
258- } ) ;
259-
260- it ( 'should focus the added layer' , async ( ) => {
261- const datasourceMap = mockDatasourceMap ( ) ;
262- frame . datasourceLayers = {
263- first : datasourceMap . testDatasource . publicAPIMock ,
264- newId : datasourceMap . testDatasource . publicAPIMock ,
265- } ;
266-
267- const defaultProps = getDefaultProps ( { datasourceMap } ) ;
268-
269- const { instance } = await prepareAndMountComponent ( defaultProps , {
270- dispatch : jest . fn ( ( x ) => {
271- if ( x . type === addLayer . type ) {
272- frame . datasourceLayers . newId = datasourceMap . testDatasource . publicAPIMock ;
273- }
274- } ) ,
275- } ) ;
276-
277- addNewLayer ( instance ) ;
278- const focusedEl = document . activeElement ;
279- expect ( focusedEl ?. children [ 0 ] . getAttribute ( 'data-test-subj' ) ) . toEqual ( 'lns-layerPanel-1' ) ;
280- } ) ;
281- } ) ;
282-
283192 describe ( 'initial default value' , ( ) => {
284193 function clickToAddDimension ( instance : ReactWrapper ) {
285194 act ( ( ) => {
0 commit comments