Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

test(ios): cover the / commands list

leepokai1793c7496c31
diff --git a/apps/ios/Kit/Tests/CodyncUITests/SkillCommandTests.swift b/apps/ios/Kit/Tests/CodyncUITests/SkillCommandTests.swift
deleted file mode 100644
index 6662765a..00000000
--- a/apps/ios/Kit/Tests/CodyncUITests/SkillCommandTests.swift
+++ /dev/null
@@ -1,16 +0,0 @@
-import Testing
-@testable import CodyncKit
-@testable import CodyncUI
-
-@Test func aLeadingSlashOffersTheBotsSkills() {
- #expect(SkillCommand.query("/") == "")
- #expect(SkillCommand.query("/pd") == "pd")
- #expect(SkillCommand.query("/pdf merge") == nil)
- #expect(SkillCommand.query("hi /pdf") == nil)
- let installed = [("pdf", "PDF"), ("code-review", "Code Review"), ("xlsx", "xlsx")].map {
- InstalledSkill(id: $0.0, name: $0.1, description: "", source: "custom", path: "")
- }
- #expect(SkillCommand.matches(installed, enabled: ["pdf", "code-review"], query: "").map(\.id) == ["pdf", "code-review"])
- #expect(SkillCommand.matches(installed, enabled: ["pdf", "code-review"], query: "review").map(\.id) == ["code-review"])
- #expect(SkillCommand.matches(installed, enabled: ["pdf"], query: "xl").isEmpty)
-}
diff --git a/apps/ios/Kit/Tests/CodyncUITests/SlashCommandsTests.swift b/apps/ios/Kit/Tests/CodyncUITests/SlashCommandsTests.swift
new file mode 100644
index 00000000..b5d246fb
--- /dev/null
+++ b/apps/ios/Kit/Tests/CodyncUITests/SlashCommandsTests.swift
@@ -0,0 +1,35 @@
+import Foundation
+import Testing
+@testable import CodyncKit
+@testable import CodyncUI
+
+private func bot(_ json: String) throws -> Bot { try JSONDecoder().decode(Bot.self, from: Data(json.utf8)) }
+
+private let installed = [("pdf", "PDF"), ("code-review", "Code Review"), ("xlsx", "xlsx")].map {
+ InstalledSkill(id: $0.0, name: $0.1, description: "", source: "custom", path: "")
+}
+
+@Test func aLeadingSlashOpensTheListUntilTheNameEnds() {
+ #expect(SlashCommands.query("/") == "")
+ #expect(SlashCommands.query("/pd") == "pd")
+ #expect(SlashCommands.query("/pdf merge") == nil)
+ #expect(SlashCommands.query("hi /pdf") == nil)
+}
+
+@Test func builtInCommandsComeFirstThenOnlyTheBotsOwnSkills() throws {
+ let offered = try bot(#"{"id":"b","skills":["pdf","code-review"],"fastModeSupport":"offered"}"#)
+ #expect(SlashCommands.list(for: offered, query: "", skills: installed).map(\.name) == ["fast", "new", "pdf", "code-review"])
+ #expect(SlashCommands.list(for: offered, query: "review", skills: installed).map(\.name) == ["code-review"])
+ #expect(SlashCommands.list(for: offered, query: "session", skills: installed).map(\.name) == ["new"])
+ #expect(SlashCommands.list(for: try bot(#"{"id":"b","skills":["pdf"]}"#), query: "xl", skills: installed).isEmpty)
+ #expect(SlashCommands.list(for: try bot(#"{"id":"b"}"#), query: "", skills: []).map(\.name) == ["new"], "no Fast mode on offer")
+ #expect(SlashCommands.list(for: try bot(#"{"id":"g","kind":"group","fastModeSupport":"offered"}"#), query: "", skills: installed).isEmpty)
+}
+
+@Test func sendingJustABuiltInCommandRunsIt() throws {
+ let offered = try bot(#"{"id":"b","fastModeSupport":"offered"}"#)
+ #expect(SlashCommands.builtIn(for: offered, draft: "/fast ")?.action == .fast)
+ #expect(SlashCommands.builtIn(for: offered, draft: "/new")?.action == .newSession)
+ #expect(SlashCommands.builtIn(for: offered, draft: "/fast please") == nil)
+ #expect(SlashCommands.builtIn(for: try bot(#"{"id":"b"}"#), draft: "/fast") == nil, "without Fast mode it reaches the agent")
+}