@@ -13,7 +13,7 @@ import React from 'react';
13
13
import { render , screen , fireEvent , waitFor } from '@testing-library/react' ;
14
14
import '@testing-library/jest-dom' ;
15
15
import { AnomalyResultsTable } from '../containers/AnomalyResultsTable' ;
16
- import { getSavedObjectsClient , getNotifications } from '../../../services' ;
16
+ import { getSavedObjectsClient , getNotifications , getDataSourceEnabled } from '../../../services' ;
17
17
import { CoreServicesContext } from '../../../components/CoreServices/CoreServices' ;
18
18
19
19
const mockWindowOpen = jest . fn ( ) ;
@@ -25,6 +25,7 @@ Object.defineProperty(window, 'open', {
25
25
jest . mock ( '../../../services' , ( ) => ( {
26
26
getSavedObjectsClient : jest . fn ( ) ,
27
27
getNotifications : jest . fn ( ) ,
28
+ getDataSourceEnabled : jest . fn ( ) ,
28
29
} ) ) ;
29
30
30
31
const mockCoreServices = {
@@ -75,6 +76,8 @@ describe('AnomalyResultsTable', () => {
75
76
addDanger : jest . fn ( ) ,
76
77
} ,
77
78
} ) ;
79
+
80
+ ( getDataSourceEnabled as jest . Mock ) . mockReturnValue ( { enabled : false } ) ;
78
81
} ) ;
79
82
80
83
it ( 'shows no anomalies message when there are no anomalies' , ( ) => {
@@ -168,4 +171,30 @@ describe('AnomalyResultsTable', () => {
168
171
} ) ;
169
172
}
170
173
} ) ;
174
+
175
+ describe ( 'mds feature flag' , ( ) => {
176
+ it ( 'shows Actions column when mds is disabled' , ( ) => {
177
+ ( getDataSourceEnabled as jest . Mock ) . mockReturnValue ( { enabled : false } ) ;
178
+
179
+ renderWithContext ( < AnomalyResultsTable { ...defaultProps } /> ) ;
180
+
181
+ const actionsColumn = screen . getByText ( 'Actions' ) ;
182
+ expect ( actionsColumn ) . toBeInTheDocument ( ) ;
183
+
184
+ const discoverButton = screen . getByTestId ( 'discoverIcon' ) ;
185
+ expect ( discoverButton ) . toBeInTheDocument ( ) ;
186
+ } ) ;
187
+
188
+ it ( 'hides Actions column when mds is enabled' , ( ) => {
189
+ ( getDataSourceEnabled as jest . Mock ) . mockReturnValue ( { enabled : true } ) ;
190
+
191
+ renderWithContext ( < AnomalyResultsTable { ...defaultProps } /> ) ;
192
+
193
+ const actionsColumn = screen . queryByText ( 'Actions' ) ;
194
+ expect ( actionsColumn ) . not . toBeInTheDocument ( ) ;
195
+
196
+ const discoverButton = screen . queryByTestId ( 'discoverIcon' ) ;
197
+ expect ( discoverButton ) . not . toBeInTheDocument ( ) ;
198
+ } ) ;
199
+ } ) ;
171
200
} ) ;
0 commit comments