Skip to content

A platform for community discussion. Free, open, simple.

DEV: adds spec for deleted message (#20317)

Joffrey JAFFEUX723a7e316b4a
diff --git a/plugins/chat/spec/system/chat_channel_spec.rb b/plugins/chat/spec/system/chat_channel_spec.rb
index 096dc6348f8..39ecd2b9682 100644
--- a/plugins/chat/spec/system/chat_channel_spec.rb
+++ b/plugins/chat/spec/system/chat_channel_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe "Chat channel", type: :system, js: true do
it "loads most recent messages" do
unloaded_message = Fabricate(:chat_message, chat_channel: channel_1)
- visit("/chat/message/#{message_1.id}")
+ visit("/chat/c/-/#{channel_1.id}/#{message_1.id}")
expect(channel).to have_no_loading_skeleton
expect(page).to have_no_css("[data-id='#{unloaded_message.id}']")
diff --git a/plugins/chat/spec/system/deleted_message_spec.rb b/plugins/chat/spec/system/deleted_message_spec.rb
new file mode 100644
index 00000000000..a73edddfd0e
--- /dev/null
+++ b/plugins/chat/spec/system/deleted_message_spec.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+RSpec.describe "Deleted message", type: :system, js: true do
+ let(:chat_page) { PageObjects::Pages::Chat.new }
+ let(:channel_page) { PageObjects::Pages::ChatChannel.new }
+
+ fab!(:current_user) { Fabricate(:user) }
+ fab!(:channel_1) { Fabricate(:category_channel) }
+ fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1, user: current_user) }
+
+ before do
+ chat_system_bootstrap
+ channel_1.add(current_user)
+ sign_in(current_user)
+ end
+
+ context "when deleting a message" do
+ it "shows as deleted" do
+ chat_page.visit_channel(channel_1)
+ expect(channel_page).to have_no_loading_skeleton
+
+ channel_page.expand_message_actions(message_1)
+ find("[data-value='deleteMessage']").click
+
+ expect(page).to have_content(I18n.t("js.chat.deleted"))
+ end
+ end
+end