Start built-in web and reconnect enabled MCP profiles

This commit is contained in:
Mark Gregory
2026-11-16 17:43:02 +00:00
parent a2ccafa613
commit dd06e337fc
4 changed files with 111 additions and 25 deletions
+34
View File
@@ -706,6 +706,40 @@ final class MultipleToolsetsTests: XCTestCase {
}
}
@MainActor
func testStartupRestoresEnabledProfilesAndBuiltInWeb() async throws {
guard let endpoint = ProcessInfo.processInfo.environment["AISTUDIO_TEST_MCP_URLS"]?
.split(separator: ",").first else { throw XCTSkip("Run Scripts/test.sh to start the MCP fixture.") }
let id = UUID().uuidString
let defaults = try XCTUnwrap(UserDefaults(suiteName: id))
let file = FileManager.default.temporaryDirectory.appending(path: "\(id).json")
defer {
defaults.removePersistentDomain(forName: id)
try? FileManager.default.removeItem(at: file)
}
let profile = ["url": String(endpoint)]
try JSONEncoder().encode(["mcpServers": ["enabled": profile, "unused": profile]]).write(to: file)
defaults.set(file.path, forKey: "mcpConfigPath")
let first = StudioModel()
first.restoreToolsets(defaults: defaults)
try await waitUntil { first.activeToolsets.map(\.id) == [.web] }
first.setMCPProfile("enabled", enabled: true, path: file.path, defaults: defaults)
try await waitUntil { first.mcpConnections[.profile("enabled")]?.toolset != nil }
let reopened = StudioModel()
reopened.restoreToolsets(defaults: defaults)
try await waitUntil { reopened.activeToolsets.count == 2 }
XCTAssertNotNil(reopened.mcpConnections[.web]?.toolset)
XCTAssertNotNil(reopened.mcpConnections[.profile("enabled")]?.toolset)
XCTAssertNil(reopened.mcpConnections[.profile("unused")])
reopened.setMCPProfile("enabled", enabled: false, path: file.path, defaults: defaults)
let afterDisable = StudioModel()
afterDisable.restoreToolsets(defaults: defaults)
try await waitUntil { afterDisable.activeToolsets.map(\.id) == [.web] }
XCTAssertNil(afterDisable.mcpConnections[.profile("enabled")])
}
@MainActor
func testSeparateConnectionsRunCallsAndRetainResultsIndependently() async throws {
let studio = StudioModel()