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.rbindex 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" doendcontext "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_loadedthread_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_loadedendcontext "for mobile" doit "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_listexpect(thread_list_page).to have_loadedthread_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_loadedend@@ -225,18 +217,17 @@ RSpec.describe "Navigation" dobefore { 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")endend@@ -245,14 +236,11 @@ RSpec.describe "Navigation" docontext "when opening a thread from indicator" doit "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).clickexpect(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_loadedend@@ -260,14 +248,11 @@ RSpec.describe "Navigation" docontext "for mobile" doit "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).clickexpect(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_closedenddiff --git a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb b/plugins/chat/spec/system/page_objects/chat/chat_channel.rbindex 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 PageObjectsdef open_thread_listfind(thread_list_button_selector).click- PageObjects::Components::Chat::ThreadList.new.has_loaded?+ expect(PageObjects::Components::Chat::ThreadList.new).to have_loadedenddef 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.rbindex 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 PageObjectsenddef 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)enddef 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.rbindex 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 PageObjectsheader.find(".c-navbar__back-button").clickend+ 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")enddiff --git a/plugins/chat/spec/system/page_objects/chat/components/thread_list.rb b/plugins/chat/spec/system/page_objects/chat/components/thread_list.rbindex 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 PageObjectsenddef 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")enddef open_thread(thread)