Ted Johansson f0275f1591
DEV: Promote channel error check to ProblemCheck (#190)
We're promoting problem checks to first class citizens in core. This migrates the problem check to the new API.

In the process of adding tests for this check, I discovered what seems like a mistake that likely means this check never worked until now. (See inline comment.)
2024-03-15 13:21:11 +08:00

36 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require_relative "../../dummy_provider"
RSpec.describe ProblemCheck::ChannelErrors do
include_context "with dummy provider"
let(:check) { described_class.new }
context "when chat integration is not enabled" do
before { SiteSetting.stubs(chat_integration_enabled: false) }
it { expect(check).to be_chill_about_it }
end
context "when chat integration is enabled" do
before { SiteSetting.stubs(chat_integration_enabled: true) }
context "when an enabled channel has errors" do
before { Fabricate(:channel, provider: "dummy", error_key: "whoops") }
it do
expect(check).to have_a_problem.with_priority("low").with_message(
"Some chat integration channels have errors. Visit <a href='/admin/plugins/chat-integration'>the chat integration section</a> to find out more.",
)
end
end
context "when a disabled chanel has errors" do
before { Fabricate(:channel, provider: "dummy", error_key: nil) }
it { expect(check).to be_chill_about_it }
end
end
end