|
30 | 30 | Group.find_by(id: Group::AUTO_GROUPS[:admins]).add(user) |
31 | 31 | assign_fake_provider_to(:ai_helper_model) |
32 | 32 | SiteSetting.ai_helper_enabled = true |
| 33 | + Jobs.run_immediately! |
33 | 34 | sign_in(user) |
34 | 35 | end |
35 | 36 |
|
@@ -87,13 +88,33 @@ def select_post_text(selected_post) |
87 | 88 | end |
88 | 89 |
|
89 | 90 | it "pre-fills fast edit with proofread text" do |
90 | | - skip("Test is flaky in CI, possibly some timing issue?") if ENV["CI"] |
91 | 91 | select_post_text(post_3) |
92 | 92 | post_ai_helper.click_ai_button |
93 | 93 | DiscourseAi::Completions::Llm.with_prepared_responses([proofread_response]) do |
94 | 94 | post_ai_helper.select_helper_model(mode) |
95 | | - wait_for { fast_editor.has_content?(proofread_response) } |
96 | | - expect(fast_editor).to have_content(proofread_response) |
| 95 | + expect(page.find("#fast-edit-input")).to have_content(proofread_response) |
| 96 | + end |
| 97 | + end |
| 98 | + end |
| 99 | + |
| 100 | + context "when using explain mode" do |
| 101 | + let(:mode) { DiscourseAi::AiHelper::Assistant::EXPLAIN } |
| 102 | + let(:explain_response) { "This is about pie." } |
| 103 | + |
| 104 | + it "shows the explanation in the AI helper" do |
| 105 | + select_post_text(post) |
| 106 | + post_ai_helper.click_ai_button |
| 107 | + |
| 108 | + DiscourseAi::Completions::Llm.with_prepared_responses([explain_response]) do |
| 109 | + post_ai_helper.select_helper_model(mode) |
| 110 | + |
| 111 | + MessageBus.publish( |
| 112 | + "/discourse-ai/ai-helper/stream_suggestion/#{post.id}", |
| 113 | + { result: explain_response, done: true }, |
| 114 | + user_ids: [user.id], |
| 115 | + ) |
| 116 | + |
| 117 | + expect(post_ai_helper.suggestion_value).to eq(explain_response) |
97 | 118 | end |
98 | 119 | end |
99 | 120 | end |
@@ -128,13 +149,11 @@ def select_post_text(selected_post) |
128 | 149 | end |
129 | 150 |
|
130 | 151 | it "pre-fills fast edit with proofread text" do |
131 | | - skip("Test is flaky in CI, possibly some timing issue?") if ENV["CI"] |
132 | 152 | select_post_text(post_3) |
133 | 153 | find(".quote-edit-label").click |
134 | 154 | DiscourseAi::Completions::Llm.with_prepared_responses([proofread_response]) do |
135 | 155 | find(".btn-ai-suggest-edit", visible: :all).click |
136 | | - wait_for { fast_editor.has_content?(proofread_response) } |
137 | | - expect(fast_editor).to have_content(proofread_response) |
| 156 | + expect(page.find("#fast-edit-input")).to have_content(proofread_response) |
138 | 157 | end |
139 | 158 | end |
140 | 159 | end |
|
0 commit comments