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 } ) ;
@@ -53,6 +55,7 @@ describe('Detections', () => {
5355 waitForSignals ( ) ;
5456 cy . reload ( ) ;
5557 waitForSignals ( ) ;
58+ waitForSignalsToBeLoaded ( ) ;
5659
5760 const expectedNumberOfSignalsAfterClosing = + numberOfSignals - numberOfSignalsToBeClosed ;
5861 cy . get ( NUMBER_OF_SIGNALS )
@@ -111,4 +114,43 @@ describe('Detections', () => {
111114 . should ( 'eql' , expectedNumberOfOpenedSignals . toString ( ) ) ;
112115 } ) ;
113116 } ) ;
117+
118+ it ( 'Closes one signal when more than one opened signals are selected' , ( ) => {
119+ waitForSignalsToBeLoaded ( ) ;
120+
121+ cy . get ( NUMBER_OF_SIGNALS )
122+ . invoke ( 'text' )
123+ . then ( numberOfSignals => {
124+ const numberOfSignalsToBeClosed = 1 ;
125+ const numberOfSignalsToBeSelected = 3 ;
126+
127+ cy . get ( OPEN_CLOSE_SIGNALS_BTN ) . should ( 'have.attr' , 'disabled' ) ;
128+ selectNumberOfSignals ( numberOfSignalsToBeSelected ) ;
129+ cy . get ( OPEN_CLOSE_SIGNALS_BTN ) . should ( 'not.have.attr' , 'disabled' ) ;
130+
131+ closeFirstSignal ( ) ;
132+ cy . reload ( ) ;
133+ waitForSignalsToBeLoaded ( ) ;
134+ waitForSignals ( ) ;
135+
136+ const expectedNumberOfSignals = + numberOfSignals - numberOfSignalsToBeClosed ;
137+ cy . get ( NUMBER_OF_SIGNALS )
138+ . invoke ( 'text' )
139+ . should ( 'eq' , expectedNumberOfSignals . toString ( ) ) ;
140+ cy . get ( SHOWING_SIGNALS )
141+ . invoke ( 'text' )
142+ . should ( 'eql' , `Showing ${ expectedNumberOfSignals . toString ( ) } signals` ) ;
143+
144+ goToClosedSignals ( ) ;
145+ waitForSignals ( ) ;
146+
147+ cy . get ( NUMBER_OF_SIGNALS )
148+ . invoke ( 'text' )
149+ . should ( 'eql' , numberOfSignalsToBeClosed . toString ( ) ) ;
150+ cy . get ( SHOWING_SIGNALS )
151+ . invoke ( 'text' )
152+ . should ( 'eql' , `Showing ${ numberOfSignalsToBeClosed . toString ( ) } signal` ) ;
153+ cy . get ( SIGNALS ) . should ( 'have.length' , numberOfSignalsToBeClosed ) ;
154+ } ) ;
155+ } ) ;
114156} ) ;
0 commit comments