@@ -9,6 +9,7 @@ import { cloneDeep } from 'lodash/fp';
99import { mountWithIntl } from 'test_utils/enzyme_helpers' ;
1010import React from 'react' ;
1111import { ThemeProvider } from 'styled-components' ;
12+ import { act } from '@testing-library/react' ;
1213
1314import '../../../common/mock/match_media' ;
1415import { DEFAULT_SEARCH_RESULTS_PER_PAGE } from '../../pages/timelines_page' ;
@@ -51,7 +52,7 @@ describe('OpenTimeline', () => {
5152 title,
5253 timelineType : TimelineType . default ,
5354 timelineStatus : TimelineStatus . active ,
54- templateTimelineFilter : [ < div /> ] ,
55+ templateTimelineFilter : [ < div key = "mock-a" /> , < div key = "mock-b" /> ] ,
5556 totalSearchResultsCount : mockSearchResults . length ,
5657 } ) ;
5758
@@ -279,6 +280,86 @@ describe('OpenTimeline', () => {
279280 expect ( wrapper . find ( '[data-test-subj="utility-bar-action"]' ) . exists ( ) ) . toEqual ( true ) ;
280281 } ) ;
281282
283+ test ( 'it should disable export-timeline if no timeline is selected' , async ( ) => {
284+ const defaultProps = {
285+ ...getDefaultTestProps ( mockResults ) ,
286+ timelineStatus : null ,
287+ selectedItems : [ ] ,
288+ } ;
289+ const wrapper = mountWithIntl (
290+ < ThemeProvider theme = { theme } >
291+ < OpenTimeline { ...defaultProps } />
292+ </ ThemeProvider >
293+ ) ;
294+
295+ wrapper . find ( '[data-test-subj="utility-bar-action"]' ) . find ( 'EuiLink' ) . simulate ( 'click' ) ;
296+ await act ( async ( ) => {
297+ expect (
298+ wrapper . find ( '[data-test-subj="export-timeline-action"]' ) . first ( ) . prop ( 'disabled' )
299+ ) . toEqual ( true ) ;
300+ } ) ;
301+ } ) ;
302+
303+ test ( 'it should disable delete timeline if no timeline is selected' , async ( ) => {
304+ const defaultProps = {
305+ ...getDefaultTestProps ( mockResults ) ,
306+ timelineStatus : null ,
307+ selectedItems : [ ] ,
308+ } ;
309+ const wrapper = mountWithIntl (
310+ < ThemeProvider theme = { theme } >
311+ < OpenTimeline { ...defaultProps } />
312+ </ ThemeProvider >
313+ ) ;
314+
315+ wrapper . find ( '[data-test-subj="utility-bar-action"]' ) . find ( 'EuiLink' ) . simulate ( 'click' ) ;
316+ await act ( async ( ) => {
317+ expect (
318+ wrapper . find ( '[data-test-subj="delete-timeline-action"]' ) . first ( ) . prop ( 'disabled' )
319+ ) . toEqual ( true ) ;
320+ } ) ;
321+ } ) ;
322+
323+ test ( 'it should enable export-timeline if a timeline is selected' , async ( ) => {
324+ const defaultProps = {
325+ ...getDefaultTestProps ( mockResults ) ,
326+ timelineStatus : null ,
327+ selectedItems : [ { } ] ,
328+ } ;
329+ const wrapper = mountWithIntl (
330+ < ThemeProvider theme = { theme } >
331+ < OpenTimeline { ...defaultProps } />
332+ </ ThemeProvider >
333+ ) ;
334+
335+ wrapper . find ( '[data-test-subj="utility-bar-action"]' ) . find ( 'EuiLink' ) . simulate ( 'click' ) ;
336+ await act ( async ( ) => {
337+ expect (
338+ wrapper . find ( '[data-test-subj="export-timeline-action"]' ) . first ( ) . prop ( 'disabled' )
339+ ) . toEqual ( false ) ;
340+ } ) ;
341+ } ) ;
342+
343+ test ( 'it should enable delete timeline if a timeline is selected' , async ( ) => {
344+ const defaultProps = {
345+ ...getDefaultTestProps ( mockResults ) ,
346+ timelineStatus : null ,
347+ selectedItems : [ { } ] ,
348+ } ;
349+ const wrapper = mountWithIntl (
350+ < ThemeProvider theme = { theme } >
351+ < OpenTimeline { ...defaultProps } />
352+ </ ThemeProvider >
353+ ) ;
354+
355+ wrapper . find ( '[data-test-subj="utility-bar-action"]' ) . find ( 'EuiLink' ) . simulate ( 'click' ) ;
356+ await act ( async ( ) => {
357+ expect (
358+ wrapper . find ( '[data-test-subj="delete-timeline-action"]' ) . first ( ) . prop ( 'disabled' )
359+ ) . toEqual ( false ) ;
360+ } ) ;
361+ } ) ;
362+
282363 test ( "it should render a selectable timeline table if timelineStatus is active (selecting custom templates' tab)" , ( ) => {
283364 const defaultProps = {
284365 ...getDefaultTestProps ( mockResults ) ,
0 commit comments