File tree Expand file tree Collapse file tree
x-pack/plugins/data_enhanced/public/search/sessions_mgmt/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ describe('Search Sessions Management API', () => {
168168
169169 describe ( 'extend' , ( ) => {
170170 beforeEach ( ( ) => {
171- sessionsClient . find = jest . fn ( ) . mockImplementation ( async ( ) => {
171+ sessionsClient . extend = jest . fn ( ) . mockImplementation ( async ( ) => {
172172 return {
173173 saved_objects : [
174174 {
@@ -188,6 +188,20 @@ describe('Search Sessions Management API', () => {
188188 } ) ;
189189 await api . sendExtend ( 'my-id' , '5d' ) ;
190190
191+ expect ( sessionsClient . extend ) . toHaveBeenCalledTimes ( 1 ) ;
192+ expect ( mockCoreStart . notifications . toasts . addSuccess ) . toHaveBeenCalled ( ) ;
193+ } ) ;
194+
195+ test ( 'displays error on reject' , async ( ) => {
196+ sessionsClient . extend = jest . fn ( ) . mockRejectedValue ( { } ) ;
197+ const api = new SearchSessionsMgmtAPI ( sessionsClient , mockConfig , {
198+ urls : mockUrls ,
199+ notifications : mockCoreStart . notifications ,
200+ application : mockCoreStart . application ,
201+ } ) ;
202+ await api . sendExtend ( 'my-id' , '5d' ) ;
203+
204+ expect ( sessionsClient . extend ) . toHaveBeenCalledTimes ( 1 ) ;
191205 expect ( mockCoreStart . notifications . toasts . addError ) . toHaveBeenCalled ( ) ;
192206 } ) ;
193207 } ) ;
Original file line number Diff line number Diff line change @@ -166,9 +166,6 @@ export class SearchSessionsMgmtAPI {
166166 } ) ,
167167 } ) ;
168168 } catch ( err ) {
169- // eslint-disable-next-line no-console
170- console . error ( err ) ;
171-
172169 this . deps . notifications . toasts . addError ( err , {
173170 title : i18n . translate ( 'xpack.data.mgmt.searchSessions.api.deletedError' , {
174171 defaultMessage : 'Failed to delete the search session!' ,
@@ -188,9 +185,6 @@ export class SearchSessionsMgmtAPI {
188185 } ) ,
189186 } ) ;
190187 } catch ( err ) {
191- // eslint-disable-next-line no-console
192- console . error ( err ) ;
193-
194188 this . deps . notifications . toasts . addError ( err , {
195189 title : i18n . translate ( 'xpack.data.mgmt.searchSessions.api.extendError' , {
196190 defaultMessage : 'Failed to extend the search session!' ,
You can’t perform that action at this time.
0 commit comments