55 */
66import {
77 NUMBER_OF_SIGNALS ,
8+ OPEN_CLOSE_SIGNALS_BTN ,
89 SELECTED_SIGNALS ,
910 SHOWING_SIGNALS ,
1011 SIGNALS ,
1112} from '../screens/detections' ;
1213
1314import {
15+ closeFirstSignal ,
1416 closeSignals ,
1517 goToClosedSignals ,
1618 goToOpenedSignals ,
@@ -26,7 +28,7 @@ import { loginAndWaitForPage } from '../tasks/login';
2628import { DETECTIONS } from '../urls/navigation' ;
2729
2830describe ( 'Detections' , ( ) => {
29- before ( ( ) => {
31+ beforeEach ( ( ) => {
3032 esArchiverLoad ( 'signals' ) ;
3133 loginAndWaitForPage ( DETECTIONS ) ;
3234 } ) ;
@@ -111,4 +113,43 @@ describe('Detections', () => {
111113 . should ( 'eql' , expectedNumberOfOpenedSignals . toString ( ) ) ;
112114 } ) ;
113115 } ) ;
116+
117+ it ( 'Closes one signal when more than one opened signals are selected' , ( ) => {
118+ waitForSignalsToBeLoaded ( ) ;
119+
120+ cy . get ( NUMBER_OF_SIGNALS )
121+ . invoke ( 'text' )
122+ . then ( numberOfSignals => {
123+ const numberOfSignalsToBeClosed = 1 ;
124+ const numberOfSignalsToBeSelected = 3 ;
125+
126+ cy . get ( OPEN_CLOSE_SIGNALS_BTN ) . should ( 'have.attr' , 'disabled' ) ;
127+ selectNumberOfSignals ( numberOfSignalsToBeSelected ) ;
128+ cy . get ( OPEN_CLOSE_SIGNALS_BTN ) . should ( 'not.have.attr' , 'disabled' ) ;
129+
130+ closeFirstSignal ( ) ;
131+ cy . reload ( ) ;
132+ waitForSignalsToBeLoaded ( ) ;
133+ waitForSignals ( ) ;
134+
135+ const expectedNumberOfSignals = + numberOfSignals - numberOfSignalsToBeClosed ;
136+ cy . get ( NUMBER_OF_SIGNALS )
137+ . invoke ( 'text' )
138+ . should ( 'eq' , expectedNumberOfSignals . toString ( ) ) ;
139+ cy . get ( SHOWING_SIGNALS )
140+ . invoke ( 'text' )
141+ . should ( 'eql' , `Showing ${ expectedNumberOfSignals . toString ( ) } signals` ) ;
142+
143+ goToClosedSignals ( ) ;
144+ waitForSignals ( ) ;
145+
146+ cy . get ( NUMBER_OF_SIGNALS )
147+ . invoke ( 'text' )
148+ . should ( 'eql' , numberOfSignalsToBeClosed . toString ( ) ) ;
149+ cy . get ( SHOWING_SIGNALS )
150+ . invoke ( 'text' )
151+ . should ( 'eql' , `Showing ${ numberOfSignalsToBeClosed . toString ( ) } signal` ) ;
152+ cy . get ( SIGNALS ) . should ( 'have.length' , numberOfSignalsToBeClosed ) ;
153+ } ) ;
154+ } ) ;
114155} ) ;
0 commit comments