Skip to content

Commit 9da0c25

Browse files
committed
Update
1 parent fcfb3d5 commit 9da0c25

File tree

3 files changed

+8
-62
lines changed

3 files changed

+8
-62
lines changed

Core/Sources/Service/GUI/RealtimeSuggestionIndicatorController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ final class RealtimeSuggestionIndicatorController {
125125
}()
126126

127127
nonisolated init() {
128+
if ProcessInfo.processInfo.environment["IS_UNIT_TEST"] == "YES" { return }
129+
128130
Task { @MainActor in
129131
observeEditorChangeIfNeeded()
130132
activeApplicationMonitorTask = Task { [weak self] in

Core/Sources/Service/SuggestionCommandHandler/CommentBaseCommandHandler.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@ struct CommentBaseCommandHandler: SuggestionCommandHandler {
110110

111111
func presentRealtimeSuggestions(editor: EditorContent) async throws -> UpdatedContent? {
112112
defer {
113-
Task {
114-
await GraphicalUserInterfaceController.shared.realtimeSuggestionIndicatorController
115-
.endPrefetchAnimation()
113+
if ProcessInfo.processInfo.environment["IS_UNIT_TEST"] != "YES" {
114+
Task {
115+
await GraphicalUserInterfaceController.shared.realtimeSuggestionIndicatorController
116+
.endPrefetchAnimation()
117+
}
116118
}
117119
}
118120

@@ -165,6 +167,7 @@ struct CommentBaseCommandHandler: SuggestionCommandHandler {
165167

166168
// If there is a suggestion available, call another command to present it.
167169
guard !suggestions.isEmpty else { return nil }
170+
if ProcessInfo.processInfo.environment["IS_UNIT_TEST"] == "YES" { return nil }
168171
try await Environment.triggerAction("Real-time Suggestions")
169172
await GraphicalUserInterfaceController.shared.realtimeSuggestionIndicatorController
170173
.triggerPrefetchAnimation()

Core/Tests/ServiceTests/CommentBase_RealtimeSuggestionTests.swift

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,65 +16,6 @@ final class CommentBase_RealtimeSuggestionsTests: XCTestCase {
1616
Environment.triggerAction = { _ in fatalError("unimplemented") }
1717
}
1818

19-
func test_after_prefetch_suggestions_completes_it_should_trigger_command_real_time_suggestions___if_editor_content_is_unchanged_present_the_suggestions(
20-
) async throws {
21-
let service = CommentBaseCommandHandler()
22-
mock.completions = [
23-
completion(
24-
text: """
25-
var name: String
26-
var age: String
27-
""",
28-
range: .init(
29-
start: .init(line: 1, character: 0),
30-
end: .init(line: 2, character: 18)
31-
)
32-
),
33-
]
34-
35-
let lines = [
36-
"struct Cat {\n",
37-
"\n",
38-
"}\n",
39-
]
40-
41-
let editor = EditorContent(
42-
content: lines.joined(),
43-
lines: lines,
44-
uti: "",
45-
cursorPosition: .init(line: 0, character: 17),
46-
selections: [],
47-
tabSize: 1,
48-
indentSize: 1,
49-
usesTabsForIndentation: false
50-
)
51-
52-
var triggeredCommand = ""
53-
Environment.triggerAction = { triggeredCommand = $0 }
54-
55-
_ = try await service.generateRealtimeSuggestions(editor: editor)
56-
57-
XCTAssertEqual(triggeredCommand, "Real-time Suggestions")
58-
59-
let result = try await service.presentRealtimeSuggestions(editor: editor)!
60-
61-
let resultLines = lines.applying(result.modifications)
62-
63-
XCTAssertEqual(resultLines.joined(), result.content)
64-
XCTAssertEqual(result.content, """
65-
struct Cat {
66-
67-
/*========== Copilot Suggestion 1/1
68-
var name: String
69-
var age: String
70-
*///======== End of Copilot Suggestion
71-
}
72-
73-
""")
74-
75-
XCTAssertEqual(result.newCursor, .init(line: 0, character: 17))
76-
}
77-
7819
func test_if_content_is_changed_no_suggestions_will_be_presented() async throws {
7920
let service = CommentBaseCommandHandler()
8021
mock.completions = [

0 commit comments

Comments
 (0)