chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.4.0 Latest 5 packages
0
0
import Foundation
import Testing
@testable import HUDKit
// HUDKit says its version on every call, so the server resolves views for
// what this build draws; and a component it does not know draws its
// children, else its fallback, else nothing, but NotYet in a debug build.
@Suite struct Kits {
@Test func theVersionIsSemver() {
let parts = Kit.version.split(separator: ".", omittingEmptySubsequences: false)
#expect(parts.count == 3)
#expect(parts.allSatisfy { !$0.isEmpty && $0.allSatisfy(\.isNumber) })
}
@Test func aToolCallsMetaCarriesTheKit() {
let meta = HUDClient.body(Call("search", ["q": "cats"]))["params"]?["_meta"]
#expect(meta?["io.modelcontextprotocol/protocolVersion"] == .string(HUDClient.version))
#expect(meta?["io.modelcontextprotocol/clientInfo"] == ["name": "hud-kit-ios", "version": .string(Kit.version)])
#expect(meta?["io.modelcontextprotocol/clientCapabilities"]?["extensions"]?["place.hud/kit"] == ["platform": "ios", "version": .string(Kit.version)])
}
@Test func callToolCarriesTheKit() {
let input = WorkspaceClient.callToolInput(Call("search", ["q": "cats"]))
#expect(input["name"] == "search")
#expect(input["arguments"] == ["q": "cats"])
#expect(input["kit"] == ["platform": "ios", "version": .string(Kit.version)])
}
}
@Suite struct UnknownComponents {
let child: JSON = ["c": "Text", "p": ["text": "hi"]]
let fallback: JSON = ["c": "Text", "p": ["text": "older"]]
@Test func inReleaseItDrawsItsChildrenAsAStack() {
let node: JSON = ["c": "Future", "k": [child], "fallback": fallback]
#expect(Unknown.drawing(node, debug: false) == .node(["c": "Stack", "p": ["gap": "md"], "k": [child]]))
}
@Test func inReleaseWithoutChildrenItDrawsItsFallback() {
#expect(Unknown.drawing(["c": "Future", "k": [], "fallback": fallback], debug: false) == .node(fallback))
#expect(Unknown.drawing(["c": "Future", "fallback": fallback], debug: false) == .node(fallback))
}
@Test func inReleaseWithNeitherItDrawsNothing() {
#expect(Unknown.drawing(["c": "Future"], debug: false) == .nothing)
}
@Test func inDebugItDrawsNotYet() {
#expect(Unknown.drawing(["c": "Future", "k": [child], "fallback": fallback], debug: true) == .notYet)
}
}