@@ -146,13 +146,20 @@ define(function (require, exports, module) {
146146 $ ( ".check-all" ) . click ( ) ;
147147 await awaitsFor ( ( ) => {
148148 const checkboxes = document . querySelectorAll ( ".check-one" ) ;
149- return Array . from ( checkboxes ) . every ( checkbox => checkbox . checked ) ;
149+ const commitIsDisabled = $ ( ".git-commit" ) . prop ( "disabled" ) ;
150+ return Array . from ( checkboxes ) . every ( checkbox => checkbox . checked ) && ! commitIsDisabled ;
150151 } , "All files to be staged for commit" , 10000 ) ;
151152 }
152153 $ ( ".git-commit" ) . click ( ) ;
153154 await __PR . waitForModalDialog ( "#git-commit-dialog" ) ;
154155 }
155156
157+ async function commmitDlgWithMessage ( message ) {
158+ $ ( "input[name='commit-message']" ) . val ( message ) ;
159+ __PR . clickDialogButtonID ( __PR . Dialogs . DIALOG_BTN_OK ) ;
160+ await __PR . waitForModalDialogClosed ( "#git-commit-dialog" ) ;
161+ }
162+
156163 function expectTextToContain ( srcText , list ) {
157164 const nonEmptyLines = srcText
158165 . split ( "\n" ) // Split the text into lines
@@ -193,6 +200,61 @@ define(function (require, exports, module) {
193200 __PR . clickDialogButtonID ( __PR . Dialogs . DIALOG_BTN_CANCEL ) ;
194201 await __PR . waitForModalDialogClosed ( "#git-commit-dialog" ) ;
195202 } ) ;
203+
204+ it ( "Should be able to commit the files" , async function ( ) {
205+ await commitAllBtnClick ( ) ;
206+ await commmitDlgWithMessage ( "first commit" ) ;
207+ await awaitsFor ( ( ) => {
208+ return $ ( ".git-edited-list tr" ) . length === 0 ;
209+ } , "no files to be commited" , 10000 ) ;
210+ } ) ;
211+
212+ it ( "Should editing new file and saving add it to changed files list" , async function ( ) {
213+ __PR . setCursors ( [ "5:15" ] ) ;
214+ __PR . typeAtCursor ( "\nhelloIG" ) ;
215+ await __PR . saveActiveFile ( ) ;
216+ await awaitsFor ( ( ) => {
217+ return $ ( ".git-edited-list tr" ) . length === 1 ;
218+ } , "new edited file to come up in status" , 10000 ) ;
219+
220+ // now commit
221+ await commitAllBtnClick ( ) ;
222+ await commmitDlgWithMessage ( "second commit" ) ;
223+ await awaitsFor ( ( ) => {
224+ return $ ( ".git-edited-list tr" ) . length === 0 ;
225+ } , "no files to be commited" , 10000 ) ;
226+ } ) ;
227+
228+ async function gotoChange ( line , direction ) {
229+ await awaitsFor ( ( ) => {
230+ $ ( `.git-${ direction } -gutter` ) . click ( ) ;
231+ const editor = EditorManager . getActiveEditor ( ) ;
232+ return editor . getCursorPos ( ) . line === line ;
233+ } , `should go to previous change ${ line } ` , 10000 , 100 ) ;
234+ }
235+
236+ it ( "Should be able to navigate to next and previous changes and then discard changes" , async function ( ) {
237+ __PR . setCursors ( [ "1:1" ] ) ;
238+ __PR . typeAtCursor ( "changeLine1\n" ) ;
239+ __PR . setCursors ( [ "4:1" ] ) ;
240+ __PR . typeAtCursor ( "changeLine2\n" ) ;
241+ await __PR . saveActiveFile ( ) ;
242+ await awaitsFor ( ( ) => {
243+ return $ ( ".git-edited-list tr" ) . length === 1 ;
244+ } , "new edited file to come up in status" , 10000 ) ;
245+
246+ // next previous buttons tests
247+ await gotoChange ( 3 , "prev" ) ;
248+ await gotoChange ( 0 , "prev" ) ;
249+ await gotoChange ( 3 , "next" ) ;
250+
251+ // discard all changes with panel button
252+ $ ( ".btn-git-undo" ) . click ( ) ;
253+ __PR . clickDialogButtonID ( __PR . Dialogs . DIALOG_BTN_OK ) ;
254+ await awaitsFor ( ( ) => {
255+ return $ ( ".git-edited-list tr" ) . length === 0 ;
256+ } , "no files to be commited" , 10000 ) ;
257+ } ) ;
196258 } ) ;
197259
198260 } ) ;
0 commit comments