Skip to content

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

DEV: Restore and fix chat navigation specs (#39489)

Jarek Radoszde05419faf34
diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rb
index 1ca6b406689..7c79cfa3f9b 100644
--- a/plugins/chat/spec/system/navigation_spec.rb
+++ b/plugins/chat/spec/system/navigation_spec.rb
@@ -188,33 +188,25 @@ RSpec.describe "Navigation" do
end
context "when opening a thread from the thread list" do
- xit "goes back to the thread list when clicking the back button" do
- skip_on_ci!
-
- visit("/chat")
- chat_page.visit_channel(category_channel)
- channel_page.open_thread_list
+ it "goes back to the thread list when clicking the back button" do
+ chat_page.visit_threads_list(category_channel)
expect(thread_list_page).to have_loaded
thread_list_page.open_thread(thread)
expect(side_panel_page).to have_open_thread(thread)
- expect(thread_page).to have_back_link_to_thread_list(category_channel)
- thread_page.back
+ thread_page.back_to_thread_list(category_channel)
expect(page).to have_current_path("#{category_channel.relative_url}/t")
expect(thread_list_page).to have_loaded
end
context "for mobile" do
it "goes back to the thread list when clicking the back button", mobile: true do
- skip_on_ci!
-
visit("/chat")
chat_page.visit_channel(category_channel)
channel_page.open_thread_list
expect(thread_list_page).to have_loaded
thread_list_page.open_thread(thread)
expect(side_panel_page).to have_open_thread(thread)
- expect(thread_page).to have_back_link_to_thread_list(category_channel)
- thread_page.back
+ thread_page.back_to_thread_list(category_channel)
expect(page).to have_current_path("#{category_channel.relative_url}/t")
expect(thread_list_page).to have_loaded
end
@@ -225,18 +217,17 @@ RSpec.describe "Navigation" do
before { Fabricate(:chat_message, thread: thread_2, use_service: true) }
it "goes back to the thread list when clicking the back button", mobile: true do
- skip_on_ci!
-
chat_page.visit_channel(category_channel)
channel_page.message_thread_indicator(thread.original_message).click
+ expect(side_panel_page).to have_open_thread(thread)
thread_page.send_message
- thread_page.back
+ thread_page.back_to_channel(category_channel)
channel_page.message_thread_indicator(thread_2.original_message).click
+ expect(side_panel_page).to have_open_thread(thread_2)
Fabricate(:chat_message, thread: thread, use_service: true)
expect(thread_page).to have_unread_list_indicator(count: 1)
- expect(thread_page).to have_back_link_to_thread_list(category_channel)
- thread_page.back
+ thread_page.back_to_thread_list(category_channel)
expect(page).to have_current_path("#{category_channel.relative_url}/t")
end
end
@@ -245,14 +236,11 @@ RSpec.describe "Navigation" do
context "when opening a thread from indicator" do
it "goes back to the thread list when clicking the back button" do
- skip_on_ci!
-
visit("/chat")
chat_page.visit_channel(category_channel)
channel_page.message_thread_indicator(thread.original_message).click
expect(side_panel_page).to have_open_thread(thread)
- expect(thread_page).to have_back_link_to_thread_list(category_channel)
- thread_page.back
+ thread_page.back_to_thread_list(category_channel)
expect(page).to have_current_path("#{category_channel.relative_url}/t")
expect(thread_list_page).to have_loaded
end
@@ -260,14 +248,11 @@ RSpec.describe "Navigation" do
context "for mobile" do
it "closes the thread and goes back to the channel when clicking the back button",
mobile: true do
- skip_on_ci!
-
visit("/chat")
chat_page.visit_channel(category_channel)
channel_page.message_thread_indicator(thread.original_message).click
expect(side_panel_page).to have_open_thread(thread)
- expect(thread_page).to have_back_link_to_channel(category_channel)
- thread_page.back
+ thread_page.back_to_channel(category_channel)
expect(page).to have_current_path("#{category_channel.relative_url}")
expect(side_panel_page).to be_closed
end
diff --git a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb
index 738290f113b..8e6f9f7692d 100644
--- a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb
+++ b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb
@@ -204,7 +204,7 @@ module PageObjects
def open_thread_list
find(thread_list_button_selector).click
- PageObjects::Components::Chat::ThreadList.new.has_loaded?
+ expect(PageObjects::Components::Chat::ThreadList.new).to have_loaded
end
def has_unread_thread_indicator?(count:)
diff --git a/plugins/chat/spec/system/page_objects/chat/chat_side_panel.rb b/plugins/chat/spec/system/page_objects/chat/chat_side_panel.rb
index 21ffde9d8b2..eb702c34582 100644
--- a/plugins/chat/spec/system/page_objects/chat/chat_side_panel.rb
+++ b/plugins/chat/spec/system/page_objects/chat/chat_side_panel.rb
@@ -12,12 +12,9 @@ module PageObjects
end
def has_open_thread?(thread = nil)
- if thread
- has_css?(".chat-side-panel .chat-thread[data-id='#{thread.id}']")
- else
- has_css?(".chat-side-panel .chat-thread")
- end
- PageObjects::Pages::ChatThread.new.has_no_loading_skeleton?
+ selector = ".chat-side-panel .chat-thread.--loaded"
+ selector += "[data-id='#{thread.id}']" if thread
+ has_css?(selector)
end
def has_no_open_thread?
diff --git a/plugins/chat/spec/system/page_objects/chat/chat_thread.rb b/plugins/chat/spec/system/page_objects/chat/chat_thread.rb
index ee49c7ac2db..6ab475d3134 100644
--- a/plugins/chat/spec/system/page_objects/chat/chat_thread.rb
+++ b/plugins/chat/spec/system/page_objects/chat/chat_thread.rb
@@ -68,6 +68,14 @@ module PageObjects
header.find(".c-navbar__back-button").click
end
+ def back_to_thread_list(channel)
+ header.find(".c-navbar__back-button[href='#{channel.relative_url}/t']").click
+ end
+
+ def back_to_channel(channel)
+ header.find(".c-navbar__back-button[href='#{channel.relative_url}']").click
+ end
+
def has_no_unread_list_indicator?
has_no_css?(".c-navbar__back-button .chat-thread-header-unread-indicator")
end
diff --git a/plugins/chat/spec/system/page_objects/chat/components/thread_list.rb b/plugins/chat/spec/system/page_objects/chat/components/thread_list.rb
index 4d168c05120..ce468edc885 100644
--- a/plugins/chat/spec/system/page_objects/chat/components/thread_list.rb
+++ b/plugins/chat/spec/system/page_objects/chat/components/thread_list.rb
@@ -11,8 +11,8 @@ module PageObjects
end
def has_loaded?
- component.has_css?(".spinner", wait: 0)
- component.has_no_css?(".spinner")
+ component.has_no_css?(".spinner") &&
+ component.has_css?(".chat-thread-list-item, .chat-thread-list__no-threads")
end
def open_thread(thread)