Run model downloads and split conversations independently
This commit is contained in:
@@ -1018,6 +1018,40 @@ final class ConnectedChatTests: XCTestCase {
|
||||
XCTAssertEqual(studio.knowledgeSources, ["knowledge.md"])
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testTwoChatSessionsGenerateConcurrentlyAndPersistSeparately() async throws {
|
||||
guard let address = ProcessInfo.processInfo.environment["AISTUDIO_TEST_WEB_URL"],
|
||||
let base = URL(string: address)?.deletingLastPathComponent() else {
|
||||
throw XCTSkip("Run Scripts/test.sh to configure the fixture.")
|
||||
}
|
||||
let folder = FileManager.default.temporaryDirectory.appending(path: UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at: folder) }
|
||||
let database = folder.appending(path: "studio.sqlite")
|
||||
let left = StudioModel()
|
||||
let right = StudioModel()
|
||||
left.open(databaseURL: database)
|
||||
right.open(databaseURL: database)
|
||||
left.newChat()
|
||||
right.newChat()
|
||||
let first = try XCTUnwrap(left.selected)
|
||||
let second = try XCTUnwrap(right.selected)
|
||||
for studio in [left, right] {
|
||||
studio.prompt = "Read \(base.appending(path: "article").absoluteString)"
|
||||
studio.send(endpoint: base.appending(path: "chat-web").absoluteString, model: "fixture", mlxPath: "",
|
||||
thinking: .off, failover: false, mlxOnly: false, compatible: false, recall: false,
|
||||
useDocuments: false, instructions: "", settings: GenerationSettings())
|
||||
}
|
||||
XCTAssertTrue(left.running && right.running)
|
||||
let deadline = ContinuousClock.now + .seconds(8)
|
||||
while (left.running || right.running) && ContinuousClock.now < deadline {
|
||||
try await Task.sleep(for: .milliseconds(10))
|
||||
}
|
||||
let store = try Store(url: database)
|
||||
XCTAssertNotEqual(first, second)
|
||||
XCTAssertEqual(try store.messages(in: first).last?.content, "Page received.")
|
||||
XCTAssertEqual(try store.messages(in: second).last?.content, "Page received.")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testChatRetrievesPageWithoutToolboxConnection() async throws {
|
||||
guard let address = ProcessInfo.processInfo.environment["AISTUDIO_TEST_WEB_URL"],
|
||||
|
||||
Reference in New Issue
Block a user