@@ -40,6 +40,7 @@ const expectActionButtonsExists = () => {
4040 expect ( screen . getByText ( 'Restart Connector' ) ) . toBeInTheDocument ( ) ;
4141 expect ( screen . getByText ( 'Restart All Tasks' ) ) . toBeInTheDocument ( ) ;
4242 expect ( screen . getByText ( 'Restart Failed Tasks' ) ) . toBeInTheDocument ( ) ;
43+ expect ( screen . getByText ( 'Reset Offsets' ) ) . toBeInTheDocument ( ) ;
4344 expect ( screen . getByText ( 'Delete' ) ) . toBeInTheDocument ( ) ;
4445} ;
4546const afterClickDropDownButton = async ( ) => {
@@ -82,6 +83,7 @@ describe('Actions', () => {
8283 expect ( screen . getAllByRole ( 'menuitem' ) . length ) . toEqual ( 4 ) ;
8384 expect ( screen . getByText ( 'Resume' ) ) . toBeInTheDocument ( ) ;
8485 expect ( screen . queryByText ( 'Pause' ) ) . not . toBeInTheDocument ( ) ;
86+ expect ( screen . queryByText ( 'Stop' ) ) . not . toBeInTheDocument ( ) ;
8587 expectActionButtonsExists ( ) ;
8688 } ) ;
8789
@@ -94,6 +96,7 @@ describe('Actions', () => {
9496 expect ( screen . getAllByRole ( 'menuitem' ) . length ) . toEqual ( 3 ) ;
9597 expect ( screen . queryByText ( 'Resume' ) ) . not . toBeInTheDocument ( ) ;
9698 expect ( screen . queryByText ( 'Pause' ) ) . not . toBeInTheDocument ( ) ;
99+ expect ( screen . queryByText ( 'Stop' ) ) . not . toBeInTheDocument ( ) ;
97100 expectActionButtonsExists ( ) ;
98101 } ) ;
99102
@@ -106,6 +109,7 @@ describe('Actions', () => {
106109 expect ( screen . getAllByRole ( 'menuitem' ) . length ) . toEqual ( 3 ) ;
107110 expect ( screen . queryByText ( 'Resume' ) ) . not . toBeInTheDocument ( ) ;
108111 expect ( screen . queryByText ( 'Pause' ) ) . not . toBeInTheDocument ( ) ;
112+ expect ( screen . queryByText ( 'Stop' ) ) . not . toBeInTheDocument ( ) ;
109113 expectActionButtonsExists ( ) ;
110114 } ) ;
111115
@@ -118,6 +122,7 @@ describe('Actions', () => {
118122 expect ( screen . getAllByRole ( 'menuitem' ) . length ) . toEqual ( 4 ) ;
119123 expect ( screen . queryByText ( 'Resume' ) ) . not . toBeInTheDocument ( ) ;
120124 expect ( screen . getByText ( 'Pause' ) ) . toBeInTheDocument ( ) ;
125+ expect ( screen . getByText ( 'Stop' ) ) . toBeInTheDocument ( ) ;
121126 expectActionButtonsExists ( ) ;
122127 } ) ;
123128
@@ -137,6 +142,15 @@ describe('Actions', () => {
137142 expect ( screen . getByRole ( 'dialog' ) ) . toBeInTheDocument ( ) ;
138143 } ) ;
139144
145+ it ( 'opens confirmation modal when reset offsets button clicked' , async ( ) => {
146+ renderComponent ( ) ;
147+ await afterClickDropDownButton ( ) ;
148+ await waitFor ( async ( ) =>
149+ userEvent . click ( screen . getByRole ( 'menuitem' , { name : 'Reset Offsets' } ) )
150+ ) ;
151+ expect ( screen . getByRole ( 'dialog' ) ) . toBeInTheDocument ( ) ;
152+ } ) ;
153+
140154 it ( 'calls restartConnector when restart button clicked' , async ( ) => {
141155 const restartConnector = jest . fn ( ) ;
142156 ( useUpdateConnectorState as jest . Mock ) . mockImplementation ( ( ) => ( {
@@ -191,7 +205,18 @@ describe('Actions', () => {
191205 expect ( pauseConnector ) . toHaveBeenCalledWith ( ConnectorAction . PAUSE ) ;
192206 } ) ;
193207
194- it ( 'calls resumeConnector when resume button clicked' , async ( ) => {
208+ it ( 'calls stopConnector when stop button clicked' , async ( ) => {
209+ const stopConnector = jest . fn ( ) ;
210+ ( useUpdateConnectorState as jest . Mock ) . mockImplementation ( ( ) => ( {
211+ mutateAsync : stopConnector ,
212+ } ) ) ;
213+ renderComponent ( ) ;
214+ await afterClickRestartButton ( ) ;
215+ await userEvent . click ( screen . getByRole ( 'menuitem' , { name : 'Stop' } ) ) ;
216+ expect ( stopConnector ) . toHaveBeenCalledWith ( ConnectorAction . STOP ) ;
217+ } ) ;
218+
219+ it ( 'calls resumeConnector when resume button clicked from PAUSED state' , async ( ) => {
195220 const resumeConnector = jest . fn ( ) ;
196221 ( useConnector as jest . Mock ) . mockImplementation ( ( ) => ( {
197222 data : setConnectorStatus ( connector , ConnectorState . PAUSED ) ,
@@ -204,6 +229,20 @@ describe('Actions', () => {
204229 await userEvent . click ( screen . getByRole ( 'menuitem' , { name : 'Resume' } ) ) ;
205230 expect ( resumeConnector ) . toHaveBeenCalledWith ( ConnectorAction . RESUME ) ;
206231 } ) ;
232+
233+ it ( 'calls resumeConnector when resume button clicked from STOPPED state' , async ( ) => {
234+ const resumeConnector = jest . fn ( ) ;
235+ ( useConnector as jest . Mock ) . mockImplementation ( ( ) => ( {
236+ data : setConnectorStatus ( connector , ConnectorState . STOPPED ) ,
237+ } ) ) ;
238+ ( useUpdateConnectorState as jest . Mock ) . mockImplementation ( ( ) => ( {
239+ mutateAsync : resumeConnector ,
240+ } ) ) ;
241+ renderComponent ( ) ;
242+ await afterClickRestartButton ( ) ;
243+ await userEvent . click ( screen . getByRole ( 'menuitem' , { name : 'Resume' } ) ) ;
244+ expect ( resumeConnector ) . toHaveBeenCalledWith ( ConnectorAction . RESUME ) ;
245+ } ) ;
207246 } ) ;
208247 } ) ;
209248} ) ;
0 commit comments