feat: complete translation language controls and styling

This commit is contained in:
2026-10-17 23:49:36 +02:00
parent 038a5b78a0
commit 11e604e79e
9 changed files with 310 additions and 75 deletions
@@ -12,6 +12,8 @@ import Testing
#expect(body["model"] as? String == "gpt-6-luna")
#expect(body["input"] as? String == "Good morning")
#expect(body["store"] as? Bool == false)
let instructions = try #require(body["instructions"] as? String)
#expect(instructions.contains("from en to ja"))
return (Data(#"{"status":"completed","output":[{"type":"reasoning"},{"content":[{"type":"output_text","text":"おはようございます"}]}]}"#.utf8),
HTTPURLResponse(url: request.url!, statusCode: 200, httpVersion: nil, headerFields: nil)!)
}
@@ -26,6 +28,20 @@ import Testing
}
}
@Test func translationSendsReverseLanguagePairToOpenAI() async throws {
let text = try await TranslationAPI.translate(
"おはようございます", apiKey: "test-key", sourceLanguage: "ja", targetLanguage: "en"
) { request in
let body = try #require(JSONSerialization.jsonObject(with: request.httpBody!) as? [String: Any])
let instructions = try #require(body["instructions"] as? String)
#expect(instructions.contains("from ja to en"))
#expect(body["input"] as? String == "おはようございます")
return (Data(#"{"status":"completed","output":[{"content":[{"type":"output_text","text":"Good morning"}]}]}"#.utf8),
HTTPURLResponse(url: request.url!, statusCode: 200, httpVersion: nil, headerFields: nil)!)
}
#expect(text == "Good morning")
}
@Test @MainActor func translationCommandBackNavigationRestoresSearch() throws {
_ = NSApplication.shared
let launcher = LauncherWindowController()