Skip to content

Commit 9a4884b

Browse files
committed
Add basic first chat integration test
1 parent 97102a3 commit 9a4884b

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

integration-test/entrypoint.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[integration.eca :as eca]))
55

66
(def namespaces
7-
'[integration.initialize-test])
7+
'[integration.initialize-test
8+
integration.chat-openai-test])
89

910
(defn timeout [timeout-ms callback]
1011
(let [fut (future (callback))
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
(ns integration.chat-openai-test
2+
(:require
3+
[clojure.test :refer [deftest is testing]]
4+
[integration.eca :as eca]
5+
[integration.fixture :as fixture]
6+
[matcher-combinators.matchers :as m]
7+
[matcher-combinators.test :refer [match?]]))
8+
9+
(eca/clean-after-test)
10+
11+
(deftest simple-text
12+
(eca/start-process!)
13+
14+
(eca/request! (fixture/initialize-request))
15+
(eca/notify! (fixture/initialized-notification))
16+
(testing "simple hello message with reply"
17+
(let [resp (eca/request! (fixture/chat-prompt-request
18+
{:request-id 0
19+
:message "Hello there!"}))
20+
chat-id (:chatId resp)]
21+
22+
(is (match?
23+
{:chatId (m/pred string?)
24+
:model "claude-sonnet-4-20250514"
25+
:status "success"}
26+
resp))
27+
28+
(is (match?
29+
{:chatId chat-id
30+
:requestId 0
31+
:role "user"
32+
:content {:type "text" :text "Hello there!\n"}}
33+
(eca/client-awaits-server-notification :chat/contentReceived)))
34+
(is (match?
35+
{:chatId chat-id
36+
:requestId 0
37+
:role "system"
38+
:content {:type "progress" :state "running" :text "Waiting model"}}
39+
(eca/client-awaits-server-notification :chat/contentReceived))))))

integration-test/integration/fixture.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@
2626

2727
(defn exit-notification []
2828
[:exit {}])
29+
30+
(defn chat-prompt-request [params]
31+
[:chat/prompt params])

0 commit comments

Comments
 (0)