Skip to content

Commit 32ff54a

Browse files
committed
Add tests that use the commit/cancel buttons instead of menu items
1 parent a179165 commit 32ff54a

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

Komet/Base.lproj/Commit Editor.xib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24093.7" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24123.1" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24093.7"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24123.1"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -17,7 +17,7 @@
1717
<windowStyleMask key="styleMask" titled="YES" resizable="YES" fullSizeContentView="YES"/>
1818
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
1919
<rect key="contentRect" x="205" y="188" width="500" height="329"/>
20-
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1409"/>
20+
<rect key="screenRect" x="0.0" y="0.0" width="1470" height="918"/>
2121
<value key="minSize" type="size" width="300" height="200"/>
2222
<view key="contentView" id="UXa-uU-h9N">
2323
<rect key="frame" x="0.0" y="0.0" width="500" height="329"/>

Komet/Base.lproj/Top Bar.xib

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24093.7" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24123.1" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24093.7"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24123.1"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -29,7 +29,7 @@
2929
</textFieldCell>
3030
</textField>
3131
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zn7-nG-YEr">
32-
<rect key="frame" x="437" y="5" width="59" height="20"/>
32+
<rect key="frame" x="441" y="6" width="55" height="17"/>
3333
<buttonCell key="cell" type="roundRect" title="commit" bezelStyle="roundedRect" alignment="center" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="n9Q-dk-3iT">
3434
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
3535
<font key="font" metaFont="smallSystem"/>
@@ -41,22 +41,24 @@ DQ
4141
<constraints>
4242
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="55" id="q4V-Be-Vbf"/>
4343
</constraints>
44+
<accessibility identifier="ZGCommitButtonIdentifier"/>
4445
<connections>
4546
<action selector="commit:" target="-2" id="rlp-Tk-UDc"/>
4647
</connections>
4748
</button>
4849
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LA4-2H-9rP">
49-
<rect key="frame" x="373" y="8" width="59" height="14"/>
50+
<rect key="frame" x="381" y="8" width="55" height="14"/>
5051
<buttonCell key="cell" type="roundRect" title="cancel" bezelStyle="roundedRect" alignment="center" controlSize="small" lineBreakMode="truncatingTail" state="on" imageScaling="proportionallyDown" inset="2" id="xU2-2T-xm9">
5152
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
5253
<font key="font" metaFont="smallSystem"/>
5354
</buttonCell>
55+
<accessibility identifier="ZGCancelButtonIdentifier"/>
5456
<connections>
5557
<action selector="cancelCommit:" target="-2" id="Xcr-0O-HRV"/>
5658
</connections>
5759
</button>
5860
<progressIndicator hidden="YES" maxValue="100" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="GTR-zR-Hnl" userLabel="Updater Check Progress Indicator">
59-
<rect key="frame" x="356" y="7" width="16" height="16"/>
61+
<rect key="frame" x="364" y="7" width="16" height="16"/>
6062
</progressIndicator>
6163
</subviews>
6264
<constraints>

Komet/Content.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24093.7" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24123.1" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24093.7"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24123.1"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>

KometUITests/KometUITests.swift

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)