Files
Termind/TermindTests/QuickOpenTests.swift
T

55 lines
1.9 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 = HostStore(hosts: [host])
let app = AppModel(hosts: store)
let workspace = Workspace.sshSession(host: host)
let window = WindowModel(tabs: [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 = HostStore()
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.tabs.isEmpty)
app.commands.perform(.newChat, app: app, window: window)
#expect(window.selectedTopLevelTab == .assistant)
#expect(window.tabs.isEmpty)
#expect(window.assistantLibrary.conversations.count == 1)
}
}