Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 08d2f3d

Browse files
committed
FIX: spam
1 parent 273a1fa commit 08d2f3d

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

assets/javascripts/discourse/components/ai-spam.gjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default class AiSpam extends Component {
127127
}
128128

129129
get llmId() {
130-
return this.selectedLLM.toString().split(":")[1];
130+
return this.selectedLLM;
131131
}
132132

133133
@action

spec/system/ai_moderation/ai_spam_spec.rb

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,51 @@
22

33
RSpec.describe "AI Spam Configuration", type: :system, js: true do
44
fab!(:admin)
5-
let(:llm_model) { Fabricate(:llm_model) }
65

76
before do
87
SiteSetting.discourse_ai_enabled = true
98
sign_in(admin)
109
end
1110

12-
it "can properly configure spam settings" do
13-
visit "/admin/plugins/discourse-ai/ai-spam"
11+
context "when no LLMs are configured" do
12+
it "shows the placeholder when no LLM is configured" do
13+
visit "/admin/plugins/discourse-ai/ai-spam"
1414

15-
expect(page).to have_css(".ai-spam__llm-placeholder")
15+
expect(page).to have_css(".ai-spam__llm-placeholder")
1616

17-
toggle = PageObjects::Components::DToggleSwitch.new(".ai-spam__toggle")
17+
toggle = PageObjects::Components::DToggleSwitch.new(".ai-spam__toggle")
1818

19-
toggle.toggle
20-
dialog = PageObjects::Components::Dialog.new
21-
expect(dialog).to have_content(I18n.t("discourse_ai.llm.configuration.must_select_model"))
22-
dialog.click_ok
19+
toggle.toggle
20+
dialog = PageObjects::Components::Dialog.new
21+
expect(dialog).to have_content(I18n.t("discourse_ai.llm.configuration.must_select_model"))
22+
dialog.click_ok
2323

24-
expect(toggle.unchecked?).to eq(true)
25-
26-
llm_model
27-
visit "/admin/plugins/discourse-ai/ai-spam"
24+
expect(toggle.unchecked?).to eq(true)
25+
end
26+
end
27+
context "when LLMs are configured" do
28+
fab!(:llm_model)
29+
it "can properly configure spam settings" do
30+
visit "/admin/plugins/discourse-ai/ai-spam"
2831

29-
toggle = PageObjects::Components::DToggleSwitch.new(".ai-spam__toggle")
30-
toggle.toggle
32+
toggle = PageObjects::Components::DToggleSwitch.new(".ai-spam__toggle")
33+
toggle.toggle
3134

32-
try_until_success { expect(AiModerationSetting.spam&.llm_model_id).to eq(llm_model.id) }
35+
try_until_success { expect(AiModerationSetting.spam&.llm_model_id).to eq(llm_model.id) }
3336

34-
find(".ai-spam__instructions-input").fill_in(with: "Test spam detection instructions")
35-
find(".ai-spam__instructions-save").click
37+
find(".ai-spam__instructions-input").fill_in(with: "Test spam detection instructions")
38+
find(".ai-spam__instructions-save").click
3639

37-
toasts = PageObjects::Components::Toasts.new
38-
expect(toasts).to have_content(I18n.t("js.discourse_ai.spam.settings_saved"))
40+
toasts = PageObjects::Components::Toasts.new
41+
expect(toasts).to have_content(I18n.t("js.discourse_ai.spam.settings_saved"))
3942

40-
expect(AiModerationSetting.spam.custom_instructions).to eq("Test spam detection instructions")
43+
expect(AiModerationSetting.spam.custom_instructions).to eq("Test spam detection instructions")
4144

42-
visit "/admin/plugins/discourse-ai/ai-llms"
45+
visit "/admin/plugins/discourse-ai/ai-llms"
4346

44-
expect(find(".ai-llm-list-editor__usages")).to have_content(
45-
I18n.t("js.discourse_ai.llms.usage.ai_spam"),
46-
)
47+
expect(find(".ai-llm-list-editor__usages")).to have_content(
48+
I18n.t("js.discourse_ai.llms.usage.ai_spam"),
49+
)
50+
end
4751
end
4852
end

0 commit comments

Comments
 (0)