A platform for community discussion. Free, open, simple.
DEV: adds logo page component (#28276)
Joffrey JAFFEUXe79a50d7a9a5
diff --git a/plugins/chat/spec/system/admin_sidebar_navigation_spec.rb b/plugins/chat/spec/system/admin_sidebar_navigation_spec.rbindex 00fa0b90a80..b15bca51d2a 100644--- a/plugins/chat/spec/system/admin_sidebar_navigation_spec.rb+++ b/plugins/chat/spec/system/admin_sidebar_navigation_spec.rb@@ -43,7 +43,7 @@ describe "Admin Revamp | Sidebar Navigation | Plugin Links", type: :system doexpect(sidebar).to have_switch_button("chat")sidebar.click_link_in_section("community", "admin")expect(sidebar).to have_no_switch_button("chat")- find("#site-logo").click+ click_logoexpect(sidebar).to have_switch_button("chat")end@@ -56,7 +56,7 @@ describe "Admin Revamp | Sidebar Navigation | Plugin Links", type: :system doexpect(sidebar).to have_no_switch_button("chat")sidebar.click_link_in_section("community", "admin")expect(sidebar).to have_no_section("chat-channels")- find("#site-logo").click+ click_logoexpect(sidebar).to have_section("chat-channels")enddiff --git a/plugins/chat/spec/system/chat_channel_spec.rb b/plugins/chat/spec/system/chat_channel_spec.rbindex 1c97ad6b4ef..3326335d408 100644--- a/plugins/chat/spec/system/chat_channel_spec.rb+++ b/plugins/chat/spec/system/chat_channel_spec.rb@@ -372,7 +372,7 @@ RSpec.describe "Chat channel", type: :system do".chat-message-actions-container .secondary-actions .select-kit-body",)- find("#site-logo").hover+ PageObjects::Components::Logo.hoverexpect(page).to have_css(".chat-message-actions-container .secondary-actions .select-kit-body",)diff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rbindex 312c7c2f029..2e7fb0734f9 100644--- a/plugins/chat/spec/system/navigation_spec.rb+++ b/plugins/chat/spec/system/navigation_spec.rb@@ -351,7 +351,7 @@ RSpec.describe "Navigation", type: :system dochat_page.open_from_headerchat_drawer_page.maximizesidebar_page.open_channel(category_channel_2)- find("#site-logo").click+ click_logoexpect(chat_page).to have_header_href(chat_channel_path)@@ -395,7 +395,7 @@ RSpec.describe "Navigation", type: :system docontext "when clicking logo from a channel in full page" doit "deactivates the channel in the sidebar" dovisit("/chat/c/#{category_channel.slug}/#{category_channel.id}")- find("#site-logo").click+ click_logoexpect(sidebar_component).to have_no_section_link(category_channel.name, active: true)end@@ -440,7 +440,7 @@ RSpec.describe "Navigation", type: :system doexpect(side_panel_page).to have_open_thread(thread)- find("#site-logo").click+ click_logosidebar_component.switch_to_chatexpect(side_panel_page).to have_open_thread(thread)diff --git a/plugins/chat/spec/system/page_objects/chat_drawer/chat_drawer.rb b/plugins/chat/spec/system/page_objects/chat_drawer/chat_drawer.rbindex 384094a3a66..5f9f2273f98 100644--- a/plugins/chat/spec/system/page_objects/chat_drawer/chat_drawer.rb+++ b/plugins/chat/spec/system/page_objects/chat_drawer/chat_drawer.rb@@ -152,7 +152,7 @@ module PageObjects# and that the message actions menu is closed.# This check is essential because the message actions menu might partially# overlap with the header, making certain buttons inaccessible.- find("#site-logo").hover+ PageObjects::Components::Logo.hoverendendenddiff --git a/plugins/chat/spec/system/separate_sidebar_mode_spec.rb b/plugins/chat/spec/system/separate_sidebar_mode_spec.rbindex 21fde310ee3..09444505a45 100644--- a/plugins/chat/spec/system/separate_sidebar_mode_spec.rb+++ b/plugins/chat/spec/system/separate_sidebar_mode_spec.rb@@ -40,7 +40,7 @@ RSpec.describe "Separate sidebar mode", type: :system doexpect(sidebar_component).to have_section("chat-channels")expect(sidebar_component).to have_no_section("Categories")- find("#site-logo").click+ click_logoexpect(sidebar_component).to have_switch_button("chat")expect(header_component).to have_open_chat_button@@ -101,7 +101,7 @@ RSpec.describe "Separate sidebar mode", type: :system doexpect(sidebar_component).to have_section("Categories")expect(sidebar_component).to have_section("chat-channels")- find("#site-logo").click+ click_logoexpect(sidebar_component).to have_no_switch_buttonexpect(header_component).to have_open_chat_button@@ -177,7 +177,7 @@ RSpec.describe "Separate sidebar mode", type: :system doexpect(sidebar_component).to have_section("chat-channels")expect(sidebar_component).to have_no_section("Categories")- find("#site-logo").click+ click_logoexpect(sidebar_component).to have_switch_button("chat")expect(header_component).to have_open_chat_button@@ -292,7 +292,7 @@ RSpec.describe "Separate sidebar mode", type: :system doexpect(sidebar_component).to have_section("chat-channels")expect(sidebar_component).to have_no_section("Categories")- find("#site-logo").click+ click_logoexpect(sidebar_component).to have_switch_button("chat")expect(header_component).to have_open_chat_buttondiff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rbindex 850862b7f71..b7d5030e226 100644--- a/spec/support/system_helpers.rb+++ b/spec/support/system_helpers.rb@@ -161,4 +161,8 @@ module SystemHelpersdef skip_on_ci!(message = "Flaky on CI")skip(message) if ENV["CI"]end++ def click_logo+ PageObjects::Components::Logo.click+ endenddiff --git a/spec/system/homepage_spec.rb b/spec/system/homepage_spec.rbindex 29546fdda78..e140dfeb62e 100644--- a/spec/system/homepage_spec.rb+++ b/spec/system/homepage_spec.rb@@ -63,7 +63,7 @@ describe "Homepage", type: :system dofind("#sidebar-section-content-community li:first-child").clickexpect(page).to have_css(".list-container")- find("#site-logo").click+ click_logoexpect(page).to have_no_css(".list-container")# ensure clicking on logo brings user back to the custom homepage@@ -93,7 +93,7 @@ describe "Homepage", type: :system dofind(".btn-primary.save-changes:not([disabled])", wait: 5)expect(user.user_option.homepage_id).to eq(UserOption::HOMEPAGES.key("top"))- find("#site-logo").click+ click_logoexpect(page).to have_css(".navigation-container .top.active", text: "Top")expect(page).to have_css(".top-lists")@@ -109,7 +109,7 @@ describe "Homepage", type: :system dofind(".btn-primary.save-changes:not([disabled])", wait: 5)expect(user.reload.user_option.homepage_id).to_not eq(UserOption::HOMEPAGES.key("top"))- find("#site-logo").click+ click_logoexpect(page).to have_current_path("/")expect(page).to have_css(".new-home", text: "Hi friends!")diff --git a/spec/system/page_objects/components/logo.rb b/spec/system/page_objects/components/logo.rbnew file mode 100644index 00000000000..4a74382cc56--- /dev/null+++ b/spec/system/page_objects/components/logo.rb@@ -0,0 +1,17 @@+# frozen_string_literal: true++module PageObjects+ module Components+ class Logo < PageObjects::Pages::Base+ SELECTOR = "#site-logo"++ def self.click+ new.find(SELECTOR).click+ end++ def self.hover+ new.find(SELECTOR).hover+ end+ end+ end+enddiff --git a/spec/system/page_objects/pages/search.rb b/spec/system/page_objects/pages/search.rbindex 6978eb0a935..50804c9e01b 100644--- a/spec/system/page_objects/pages/search.rb+++ b/spec/system/page_objects/pages/search.rb@@ -30,10 +30,6 @@ module PageObjectsfind(".search-cta").clickend- def click_home_logo- find(".d-header .logo-mobile").click- end-def click_search_iconfind(".d-header #search-button").clickenddiff --git a/spec/system/request_tracker_spec.rb b/spec/system/request_tracker_spec.rbindex b334d7c0003..3fa625913ce 100644--- a/spec/system/request_tracker_spec.rb+++ b/spec/system/request_tracker_spec.rb@@ -105,7 +105,7 @@ describe "Request tracking", type: :system do)end- find("#site-logo").click+ click_logotry_until_success doCachedCounting.flush@@ -153,7 +153,7 @@ describe "Request tracking", type: :system do)end- find("#site-logo").click+ click_logotry_until_success doCachedCounting.flushdiff --git a/spec/system/scroll_manager_service_spec.rb b/spec/system/scroll_manager_service_spec.rbindex d89d81d35d3..76442b69cce 100644--- a/spec/system/scroll_manager_service_spec.rb+++ b/spec/system/scroll_manager_service_spec.rb@@ -38,7 +38,7 @@ describe "Ember route-scroll-manager service", type: :system dotry_until_success { expect(current_scroll_y).to eq(topic_list_scroll_y) }# Clicking site logo triggers refresh and scrolls to top- find("#site-logo").click+ click_logotry_until_success { expect(current_scroll_y).to eq(0) }endenddiff --git a/spec/system/search_spec.rb b/spec/system/search_spec.rbindex 8c6becc2a82..305514d3e27 100644--- a/spec/system/search_spec.rb+++ b/spec/system/search_spec.rb@@ -27,14 +27,14 @@ describe "Search", type: :system doexpect(search_page).to have_search_resultexpect(search_page.heading_text).not_to eq("Search")- search_page.click_home_logo+ click_logoexpect(search_page).to be_not_activepage.go_back# ensure results are still there when using browser's historyexpect(search_page).to have_search_result- search_page.click_home_logo+ click_logosearch_page.click_search_iconexpect(search_page).to have_no_search_result@@ -103,7 +103,6 @@ describe "Search", type: :system dosearch_page.type_in_search_menu("test")search_page.click_search_menu_linkexpect(search_page).to have_topic_title_for_first_search_result(topic.title)-search_page.click_first_topicsearch_page.click_search_iconexpect(search_page).to have_topic_title_for_first_search_result(topic.title)diff --git a/spec/system/user_page/user_preferences_profile_spec.rb b/spec/system/user_page/user_preferences_profile_spec.rbindex f31ee17ced4..2b29bd3335d 100644--- a/spec/system/user_page/user_preferences_profile_spec.rb+++ b/spec/system/user_page/user_preferences_profile_spec.rb@@ -47,7 +47,7 @@ describe "User preferences | Profile", type: :system doexpect(page).to have_current_path("/faq")- find("#site-logo").click+ click_logoexpect(page).to have_current_path("/u/#{user.username}/preferences/profile")@@ -60,7 +60,7 @@ describe "User preferences | Profile", type: :system doit "disables client-side routing while missing required fields" douser_preferences_profile_page.visit(user)- find("#site-logo").click+ click_logoexpect(page).to have_current_path("/u/#{user.username}/preferences/profile")end