@@ -9,7 +9,7 @@ import { fireEvent, screen, within, act } from '@testing-library/react';
99import './mocks' ;
1010import { getFollowerIndexMock } from './fixtures/follower_index' ;
1111import { setupEnvironment , pageHelpers , getRandomString } from './helpers' ;
12- import { getTableCellsValues , getTableRows } from './ helpers/eui_table ' ;
12+ import { EuiTableTestHarness } from '@kbn/test-eui- helpers' ;
1313
1414const { setup } = pageHelpers . followerIndexList ;
1515
@@ -79,13 +79,14 @@ describe('<FollowerIndicesList />', () => {
7979 } ) ;
8080
8181 test ( 'pagination works' , async ( ) => {
82- const initialRows = getTableRows ( 'followerIndexListTable' ) ;
82+ const table = new EuiTableTestHarness ( 'followerIndexListTable' ) ;
83+ const initialRows = table . rows ;
8384 expect ( initialRows . length ) . toBe ( 20 ) ; // Default page size
8485
8586 const nextButton = screen . getByLabelText ( 'Next page' ) ;
8687 fireEvent . click ( nextButton ) ;
8788
88- const rowsAfterPagination = getTableRows ( 'followerIndexListTable' ) ;
89+ const rowsAfterPagination = table . rows ;
8990 expect ( rowsAfterPagination . length ) . toBe ( 10 ) ; // Remaining items on page 2
9091 } ) ;
9192
@@ -94,12 +95,14 @@ describe('<FollowerIndicesList />', () => {
9495 fireEvent . change ( searchBox , { target : { value : 'unique' } } ) ;
9596 fireEvent . blur ( searchBox ) ;
9697
97- const rows = getTableRows ( 'followerIndexListTable' ) ;
98+ const table = new EuiTableTestHarness ( 'followerIndexListTable' ) ;
99+ const rows = table . rows ;
98100 expect ( rows . length ) . toBe ( 1 ) ;
99101 } ) ;
100102 } ) ;
101103
102104 describe ( 'when there are follower indices' , ( ) => {
105+ let table ;
103106 let tableCellsValues ;
104107 let actions ;
105108
@@ -116,7 +119,8 @@ describe('<FollowerIndicesList />', () => {
116119 await jest . runOnlyPendingTimersAsync ( ) ;
117120 } ) ;
118121
119- tableCellsValues = getTableCellsValues ( 'followerIndexListTable' ) ;
122+ table = new EuiTableTestHarness ( 'followerIndexListTable' ) ;
123+ tableCellsValues = table . cellValues ;
120124 } ) ;
121125
122126 test ( 'should not display the empty prompt' , ( ) => {
@@ -146,16 +150,14 @@ describe('<FollowerIndicesList />', () => {
146150 test ( 'should be visible when a follower index is selected' , async ( ) => {
147151 expect ( screen . queryByTestId ( 'contextMenuButton' ) ) . not . toBeInTheDocument ( ) ;
148152
149- const rows = getTableRows ( 'followerIndexListTable' ) ;
150- const firstCheckbox = within ( rows [ 0 ] ) . getByRole ( 'checkbox' ) ;
153+ const firstCheckbox = within ( table . rows [ 0 ] ) . getByRole ( 'checkbox' ) ;
151154 await user . click ( firstCheckbox ) ;
152155
153156 expect ( await screen . findByTestId ( 'contextMenuButton' ) ) . toBeInTheDocument ( ) ;
154157 } ) ;
155158
156159 test ( 'should have a "pause", "edit" and "unfollow" action when the follower index is active' , async ( ) => {
157- const rows = getTableRows ( 'followerIndexListTable' ) ;
158- const firstCheckbox = within ( rows [ 0 ] ) . getByRole ( 'checkbox' ) ;
160+ const firstCheckbox = within ( table . rows [ 0 ] ) . getByRole ( 'checkbox' ) ;
159161 await user . click ( firstCheckbox ) ;
160162
161163 const contextMenuButton = await screen . findByTestId ( 'contextMenuButton' ) ;
@@ -173,8 +175,7 @@ describe('<FollowerIndicesList />', () => {
173175 } ) ;
174176
175177 test ( 'should have a "resume", "edit" and "unfollow" action when the follower index is paused' , async ( ) => {
176- const rows = getTableRows ( 'followerIndexListTable' ) ;
177- const secondCheckbox = within ( rows [ 1 ] ) . getByRole ( 'checkbox' ) ;
178+ const secondCheckbox = within ( table . rows [ 1 ] ) . getByRole ( 'checkbox' ) ;
178179 await user . click ( secondCheckbox ) ;
179180
180181 const contextMenuButton = await screen . findByTestId ( 'contextMenuButton' ) ;
@@ -194,8 +195,7 @@ describe('<FollowerIndicesList />', () => {
194195 test ( 'should open a confirmation modal when clicking on "pause replication"' , async ( ) => {
195196 expect ( screen . queryByTestId ( 'pauseReplicationConfirmation' ) ) . not . toBeInTheDocument ( ) ;
196197
197- const rows = getTableRows ( 'followerIndexListTable' ) ;
198- const firstCheckbox = within ( rows [ 0 ] ) . getByRole ( 'checkbox' ) ;
198+ const firstCheckbox = within ( table . rows [ 0 ] ) . getByRole ( 'checkbox' ) ;
199199 await user . click ( firstCheckbox ) ;
200200
201201 const contextMenuButton = await screen . findByTestId ( 'contextMenuButton' ) ;
@@ -211,8 +211,7 @@ describe('<FollowerIndicesList />', () => {
211211 test ( 'should open a confirmation modal when clicking on "unfollow leader index"' , async ( ) => {
212212 expect ( screen . queryByTestId ( 'unfollowLeaderConfirmation' ) ) . not . toBeInTheDocument ( ) ;
213213
214- const rows = getTableRows ( 'followerIndexListTable' ) ;
215- const firstCheckbox = within ( rows [ 0 ] ) . getByRole ( 'checkbox' ) ;
214+ const firstCheckbox = within ( table . rows [ 0 ] ) . getByRole ( 'checkbox' ) ;
216215 await user . click ( firstCheckbox ) ;
217216
218217 const contextMenuButton = await screen . findByTestId ( 'contextMenuButton' ) ;
@@ -230,16 +229,14 @@ describe('<FollowerIndicesList />', () => {
230229 test ( 'should open a context menu when clicking on the button of each row' , async ( ) => {
231230 expect ( document . querySelector ( '.euiContextMenuPanel' ) ) . toBeNull ( ) ;
232231
233- const rows = getTableRows ( 'followerIndexListTable' ) ;
234- const actionButton = within ( rows [ 0 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
232+ const actionButton = within ( table . rows [ 0 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
235233 await user . click ( actionButton ) ;
236234
237235 expect ( document . querySelector ( '.euiContextMenuPanel' ) ) . not . toBeNull ( ) ;
238236 } ) ;
239237
240238 test ( 'should have the "pause", "edit" and "unfollow" options in the row context menu' , async ( ) => {
241- const rows = getTableRows ( 'followerIndexListTable' ) ;
242- const actionButton = within ( rows [ 0 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
239+ const actionButton = within ( table . rows [ 0 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
243240 await user . click ( actionButton ) ;
244241
245242 const contextMenuPanel = document . querySelector ( '.euiContextMenuPanel' ) ;
@@ -254,8 +251,7 @@ describe('<FollowerIndicesList />', () => {
254251 } ) ;
255252
256253 test ( 'should have the "resume", "edit" and "unfollow" options in the row context menu for paused index' , async ( ) => {
257- const rows = getTableRows ( 'followerIndexListTable' ) ;
258- const actionButton = within ( rows [ 1 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
254+ const actionButton = within ( table . rows [ 1 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
259255 await user . click ( actionButton ) ;
260256
261257 const contextMenuPanel = document . querySelector ( '.euiContextMenuPanel' ) ;
@@ -272,8 +268,7 @@ describe('<FollowerIndicesList />', () => {
272268 test ( 'should open a confirmation modal when clicking on "pause replication"' , async ( ) => {
273269 expect ( screen . queryByTestId ( 'pauseReplicationConfirmation' ) ) . not . toBeInTheDocument ( ) ;
274270
275- const rows = getTableRows ( 'followerIndexListTable' ) ;
276- const actionButton = within ( rows [ 0 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
271+ const actionButton = within ( table . rows [ 0 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
277272 await user . click ( actionButton ) ;
278273
279274 const pauseButton = await screen . findByTestId ( 'pauseButton' ) ;
@@ -285,8 +280,7 @@ describe('<FollowerIndicesList />', () => {
285280 test ( 'should open a confirmation modal when clicking on "resume"' , async ( ) => {
286281 expect ( screen . queryByTestId ( 'resumeReplicationConfirmation' ) ) . not . toBeInTheDocument ( ) ;
287282
288- const rows = getTableRows ( 'followerIndexListTable' ) ;
289- const actionButton = within ( rows [ 1 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
283+ const actionButton = within ( table . rows [ 1 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
290284 await user . click ( actionButton ) ;
291285
292286 const resumeButton = await screen . findByTestId ( 'resumeButton' ) ;
@@ -298,8 +292,7 @@ describe('<FollowerIndicesList />', () => {
298292 test ( 'should open a confirmation modal when clicking on "unfollow leader index"' , async ( ) => {
299293 expect ( screen . queryByTestId ( 'unfollowLeaderConfirmation' ) ) . not . toBeInTheDocument ( ) ;
300294
301- const rows = getTableRows ( 'followerIndexListTable' ) ;
302- const actionButton = within ( rows [ 0 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
295+ const actionButton = within ( table . rows [ 0 ] ) . getByTestId ( 'euiCollapsedItemActionsButton' ) ;
303296 await user . click ( actionButton ) ;
304297
305298 const unfollowButton = await screen . findByTestId ( 'unfollowButton' ) ;
@@ -313,8 +306,7 @@ describe('<FollowerIndicesList />', () => {
313306 test ( 'should open a detail panel when clicking on a follower index' , async ( ) => {
314307 expect ( screen . queryByTestId ( 'followerIndexDetail' ) ) . not . toBeInTheDocument ( ) ;
315308
316- const rows = getTableRows ( 'followerIndexListTable' ) ;
317- const nameLink = within ( rows [ 0 ] ) . getByText ( index1 . name ) ;
309+ const nameLink = within ( table . rows [ 0 ] ) . getByText ( index1 . name ) ;
318310 await user . click ( nameLink ) ;
319311
320312 expect ( await screen . findByTestId ( 'followerIndexDetail' ) ) . toBeInTheDocument ( ) ;
0 commit comments