From 8cb81a7d9e0df1d43903bc26aa415cecfcada915 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Thu, 17 Oct 2024 12:02:43 -0300 Subject: [PATCH 1/2] FIX: Error modal not showing data Before, there was an issue where the error modal was not showing the data. This was because the error modal was not being shown when there were errors. --- .../javascripts/admin/components/modal/channel-error.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/assets/javascripts/admin/components/modal/channel-error.hbs b/admin/assets/javascripts/admin/components/modal/channel-error.hbs index 4578f5db..f6914b32 100644 --- a/admin/assets/javascripts/admin/components/modal/channel-error.hbs +++ b/admin/assets/javascripts/admin/components/modal/channel-error.hbs @@ -1,4 +1,4 @@ -

{{i18n @model.error_key}}

-
{{@model.error_info}}
+

{{i18n @model.channel.error_key}}

+
{{@model.channel.error_info}}
\ No newline at end of file From 42b5497941b9f1c81e48e7289df61a425412f38d Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Thu, 17 Oct 2024 12:32:38 -0300 Subject: [PATCH 2/2] DEV: add tests to ensure that error modal is showing data --- spec/system/create_channel_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/system/create_channel_spec.rb b/spec/system/create_channel_spec.rb index f56258ea..eba78c9b 100644 --- a/spec/system/create_channel_spec.rb +++ b/spec/system/create_channel_spec.rb @@ -1,8 +1,16 @@ # frozen_string_literal: true +require_relative "../dummy_provider" RSpec.describe "Create channel", type: :system do fab!(:admin) + include_context "with dummy provider" + let(:manager) { ::DiscourseChatIntegration::Manager } + let(:chan1) { DiscourseChatIntegration::Channel.create!(provider: "dummy") } + let(:category) { Fabricate(:category) } + let(:topic) { Fabricate(:topic, category_id: category.id) } + let(:first_post) { Fabricate(:post, topic: topic) } + before do SiteSetting.chat_integration_enabled = true SiteSetting.chat_integration_discord_enabled = true @@ -23,4 +31,25 @@ expect(page).to have_css(".channel-details") expect(find(".channel-info")).to have_content("bloop") end + + it "shows error in chanel modal" do + DiscourseChatIntegration::Rule.create!( + channel: chan1, + filter: "watch", + category_id: category.id, + ) + + visit("/admin/plugins/chat-integration/dummy") + + provider.set_raise_exception( + DiscourseChatIntegration::ProviderError.new info: { error_key: "hello" } + ) + manager.trigger_notifications(first_post.id) + expect(find(".error-message")).to have_content( + I18n.t("js.chat_integration.channels_with_errors"), + ) + + find(".channel-title").find("button").click + expect(page).to have_content "{\n \"error_key\": \"hello\"\n}" + end end