@@ -16,6 +16,8 @@ import { chartPluginMock } from '../../../../../../../../src/plugins/charts/publ
1616import { dataPluginMock } from '../../../../../../../../src/plugins/data/public/mocks' ;
1717import { alertingPluginMock } from '../../../../../../alerts/public/mocks' ;
1818import { featuresPluginMock } from '../../../../../../features/public/mocks' ;
19+ import { ActionConnector } from '../../../../types' ;
20+ import { times } from 'lodash' ;
1921
2022jest . mock ( '../../../lib/action_connector_api' , ( ) => ( {
2123 loadAllActions : jest . fn ( ) ,
@@ -109,36 +111,38 @@ describe('actions_connectors_list component empty', () => {
109111describe ( 'actions_connectors_list component with items' , ( ) => {
110112 let wrapper : ReactWrapper < any > ;
111113
112- async function setup ( ) {
114+ async function setup ( actionConnectors ?: ActionConnector [ ] ) {
113115 const { loadAllActions, loadActionTypes } = jest . requireMock (
114116 '../../../lib/action_connector_api'
115117 ) ;
116- loadAllActions . mockResolvedValueOnce ( [
117- {
118- id : '1' ,
119- actionTypeId : 'test' ,
120- description : 'My test' ,
121- isPreconfigured : false ,
122- referencedByCount : 1 ,
123- config : { } ,
124- } ,
125- {
126- id : '2' ,
127- actionTypeId : 'test2' ,
128- description : 'My test 2' ,
129- referencedByCount : 1 ,
130- isPreconfigured : false ,
131- config : { } ,
132- } ,
133- {
134- id : '3' ,
135- actionTypeId : 'test2' ,
136- description : 'My preconfigured test 2' ,
137- referencedByCount : 1 ,
138- isPreconfigured : true ,
139- config : { } ,
140- } ,
141- ] ) ;
118+ loadAllActions . mockResolvedValueOnce (
119+ actionConnectors ?? [
120+ {
121+ id : '1' ,
122+ actionTypeId : 'test' ,
123+ description : 'My test' ,
124+ isPreconfigured : false ,
125+ referencedByCount : 1 ,
126+ config : { } ,
127+ } ,
128+ {
129+ id : '2' ,
130+ actionTypeId : 'test2' ,
131+ description : 'My test 2' ,
132+ referencedByCount : 1 ,
133+ isPreconfigured : false ,
134+ config : { } ,
135+ } ,
136+ {
137+ id : '3' ,
138+ actionTypeId : 'test2' ,
139+ description : 'My preconfigured test 2' ,
140+ referencedByCount : 1 ,
141+ isPreconfigured : true ,
142+ config : { } ,
143+ } ,
144+ ]
145+ ) ;
142146 loadActionTypes . mockResolvedValueOnce ( [
143147 {
144148 id : 'test' ,
@@ -217,6 +221,36 @@ describe('actions_connectors_list component with items', () => {
217221 expect ( wrapper . find ( '[data-test-subj="preConfiguredTitleMessage"]' ) ) . toHaveLength ( 2 ) ;
218222 } ) ;
219223
224+ it ( 'supports pagination' , async ( ) => {
225+ await setup (
226+ times ( 15 , ( index ) => ( {
227+ id : `connector${ index } ` ,
228+ actionTypeId : 'test' ,
229+ name : `My test ${ index } ` ,
230+ secrets : { } ,
231+ description : `My test ${ index } ` ,
232+ isPreconfigured : false ,
233+ referencedByCount : 1 ,
234+ config : { } ,
235+ } ) )
236+ ) ;
237+ expect ( wrapper . find ( '[data-test-subj="actionsTable"]' ) . first ( ) . prop ( 'pagination' ) )
238+ . toMatchInlineSnapshot ( `
239+ Object {
240+ "initialPageIndex": 0,
241+ "pageIndex": 0,
242+ }
243+ ` ) ;
244+ wrapper . find ( '[data-test-subj="pagination-button-1"]' ) . first ( ) . simulate ( 'click' ) ;
245+ expect ( wrapper . find ( '[data-test-subj="actionsTable"]' ) . first ( ) . prop ( 'pagination' ) )
246+ . toMatchInlineSnapshot ( `
247+ Object {
248+ "initialPageIndex": 0,
249+ "pageIndex": 1,
250+ }
251+ ` ) ;
252+ } ) ;
253+
220254 test ( 'if select item for edit should render ConnectorEditFlyout' , async ( ) => {
221255 await setup ( ) ;
222256 await wrapper . find ( '[data-test-subj="edit1"]' ) . first ( ) . simulate ( 'click' ) ;
0 commit comments