This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
spec/lib/modules/ai_bot/tools Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ def update_custom_html(artifact = nil)
9393 js = parameters [ :js ] . to_s
9494
9595 artifact_div =
96- "<div class=\" ai-artifact\" data-ai-artifact-id=#{ artifact . id } ></div>" if artifact
96+ "<div class=\" ai-artifact\" data-ai-artifact-id=\" #{ artifact . id } \" ></div>" if artifact
9797
9898 content = [ ]
9999
Original file line number Diff line number Diff line change 44 fab! ( :llm_model )
55 let ( :bot_user ) { DiscourseAi ::AiBot ::EntryPoint . find_user_from_model ( llm_model . name ) }
66 let ( :llm ) { DiscourseAi ::Completions ::Llm . proxy ( "custom:#{ llm_model . id } " ) }
7+ fab! ( :post )
78
89 before { SiteSetting . ai_bot_enabled = true }
910
1011 describe "#process" do
12+ it "correctly adds details block on final invoke" do
13+ tool =
14+ described_class . new (
15+ { html_body : "hello" } ,
16+ bot_user : Fabricate ( :user ) ,
17+ llm : llm ,
18+ context : {
19+ post_id : post . id ,
20+ } ,
21+ )
22+
23+ tool . parameters = { html_body : "hello" }
24+
25+ tool . invoke { }
26+
27+ artifact_id = AiArtifact . order ( "id desc" ) . limit ( 1 ) . pluck ( :id ) . first
28+
29+ expected = <<~MD
30+ [details='View Source']
31+
32+ ### HTML
33+
34+ ```html
35+ hello
36+ ```
37+
38+ [/details]
39+
40+ ### Preview
41+
42+ <div class="ai-artifact" data-ai-artifact-id="#{ artifact_id } "></div>
43+ MD
44+ expect ( tool . custom_raw . strip ) . to eq ( expected . strip )
45+ end
46+
1147 it "can correctly handle partial updates" do
1248 tool = described_class . new ( { } , bot_user : bot_user , llm : llm )
1349
You can’t perform that action at this time.
0 commit comments