@@ -58,7 +58,7 @@ describe('AnomalyResultsTable', () => {
58
58
59
59
const defaultProps = {
60
60
anomalies : mockAnomalies ,
61
- detectorIndex : [ 'test-index' ] ,
61
+ detectorIndices : [ 'test-index' , 'followCluster: test-index'] ,
62
62
detectorTimeField : 'timestamp' ,
63
63
} ;
64
64
@@ -151,6 +151,33 @@ describe('AnomalyResultsTable', () => {
151
151
}
152
152
} ) ;
153
153
154
+ it ( 'creates new index pattern when none exists' , async ( ) => {
155
+ const mockCreate = jest . fn ( ) . mockResolvedValue ( { id : 'new-index-pattern-id' } ) ;
156
+ ( getSavedObjectsClient as jest . Mock ) . mockReturnValue ( {
157
+ find : jest . fn ( ) . mockResolvedValue ( { savedObjects : [ ] } ) ,
158
+ create : mockCreate ,
159
+ } ) ;
160
+
161
+ const { container } = renderWithContext ( < AnomalyResultsTable { ...defaultProps } /> ) ;
162
+
163
+ const discoverButton = container . querySelector ( '[data-test-subj="discoverIcon"]' ) ;
164
+ if ( discoverButton ) {
165
+ fireEvent . click ( discoverButton ) ;
166
+
167
+ await waitFor ( ( ) => {
168
+ expect ( mockCreate ) . toHaveBeenCalledWith ( 'index-pattern' , {
169
+ title : 'test-index,followCluster:test-index' ,
170
+ timeFieldName : 'timestamp' ,
171
+ } ) ;
172
+ } ) ;
173
+
174
+ const notifications = getNotifications ( ) ;
175
+ expect ( notifications . toasts . addSuccess ) . toHaveBeenCalledWith (
176
+ expect . stringContaining ( 'Created new index pattern: test-index,followCluster:test-index' )
177
+ ) ;
178
+ }
179
+ } ) ;
180
+
154
181
describe ( 'mds feature flag' , ( ) => {
155
182
it ( 'shows Actions column when mds is disabled' , ( ) => {
156
183
( getDataSourceEnabled as jest . Mock ) . mockReturnValue ( { enabled : false } ) ;
0 commit comments