DEV: Try fix flaky chat navigation spec (#22356)

Followup to e57070af92,
try to check for href of link first before clicking.
This commit is contained in:
Martin Brennan 2023-06-30 11:08:29 +10:00 committed by GitHub
parent 351005ef1b
commit 58a3cdc6ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -142,13 +142,14 @@ RSpec.describe "Navigation", type: :system do
end end
context "when opening a thread from the thread list" do context "when opening a thread from the thread list" do
xit "goes back to the thread list when clicking the back button" do it "goes back to the thread list when clicking the back button" do
visit("/chat") visit("/chat")
chat_page.visit_channel(category_channel) chat_page.visit_channel(category_channel)
channel_page.open_thread_list channel_page.open_thread_list
expect(thread_list_page).to have_loaded expect(thread_list_page).to have_loaded
thread_list_page.open_thread(thread) thread_list_page.open_thread(thread)
expect(side_panel_page).to have_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_to_previous_route thread_page.back_to_previous_route
expect(thread_list_page).to have_loaded expect(thread_list_page).to have_loaded
end end
@ -161,6 +162,7 @@ RSpec.describe "Navigation", type: :system do
expect(thread_list_page).to have_loaded expect(thread_list_page).to have_loaded
thread_list_page.open_thread(thread) thread_list_page.open_thread(thread)
expect(side_panel_page).to have_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_to_previous_route thread_page.back_to_previous_route
expect(thread_list_page).to have_loaded expect(thread_list_page).to have_loaded
end end
@ -173,6 +175,7 @@ RSpec.describe "Navigation", type: :system do
chat_page.visit_channel(category_channel) chat_page.visit_channel(category_channel)
channel_page.message_thread_indicator(thread.original_message).click channel_page.message_thread_indicator(thread.original_message).click
expect(side_panel_page).to have_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_to_previous_route thread_page.back_to_previous_route
expect(thread_list_page).to have_loaded expect(thread_list_page).to have_loaded
end end
@ -184,6 +187,7 @@ RSpec.describe "Navigation", type: :system do
chat_page.visit_channel(category_channel) chat_page.visit_channel(category_channel)
channel_page.message_thread_indicator(thread.original_message).click channel_page.message_thread_indicator(thread.original_message).click
expect(side_panel_page).to have_open_thread(thread) expect(side_panel_page).to have_open_thread(thread)
expect(thread_page).to have_back_link_to_channel(category_channel)
thread_page.back_to_previous_route thread_page.back_to_previous_route
expect(side_panel_page).not_to be_open expect(side_panel_page).not_to be_open
end end

View File

@ -58,6 +58,16 @@ module PageObjects
header.find(".chat-thread__close").click header.find(".chat-thread__close").click
end end
def has_back_link_to_thread_list?(channel)
header.has_css?(
".chat-thread__back-to-previous-route[href='#{channel.relative_url + "/t"}']",
)
end
def has_back_link_to_channel?(channel)
header.has_css?(".chat-thread__back-to-previous-route[href='#{channel.relative_url}']")
end
def back_to_previous_route def back_to_previous_route
header.find(".chat-thread__back-to-previous-route").click header.find(".chat-thread__back-to-previous-route").click
end end