56 lines
2.0 KiB
Swift
56 lines
2.0 KiB
Swift
import Testing
|
|
|
|
@testable import Termind
|
|
|
|
@Suite
|
|
@MainActor
|
|
struct QuickOpenTests {
|
|
@Test
|
|
func registryCombinesManagementWorkspacesHostsAndActions() {
|
|
let host = Host(name: "Production", host: "prod.example", tags: ["critical"])
|
|
let store = HostLibraryModel(hosts: [host])
|
|
let app = AppModel(hosts: store)
|
|
let workspace = Workspace.sshSession(host: host)
|
|
let window = WindowModel(workspaces: [workspace])
|
|
|
|
let commands = app.commands.commands(app: app, window: window)
|
|
|
|
#expect(commands.contains { $0.target == .vaultPage(.hosts) })
|
|
#expect(commands.contains { $0.target == .vault })
|
|
#expect(commands.contains { $0.target == .assistant })
|
|
#expect(commands.contains { $0.target == .settings })
|
|
#expect(commands.contains { $0.target == .workspace(workspace.id) })
|
|
#expect(commands.contains { $0.target == .connectHost(host.id, .sshSession) })
|
|
#expect(commands.contains { $0.target == .newChat })
|
|
#expect(commands.contains { $0.target == .showAssistant })
|
|
#expect(commands.filter { $0.matches("critical") }.count == 2)
|
|
}
|
|
|
|
@Test
|
|
func registryRoutesWithoutDuplicatingNavigationLogic() {
|
|
let store = HostLibraryModel()
|
|
let app = AppModel(hosts: store)
|
|
let window = WindowModel()
|
|
|
|
#expect(
|
|
!app.commands.commands(app: app, window: window).contains {
|
|
$0.target == .showAssistant
|
|
}
|
|
)
|
|
|
|
var settingsOpened = false
|
|
app.commands.perform(
|
|
.settings, app: app, window: window,
|
|
openSettings: { settingsOpened = true }
|
|
)
|
|
#expect(settingsOpened)
|
|
#expect(window.workspaces.isEmpty)
|
|
|
|
app.commands.perform(.newChat, app: app, window: window)
|
|
#expect(window.selectedDestination == .assistant)
|
|
#expect(window.workspaces.isEmpty)
|
|
#expect(window.assistantLibrary.conversations.isEmpty)
|
|
#expect(window.assistantLibrary.selectedConversationID == nil)
|
|
}
|
|
}
|