@@ -79,9 +79,10 @@ describe('VersionUpdate', () => {
7979
8080 await fireEvent . change ( screen . getByRole ( 'combobox' ) , { target : { value : '2.0.0' } } ) ;
8181
82- const [ moreLink , checkBtn , updateBtnDisabled ] = screen . getAllByRole ( 'button' ) ;
82+ const [ moreLink , checkBtn , cancelBtn , updateBtnDisabled ] = screen . getAllByRole ( 'button' ) ;
8383 expect ( moreLink . textContent ) . eq ( 'more' ) ;
8484 expect ( checkBtn . textContent ) . eq ( 'Check' ) ;
85+ expect ( cancelBtn . textContent ) . eq ( 'Cancel' ) ;
8586 expect ( updateBtnDisabled . textContent ) . eq ( 'Update' ) ;
8687 expect ( updateBtnDisabled . disabled ) . eq ( true ) ;
8788
@@ -100,11 +101,38 @@ describe('VersionUpdate', () => {
100101 } ) ;
101102 await fireEvent . click ( checkBtn ) ;
102103
103- const updateBtnEnabled = screen . getAllByRole ( 'button' ) [ 1 ] ;
104+ const updateBtnEnabled = screen . getAllByRole ( 'button' ) [ 2 ] ;
104105 expect ( updateBtnEnabled . textContent ) . eq ( 'Update' ) ;
105106 expect ( updateBtnEnabled . disabled ) . eq ( false ) ;
106107 } ) ;
107108
109+ it ( 'use the cancel button when fixing the arguments' , async ( ) => {
110+ const task = getTask ( 'My Task' , '1.2.4' ) ;
111+ const versions = await checkVersions ( task , 1 , { changed_property : 'x' } ) ;
112+ expect ( versions [ 0 ] ) . toBe ( '2.0.0' ) ;
113+
114+ await fireEvent . change ( screen . getByRole ( 'combobox' ) , { target : { value : '2.0.0' } } ) ;
115+
116+ expect ( screen . getByRole ( 'textbox' ) . value ) . eq (
117+ JSON . stringify ( { changed_property : 'x' } , null , 2 )
118+ ) ;
119+
120+ const cancelBtnDisabled = screen . getByRole ( 'button' , { name : 'Cancel' } ) ;
121+ expect ( cancelBtnDisabled . disabled ) . eq ( true ) ;
122+
123+ await fireEvent . input ( screen . getByRole ( 'textbox' ) , {
124+ target : { value : '{"changed_property": "y"}' }
125+ } ) ;
126+
127+ const cancelBtnEnabled = screen . getByRole ( 'button' , { name : 'Cancel' } ) ;
128+ expect ( cancelBtnEnabled . disabled ) . eq ( false ) ;
129+ await fireEvent . click ( cancelBtnEnabled ) ;
130+
131+ expect ( screen . getByRole ( 'textbox' ) . value ) . eq (
132+ JSON . stringify ( { changed_property : 'x' } , null , 2 )
133+ ) ;
134+ } ) ;
135+
108136 it ( 'trying to fix the arguments with invalid JSON' , async ( ) => {
109137 const task = getTask ( 'My Task' , '1.2.4' ) ;
110138 const versions = await checkVersions ( task , 1 ) ;
0 commit comments