Skip to content

Commit c6a4af2

Browse files
committed
Add UI Tests
1 parent 636f5ff commit c6a4af2

File tree

9 files changed

+103
-1
lines changed

9 files changed

+103
-1
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@
357357
6C05A8AF284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C05A8AE284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift */; };
358358
6C05CF9E2CDE8699006AAECD /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6C05CF9D2CDE8699006AAECD /* CodeEditSourceEditor */; };
359359
6C0617D62BDB4432008C9C42 /* LogStream in Frameworks */ = {isa = PBXBuildFile; productRef = 6C0617D52BDB4432008C9C42 /* LogStream */; };
360+
6C07383B2D284ECA0025CBE3 /* TasksMenuUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C07383A2D284ECA0025CBE3 /* TasksMenuUITests.swift */; };
360361
6C08249C2C556F7400A0751E /* TerminalCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C08249B2C556F7400A0751E /* TerminalCache.swift */; };
361362
6C08249E2C55768400A0751E /* UtilityAreaTerminal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C08249D2C55768400A0751E /* UtilityAreaTerminal.swift */; };
362363
6C0824A12C5C0C9700A0751E /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = 6C0824A02C5C0C9700A0751E /* SwiftTerm */; };
@@ -1051,6 +1052,7 @@
10511052
66F370332BEE537B00D3B823 /* NonTextFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonTextFileView.swift; sourceTree = "<group>"; };
10521053
6C049A362A49E2DB00D42923 /* DirectoryEventStream.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectoryEventStream.swift; sourceTree = "<group>"; };
10531054
6C05A8AE284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WorkspaceDocument+Listeners.swift"; sourceTree = "<group>"; };
1055+
6C07383A2D284ECA0025CBE3 /* TasksMenuUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TasksMenuUITests.swift; sourceTree = "<group>"; };
10541056
6C08249B2C556F7400A0751E /* TerminalCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalCache.swift; sourceTree = "<group>"; };
10551057
6C08249D2C55768400A0751E /* UtilityAreaTerminal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilityAreaTerminal.swift; sourceTree = "<group>"; };
10561058
6C092ED92A53A58600489202 /* EditorLayout+StateRestoration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EditorLayout+StateRestoration.swift"; sourceTree = "<group>"; };
@@ -2838,6 +2840,22 @@
28382840
name = "Recovered References";
28392841
sourceTree = "<group>";
28402842
};
2843+
6C0738382D284EA20025CBE3 /* ActivityViewer */ = {
2844+
isa = PBXGroup;
2845+
children = (
2846+
6C0738392D284EAE0025CBE3 /* Tasks */,
2847+
);
2848+
path = ActivityViewer;
2849+
sourceTree = "<group>";
2850+
};
2851+
6C0738392D284EAE0025CBE3 /* Tasks */ = {
2852+
isa = PBXGroup;
2853+
children = (
2854+
6C07383A2D284ECA0025CBE3 /* TasksMenuUITests.swift */,
2855+
);
2856+
path = Tasks;
2857+
sourceTree = "<group>";
2858+
};
28412859
6C092EDC2A53A63E00489202 /* Views */ = {
28422860
isa = PBXGroup;
28432861
children = (
@@ -3004,6 +3022,7 @@
30043022
6C96191E2C3F27E3009733CE /* Features */ = {
30053023
isa = PBXGroup;
30063024
children = (
3025+
6C0738382D284EA20025CBE3 /* ActivityViewer */,
30073026
6C96191D2C3F27E3009733CE /* NavigatorArea */,
30083027
);
30093028
path = Features;
@@ -4581,6 +4600,7 @@
45814600
6CFBA54B2C4E168A00E3A914 /* App.swift in Sources */,
45824601
6CFBA54D2C4E16C900E3A914 /* WindowCloseCommandTests.swift in Sources */,
45834602
6C9619222C3F27F1009733CE /* Query.swift in Sources */,
4603+
6C07383B2D284ECA0025CBE3 /* TasksMenuUITests.swift in Sources */,
45844604
6C9619202C3F27E3009733CE /* ProjectNavigatorUITests.swift in Sources */,
45854605
);
45864606
runOnlyForDeploymentPostprocessing = 0;

CodeEdit/Features/CEWorkspaceSettings/Views/AddCETaskView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct AddCETaskView: View {
4242
}
4343
.padding()
4444
}
45+
.accessibilityIdentifier("AddTaskView")
4546
}
4647

4748
}

CodeEdit/Features/CEWorkspaceSettings/Views/CETaskFormView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct CETaskFormView: View {
1919
TextField(text: $task.name) {
2020
Text("Name")
2121
}
22+
.accessibilityLabel("Task Name")
2223
Picker("Target", selection: $task.target) {
2324
Text("My Mac")
2425
.tag("My Mac")
@@ -32,12 +33,14 @@ struct CETaskFormView: View {
3233
Text("Docker Compose")
3334
.tag("Docker Compose")
3435
}
36+
.disabled(true)
3537
}
3638

3739
Section {
3840
TextField(text: $task.command) {
3941
Text("Task")
4042
}
43+
.accessibilityLabel("Task Command")
4144
TextField(text: $task.workingDirectory) {
4245
Text("Working Directory")
4346
}

CodeEdit/Features/CEWorkspaceSettings/Views/CEWorkspaceSettingsTaskListView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct CEWorkspaceSettingsTaskListView: View {
1515

1616
@Binding var selectedTaskID: UUID?
1717
@Binding var showAddTaskSheet: Bool
18+
1819
var body: some View {
1920
if settings.tasks.isEmpty {
2021
Text("No tasks")

CodeEdit/Features/CEWorkspaceSettings/Views/CEWorkspaceSettingsView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ struct CEWorkspaceSettingsView: View {
2626
"Name",
2727
text: $workspaceSettingsManager.settings.project.projectName
2828
)
29+
.accessibilityLabel("Workspace Name")
2930
} header: {
3031
Text("Workspace")
32+
.accessibilityHidden(true)
3133
}
3234

3335
Section {

CodeEdit/Features/Documents/Controllers/CodeEditWindowControllerExtensions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ extension CodeEditWindowController {
125125
settingsWindow.contentView = NSHostingView(rootView: contentView)
126126
settingsWindow.titlebarAppearsTransparent = true
127127
settingsWindow.setContentSize(NSSize(width: 515, height: 515))
128+
settingsWindow.setAccessibilityTitle("Workspace Settings")
128129

129130
window.beginSheet(settingsWindow, completionHandler: nil)
130131
}

CodeEditUITests/App.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@ import XCTest
1010
enum App {
1111
static func launchWithCodeEditWorkspace() -> XCUIApplication {
1212
let application = XCUIApplication()
13-
application.launchArguments = ["--open", projectPath()]
13+
application.launchArguments = ["-ApplePersistenceIgnoreState", "YES", "--open", projectPath()]
14+
application.launch()
15+
return application
16+
}
17+
18+
// Launches CodeEdit in a new directory
19+
static func launchWithTempDir() throws -> XCUIApplication {
20+
let application = XCUIApplication()
21+
application.launchArguments = ["-ApplePersistenceIgnoreState", "YES", "--open", try tempProjectPath()]
1422
application.launch()
1523
return application
1624
}
1725

1826
static func launch() -> XCUIApplication {
1927
let application = XCUIApplication()
28+
application.launchArguments = ["-ApplePersistenceIgnoreState", "YES"]
2029
application.launch()
2130
return application
2231
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// ActivityViewerTasksMenuTests.swift
3+
// CodeEditUITests
4+
//
5+
// Created by Khan Winter on 1/3/25.
6+
//
7+
8+
import XCTest
9+
10+
final class ActivityViewerTasksMenuTests: XCTestCase {
11+
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
17+
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.
19+
}
20+
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+
}
24+
25+
func testExample() throws {
26+
// UI tests must launch the application that they test.
27+
let app = XCUIApplication()
28+
app.launch()
29+
30+
// Use XCTAssert and related functions to verify your tests produce the correct results.
31+
}
32+
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+
}
40+
}
41+
}

CodeEditUITests/ProjectPath.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,27 @@ func projectPath() -> String {
1616
.dropFirst()
1717
)
1818
}
19+
20+
private var tempProjectPathIds = Set<String>()
21+
22+
private func makeTempID() -> String {
23+
let id = String((0..<10).map { _ in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-".randomElement()! })
24+
if tempProjectPathIds.contains(id) {
25+
return makeTempID()
26+
}
27+
tempProjectPathIds.insert(id)
28+
return id
29+
}
30+
31+
func tempProjectPath() throws -> String {
32+
let baseDir = FileManager.default.temporaryDirectory.appending(path: "CodeEditUITests")
33+
let id = makeTempID()
34+
let path = baseDir.appending(path: id)
35+
try FileManager.default.createDirectory(at: path, withIntermediateDirectories: true)
36+
return path.path(percentEncoded: false)
37+
}
38+
39+
func cleanUpTempProjectPaths() throws {
40+
let baseDir = FileManager.default.temporaryDirectory.appending(path: "CodeEditUITests")
41+
try FileManager.default.removeItem(at: baseDir)
42+
}

0 commit comments

Comments
 (0)