A platform for community discussion. Free, open, simple.
DEV: Speed up chat plugin system tests (#21399)
Alan Guo Xiang Tan7ff8e5580f9a
diff --git a/plugins/chat/spec/system/create_channel_spec.rb b/plugins/chat/spec/system/create_channel_spec.rbindex f5b63e8b607..5ea35b48a99 100644--- a/plugins/chat/spec/system/create_channel_spec.rb+++ b/plugins/chat/spec/system/create_channel_spec.rb@@ -10,11 +10,12 @@ RSpec.describe "Create channel", type: :system, js: true docontext "when user cannot create channel" dofab!(:current_user) { Fabricate(:user) }+before { sign_in(current_user) }it "does not show the create channel button" dochat_page.visit_browse- expect(chat_page).not_to have_new_channel_button+ expect(chat_page).to have_no_new_channel_buttonendenddiff --git a/plugins/chat/spec/system/message_thread_indicator_spec.rb b/plugins/chat/spec/system/message_thread_indicator_spec.rbindex d1985046012..ca73c23c0e7 100644--- a/plugins/chat/spec/system/message_thread_indicator_spec.rb+++ b/plugins/chat/spec/system/message_thread_indicator_spec.rb@@ -22,7 +22,7 @@ describe "Thread indicator for chat messages", type: :system, js: true doit "shows no thread indicators in the channel" dothread = chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])chat_page.visit_channel(channel)- expect(channel_page).not_to have_thread_indicator(thread.original_message)+ expect(channel_page).to have_no_thread_indicator(thread.original_message)endend@@ -36,7 +36,7 @@ describe "Thread indicator for chat messages", type: :system, js: true doit "shows no thread inidcators in the channel" dothread = chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])chat_page.visit_channel(channel)- expect(channel_page).not_to have_thread_indicator(thread.original_message)+ expect(channel_page).to have_no_thread_indicator(thread.original_message)endenddiff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rbindex 14a3117eabf..36db0d0a790 100644--- a/plugins/chat/spec/system/navigation_spec.rb+++ b/plugins/chat/spec/system/navigation_spec.rb@@ -277,7 +277,7 @@ RSpec.describe "Navigation", type: :system, js: true dovisit("/chat/c/#{category_channel.slug}/#{category_channel.id}")find("#site-logo").click- expect(sidebar_component).not_to have_section_link(category_channel.name, active: true)+ expect(sidebar_component).to have_no_section_link(category_channel.name, active: true)endend@@ -299,7 +299,7 @@ RSpec.describe "Navigation", type: :system, js: true dosidebar_component.click_link(category_channel.name)chat_drawer_page.close- expect(sidebar_component).not_to have_section_link(category_channel.name, active: true)+ expect(sidebar_component).to have_no_section_link(category_channel.name, active: true)endendenddiff --git a/plugins/chat/spec/system/page_objects/chat/chat.rb b/plugins/chat/spec/system/page_objects/chat/chat.rbindex 8079a10f60b..8fc07f6479b 100644--- a/plugins/chat/spec/system/page_objects/chat/chat.rb+++ b/plugins/chat/spec/system/page_objects/chat/chat.rb@@ -57,12 +57,18 @@ module PageObjectscontainer.has_content?(message.user.username)end+ NEW_CHANNEL_BUTTON_SELECTOR = ".new-channel-btn"+def new_channel_button- find(".new-channel-btn")+ find(NEW_CHANNEL_BUTTON_SELECTOR)enddef has_new_channel_button?- has_css?(".new-channel-btn")+ has_css?(NEW_CHANNEL_BUTTON_SELECTOR)+ end++ def has_no_new_channel_button?+ has_no_css?(NEW_CHANNEL_BUTTON_SELECTOR)endendenddiff --git a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb b/plugins/chat/spec/system/page_objects/chat/chat_channel.rbindex d59d96aaeac..395c4b2c955 100644--- a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb+++ b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb@@ -174,11 +174,21 @@ module PageObjectsenddef has_thread_indicator?(message)- has_css?("#{message_by_id_selector(message.id)} .chat-message-thread-indicator")+ has_css?(message_thread_indicator_selector(message))+ end++ def has_no_thread_indicator?(message)+ has_no_css?(message_thread_indicator_selector(message))enddef message_thread_indicator(message)- find("#{message_by_id_selector(message.id)} .chat-message-thread-indicator")+ find(message_thread_indicator_selector(message))+ end++ private++ def message_thread_indicator_selector(message)+ "#{message_by_id_selector(message.id)} .chat-message-thread-indicator"endendend