Skip to content

Commit 34558a0

Browse files
committed
UI Tests (got missed in last commit)
1 parent c6a4af2 commit 34558a0

File tree

1 file changed

+68
-21
lines changed

1 file changed

+68
-21
lines changed

CodeEditUITests/Features/ActivityViewer/Tasks/TasksMenuUITests.swift

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,81 @@
88
import XCTest
99

1010
final class ActivityViewerTasksMenuTests: XCTestCase {
11+
// After all tests in this group
12+
override static func tearDown() {
13+
do {
14+
try cleanUpTempProjectPaths()
15+
} catch {
16+
print("Failed to clean up test temp directories.")
17+
print(error)
18+
}
19+
}
1120

12-
override func setUpWithError() throws {
13-
// Put setup code here. This method is called before the invocation of each test method in the class.
14-
15-
// In UI tests it is usually best to stop immediately when a failure occurs.
16-
continueAfterFailure = false
21+
var app: XCUIApplication!
22+
var window: XCUIElement!
1723

18-
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
24+
@MainActor
25+
override func setUp() async throws {
26+
app = try App.launchWithTempDir()
27+
window = Query.getWindow(app)
28+
XCTAssertTrue(window.exists, "Window not found")
1929
}
2030

21-
override func tearDownWithError() throws {
22-
// Put teardown code here. This method is called after the invocation of each test method in the class.
23-
}
31+
func testOpenTaskMenu() {
32+
let viewer = window.groups["Activity Viewer"]
33+
XCTAssertNotNil(viewer, "No Activity Viewer")
2434

25-
func testExample() throws {
26-
// UI tests must launch the application that they test.
27-
let app = XCUIApplication()
28-
app.launch()
35+
let taskDropdown = viewer.buttons["Active Task"]
36+
XCTAssertTrue(taskDropdown.exists, "No Task Dropdown")
37+
XCTAssertEqual(taskDropdown.value as? String, "Create Tasks", "Incorrect empty tasks label")
2938

30-
// Use XCTAssert and related functions to verify your tests produce the correct results.
39+
taskDropdown.click()
40+
XCTAssertGreaterThan(app.popovers.count, 0, "Popover didn't show up")
3141
}
3242

33-
func testLaunchPerformance() throws {
34-
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
35-
// This measures how long it takes to launch your application.
36-
measure(metrics: [XCTApplicationLaunchMetric()]) {
37-
XCUIApplication().launch()
38-
}
39-
}
43+
func testNewTask() {
44+
let viewer = window.groups["Activity Viewer"]
45+
let taskDropdown = viewer.buttons["Active Task"]
46+
taskDropdown.click()
47+
let popover = app.popovers.firstMatch
48+
XCTAssertTrue(popover.exists, "Popover did not appear on click")
49+
50+
let addTaskListOption = popover.buttons["Add Task..."]
51+
XCTAssertTrue(addTaskListOption.exists, "No add task option in dropdown")
52+
addTaskListOption.click()
53+
54+
let workspaceSettingsWindow = window.sheets["Workspace Settings"]
55+
XCTAssertTrue(workspaceSettingsWindow.exists, "Workspace settings did not appear")
56+
57+
let addTaskButton = workspaceSettingsWindow.buttons["Add Task..."]
58+
XCTAssertTrue(addTaskButton.exists, "No add task button")
59+
addTaskButton.click()
60+
61+
// Enter in task information
62+
let newSheet = workspaceSettingsWindow.sheets.firstMatch
63+
XCTAssertTrue(newSheet.exists)
64+
let taskName = newSheet.textFields["Task Name"]
65+
XCTAssertTrue(taskName.exists)
66+
taskName.click()
67+
taskName.typeText("New Test Task")
68+
XCTAssertEqual(taskName.value as? String, "New Test Task", "Name did not enter in")
69+
70+
let taskCommand = newSheet.textFields["Task Command"]
71+
XCTAssertTrue(taskCommand.exists)
72+
taskCommand.click()
73+
taskCommand.typeText("echo \"Hello World\"")
74+
XCTAssertEqual(taskCommand.value as? String, "echo \"Hello World\"", "Command did not enter in")
75+
76+
let saveButton = newSheet.buttons["Save"]
77+
XCTAssertTrue(saveButton.exists)
78+
saveButton.click()
79+
80+
workspaceSettingsWindow.buttons["Done"].click()
81+
XCTAssertFalse(workspaceSettingsWindow.exists, "Workspace Settings should have dismissed")
82+
83+
// Ensure the new task was added as an option
84+
XCTAssertEqual(taskDropdown.value as? String, "New Test Task")
85+
taskDropdown.click()
86+
XCTAssertTrue(popover.buttons["New Test Task"].exists, "New task was not added to the task list.")
4087
}
4188
}

0 commit comments

Comments
 (0)