Skip to content

Commit bf60ed9

Browse files
committed
test: using XCTAssertEqual to get more information
1 parent 6889262 commit bf60ed9

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

macos/GhosttyUITests/GhosttyTitleUITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ final class GhosttyTitleUITests: GhosttyCustomConfigCase {
1818
let app = try ghosttyApplication()
1919
app.launch()
2020

21-
XCTAssert(app.windows.firstMatch.title == "GhosttyUITestsLaunchTests", "Oops, `title=` doesn't work!")
21+
XCTAssertEqual(app.windows.firstMatch.title, "GhosttyUITestsLaunchTests", "Oops, `title=` doesn't work!")
2222
}
2323
}

macos/GhosttyUITests/GhosttyTitlebarTabsUITests.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ final class GhosttyTitlebarTabsUITests: GhosttyCustomConfigCase {
3434
let app = try ghosttyApplication()
3535
app.launch()
3636
app.groups["Terminal pane"].typeKey("t", modifierFlags: .command)
37-
XCTAssert(app.tabs.count == 2, "There should be 2 tabs")
38-
checkTabsGeometry(app.windows.element(boundBy: 0))
37+
XCTAssertEqual(app.tabs.count, 2, "There should be 2 tabs")
38+
checkTabsGeometry(app.windows.firstMatch)
3939
}
4040

4141
@MainActor
@@ -45,14 +45,15 @@ final class GhosttyTitlebarTabsUITests: GhosttyCustomConfigCase {
4545
app.typeKey("f", modifierFlags: [.command, .control])
4646
// using app to type ⌘+t might not be able to create tabs
4747
app.groups["Terminal pane"].typeKey("t", modifierFlags: .command)
48-
XCTAssert(app.tabs.count == 2, "There should be 2 tabs")
49-
checkTabsGeometry(app.windows.element(boundBy: 0))
48+
XCTAssertEqual(app.tabs.count, 2, "There should be 2 tabs")
49+
checkTabsGeometry(app.windows.firstMatch)
5050
}
5151

5252
@MainActor
5353
func testTabsGeometryAfterMovingTabs() throws {
5454
let app = try ghosttyApplication()
5555
app.launch()
56+
XCTAssertTrue(app.windows.firstMatch.waitForExistence(timeout: 1), "Main window should exist")
5657
// create 3 tabs
5758
app.groups["Terminal pane"].typeKey("t", modifierFlags: .command)
5859
app.groups["Terminal pane"].typeKey("t", modifierFlags: .command)
@@ -61,20 +62,20 @@ final class GhosttyTitlebarTabsUITests: GhosttyCustomConfigCase {
6162
app.menuItems["_zoomLeft:"].firstMatch.click()
6263

6364
// create another window with 2 tabs
64-
app.windows.element(boundBy: 0).groups["Terminal pane"].typeKey("n", modifierFlags: .command)
65-
XCTAssert(app.windows.count == 2, "There should be 2 windows")
65+
app.windows.firstMatch.groups["Terminal pane"].typeKey("n", modifierFlags: .command)
66+
XCTAssertEqual(app.windows.count, 2, "There should be 2 windows")
6667

6768
// move to the right
6869
app.menuItems["_zoomRight:"].firstMatch.click()
6970

7071
// now second window is the first/main one in the list
71-
app.windows.element(boundBy: 0).groups["Terminal pane"].typeKey("t", modifierFlags: .command)
72+
app.windows.firstMatch.groups["Terminal pane"].typeKey("t", modifierFlags: .command)
7273

73-
app.windows.element(boundBy: 1).tabs.element(boundBy: 0).click() // focus first window
74+
app.windows.element(boundBy: 1).tabs.firstMatch.click() // focus first window
7475

7576
// now the first window is the main one
76-
let firstTabInFirstWindow = app.windows.element(boundBy: 0).tabs.element(boundBy: 0)
77-
let firstTabInSecondWindow = app.windows.element(boundBy: 1).tabs.element(boundBy: 0)
77+
let firstTabInFirstWindow = app.windows.firstMatch.tabs.firstMatch
78+
let firstTabInSecondWindow = app.windows.element(boundBy: 1).tabs.firstMatch
7879

7980
// drag a tab from one window to another
8081
firstTabInFirstWindow.press(forDuration: 0.2, thenDragTo: firstTabInSecondWindow)
@@ -89,11 +90,12 @@ final class GhosttyTitlebarTabsUITests: GhosttyCustomConfigCase {
8990
func checkTabsGeometry(_ window: XCUIElement) {
9091
let closeTabButtons = window.buttons.matching(identifier: "_closeButton")
9192

92-
XCTAssert(closeTabButtons.count == window.tabs.count, "Close tab buttons count should match tabs count")
93+
XCTAssertEqual(closeTabButtons.count, window.tabs.count, "Close tab buttons count should match tabs count")
9394

9495
var previousTabHeight: CGFloat?
9596
for idx in 0 ..< window.tabs.count {
9697
let currentTab = window.tabs.element(boundBy: idx)
98+
XCTAssertTrue(currentTab.waitForExistence(timeout: 1))
9799
// focus
98100
currentTab.click()
99101
// switch to the tab

0 commit comments

Comments
 (0)