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

Commit 8947a7d

Browse files
committed
DEV: Add spec
1 parent 8f10c3d commit 8947a7d

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

app/services/problem_check/ai_llm_status.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class ProblemCheck::AiLlmStatus < ProblemCheck
44
self.priority = "high"
5-
# self.perform_every = 1.hour
5+
self.perform_every = 1.hour
66

77
def call
88
[*llm_errors]
@@ -24,6 +24,7 @@ def llm_errors
2424

2525
def try_validate(model, &blk)
2626
begin
27+
raise({ message: "Forced error for testing" }.to_json) if Rails.env.test?
2728
blk.call
2829
nil
2930
rescue => e
@@ -34,7 +35,7 @@ def try_validate(model, &blk)
3435
Problem.new(
3536
message,
3637
priority: "high",
37-
identifier: "ai_llm_checker",
38+
identifier: "ai_llm_status",
3839
target: model.id,
3940
details: {
4041
model_id: model.id,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# frozen_string_literal: true
2+
3+
require "rails_helper"
4+
5+
RSpec.describe ProblemCheck::AiLlmStatus do
6+
subject(:check) { described_class.new }
7+
8+
before do
9+
assign_fake_provider_to(:ai_summarization_model)
10+
SiteSetting.ai_summarization_enabled = true
11+
end
12+
13+
describe "#call" do
14+
it "does nothing if discourse-ai plugin disabled" do
15+
SiteSetting.discourse_ai_enabled = false
16+
expect(check).to be_chill_about_it
17+
end
18+
19+
context "with discourse-ai plugin enabled for the site" do
20+
let(:llm_model) { LlmModel.in_use.first }
21+
22+
before { SiteSetting.discourse_ai_enabled = true }
23+
24+
it "returns a problem with an LLM model" do
25+
message =
26+
"#{I18n.t("dashboard.problem.ai_llm_status", { model_name: llm_model.display_name, model_id: llm_model.id })}"
27+
28+
expect(described_class.new.call).to contain_exactly(
29+
have_attributes(
30+
identifier: "ai_llm_status",
31+
target: llm_model.id,
32+
priority: "high",
33+
message: message,
34+
details: {
35+
model_id: llm_model.id,
36+
model_name: llm_model.display_name,
37+
error: "Forced error for testing",
38+
},
39+
),
40+
)
41+
end
42+
end
43+
end
44+
end

0 commit comments

Comments
 (0)