"oAI" reads as easily confused with OpenAI, both visually and in casual conversation. Renamed to "Confab" throughout: Xcode target/scheme/bundle ID (com.oai.Confab), Info.plist and Help Book identity, all user-facing UI text, internal Log subsystem and color identifiers, localization catalogs (6 languages, including a proper reworded/retranslated Intel-deprecation notice), Help Book HTML content, and docs (README/DEVELOPMENT/PRIVACY/SECURITY). Deliberately cosmetic-only: the on-disk data folder (~/Library/Application Support/oAI/), database/backup filenames, Keychain service identifiers, and EncryptionService's key-derivation inputs are all left untouched so existing conversations, settings, and stored API keys survive the update with zero migration and no re-entering credentials. Verified live: a real signed build successfully decrypted a stored API key and loaded an existing conversation database after the bundle ID change. Also includes a small already-completed, previously uncommitted model-release-date feature (ModelInfo/OpenRouterModels/ OpenRouterProvider/ModelInfoView) that happened to share several files with this rename. Gitignored on this branch and updated on disk but not part of this commit: CLAUDE.md, RELEASE_NOTES.md, and the build*.sh scripts.
73 lines
2.6 KiB
Swift
73 lines
2.6 KiB
Swift
//
|
|
// ConversationMergeServiceTests.swift
|
|
// oAITests
|
|
//
|
|
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
// Copyright (C) 2026 Rune Olsen
|
|
|
|
import Testing
|
|
@testable import Confab
|
|
|
|
@Suite("ConversationMergeService AI response parsing")
|
|
struct ConversationMergeServiceParsingTests {
|
|
|
|
@Test("Parses a clean JSON array response")
|
|
func parsesCleanJSON() throws {
|
|
let raw = #"[{"role": "user", "content": "hi"}, {"role": "assistant", "content": "hello"}]"#
|
|
let turns = try ConversationMergeService.parseTurns(from: raw)
|
|
#expect(turns == [
|
|
ConversationMergeService.MergedTurn(role: "user", content: "hi"),
|
|
ConversationMergeService.MergedTurn(role: "assistant", content: "hello"),
|
|
])
|
|
}
|
|
|
|
@Test("Parses a JSON array wrapped in markdown code fences")
|
|
func parsesFencedJSON() throws {
|
|
let raw = """
|
|
```json
|
|
[{"role": "user", "content": "hi"}]
|
|
```
|
|
"""
|
|
let turns = try ConversationMergeService.parseTurns(from: raw)
|
|
#expect(turns == [ConversationMergeService.MergedTurn(role: "user", content: "hi")])
|
|
}
|
|
|
|
@Test("Recovers a JSON array embedded in surrounding prose")
|
|
func recoversEmbeddedJSON() throws {
|
|
let raw = """
|
|
Sure, here's the merged conversation:
|
|
|
|
[{"role": "user", "content": "hi"}, {"role": "assistant", "content": "hello there"}]
|
|
|
|
Let me know if you'd like anything else!
|
|
"""
|
|
let turns = try ConversationMergeService.parseTurns(from: raw)
|
|
#expect(turns == [
|
|
ConversationMergeService.MergedTurn(role: "user", content: "hi"),
|
|
ConversationMergeService.MergedTurn(role: "assistant", content: "hello there"),
|
|
])
|
|
}
|
|
|
|
@Test("Bracket matching ignores ']' characters inside quoted content")
|
|
func ignoresBracketsInsideStrings() throws {
|
|
let raw = #"[{"role": "assistant", "content": "array[0] and array[1]"}]"#
|
|
let turns = try ConversationMergeService.parseTurns(from: raw)
|
|
#expect(turns == [ConversationMergeService.MergedTurn(role: "assistant", content: "array[0] and array[1]")])
|
|
}
|
|
|
|
@Test("Throws invalidAIResponse when no JSON array is present")
|
|
func throwsWhenNoJSONFound() {
|
|
let raw = "I reverted the latest changes, the search function is not that important."
|
|
#expect(throws: MergeError.self) {
|
|
try ConversationMergeService.parseTurns(from: raw)
|
|
}
|
|
}
|
|
|
|
@Test("Throws invalidAIResponse for an empty JSON array")
|
|
func throwsForEmptyArray() {
|
|
#expect(throws: MergeError.self) {
|
|
try ConversationMergeService.parseTurns(from: "[]")
|
|
}
|
|
}
|
|
}
|