@@ -112,8 +112,12 @@ class KometApp {
112112 return ( breadcrumbs, finalContent)
113113 }
114114
115- func commit( expectingError: Bool = false ) throws -> ( Breadcrumbs ? , String ) {
116- application. menuBars. menuBarItems [ " File " ] . menuItems [ " Commit " ] . click ( )
115+ func commit( expectingError: Bool = false , usingButton: Bool = false ) throws -> ( Breadcrumbs ? , String ) {
116+ if !usingButton {
117+ application. menuBars. menuBarItems [ " File " ] . menuItems [ " Commit " ] . click ( )
118+ } else {
119+ application. buttons [ " ZGCommitButtonIdentifier " ] . firstMatch. click ( )
120+ }
117121
118122 if expectingError && application. sheets. count > 0 {
119123 // The error we supply doesn't really matter
@@ -123,8 +127,12 @@ class KometApp {
123127 }
124128 }
125129
126- func cancel( ) throws -> ( Breadcrumbs ? , String ) {
127- application. menuBars. menuBarItems [ " File " ] . menuItems [ " Cancel " ] . click ( )
130+ func cancel( usingButton: Bool = false ) throws -> ( Breadcrumbs ? , String ) {
131+ if !usingButton {
132+ application. menuBars. menuBarItems [ " File " ] . menuItems [ " Cancel " ] . click ( )
133+ } else {
134+ application. buttons [ " ZGCancelButtonIdentifier " ] . firstMatch. click ( )
135+ }
128136 return try waitForExit ( )
129137 }
130138
@@ -215,6 +223,17 @@ class KometUITests: XCTestCase {
215223 XCTAssertEqual ( finalContent, newContent + app. initialContent)
216224 }
217225
226+ func testNewCommitWithButton( ) throws {
227+ let app = try KometApp ( filename: " new-commit " )
228+
229+ let newContent = " Hello there "
230+ app. typeText ( newContent)
231+
232+ let ( breadcrumbs, finalContent) = try app. commit ( usingButton: true )
233+ XCTAssertEqual ( breadcrumbs!. exitStatus, 0 , " commit failed with non-zero status " )
234+ XCTAssertEqual ( finalContent, newContent + app. initialContent)
235+ }
236+
218237 func testCanceledNewCommit( ) throws {
219238 let app = try KometApp ( filename: " new-commit " )
220239
@@ -225,6 +244,17 @@ class KometUITests: XCTestCase {
225244 XCTAssertEqual ( breadcrumbs!. exitStatus, 0 , " commit canceled empty message with non-zero exit status " )
226245 XCTAssertEqual ( finalContent, app. initialContent)
227246 }
247+
248+ func testCanceledNewCommitWithButton( ) throws {
249+ let app = try KometApp ( filename: " new-commit " )
250+
251+ let newContent = " Hello there "
252+ app. typeText ( newContent)
253+
254+ let ( breadcrumbs, finalContent) = try app. cancel ( usingButton: true )
255+ XCTAssertEqual ( breadcrumbs!. exitStatus, 0 , " commit canceled empty message with non-zero exit status " )
256+ XCTAssertEqual ( finalContent, app. initialContent)
257+ }
228258
229259 func testCanceledAmendedCommit( ) throws {
230260 let app = try KometApp ( filename: " amended-commit " )
0 commit comments