mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
DEV: adds logo page component (#28276)
Usage: ``` click_logo # globally accessible PageObjects::Components::Logo.click PageObjects::Components::Logo.hover ```
This commit is contained in:
parent
bf3d8a0a94
commit
e79a50d7a9
@ -43,7 +43,7 @@ describe "Admin Revamp | Sidebar Navigation | Plugin Links", type: :system do
|
||||
expect(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_logo
|
||||
expect(sidebar).to have_switch_button("chat")
|
||||
end
|
||||
|
||||
@ -56,7 +56,7 @@ describe "Admin Revamp | Sidebar Navigation | Plugin Links", type: :system do
|
||||
expect(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_logo
|
||||
expect(sidebar).to have_section("chat-channels")
|
||||
end
|
||||
|
||||
|
@ -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.hover
|
||||
expect(page).to have_css(
|
||||
".chat-message-actions-container .secondary-actions .select-kit-body",
|
||||
)
|
||||
|
@ -351,7 +351,7 @@ RSpec.describe "Navigation", type: :system do
|
||||
chat_page.open_from_header
|
||||
chat_drawer_page.maximize
|
||||
sidebar_page.open_channel(category_channel_2)
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(chat_page).to have_header_href(chat_channel_path)
|
||||
|
||||
@ -395,7 +395,7 @@ RSpec.describe "Navigation", type: :system do
|
||||
context "when clicking logo from a channel in full page" do
|
||||
it "deactivates the channel in the sidebar" do
|
||||
visit("/chat/c/#{category_channel.slug}/#{category_channel.id}")
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(sidebar_component).to have_no_section_link(category_channel.name, active: true)
|
||||
end
|
||||
@ -440,7 +440,7 @@ RSpec.describe "Navigation", type: :system do
|
||||
|
||||
expect(side_panel_page).to have_open_thread(thread)
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
sidebar_component.switch_to_chat
|
||||
|
||||
expect(side_panel_page).to have_open_thread(thread)
|
||||
|
@ -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.hover
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ RSpec.describe "Separate sidebar mode", type: :system do
|
||||
expect(sidebar_component).to have_section("chat-channels")
|
||||
expect(sidebar_component).to have_no_section("Categories")
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(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 do
|
||||
expect(sidebar_component).to have_section("Categories")
|
||||
expect(sidebar_component).to have_section("chat-channels")
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(sidebar_component).to have_no_switch_button
|
||||
expect(header_component).to have_open_chat_button
|
||||
@ -177,7 +177,7 @@ RSpec.describe "Separate sidebar mode", type: :system do
|
||||
expect(sidebar_component).to have_section("chat-channels")
|
||||
expect(sidebar_component).to have_no_section("Categories")
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(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 do
|
||||
expect(sidebar_component).to have_section("chat-channels")
|
||||
expect(sidebar_component).to have_no_section("Categories")
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(sidebar_component).to have_switch_button("chat")
|
||||
expect(header_component).to have_open_chat_button
|
||||
|
@ -161,4 +161,8 @@ module SystemHelpers
|
||||
def skip_on_ci!(message = "Flaky on CI")
|
||||
skip(message) if ENV["CI"]
|
||||
end
|
||||
|
||||
def click_logo
|
||||
PageObjects::Components::Logo.click
|
||||
end
|
||||
end
|
||||
|
@ -63,7 +63,7 @@ describe "Homepage", type: :system do
|
||||
find("#sidebar-section-content-community li:first-child").click
|
||||
expect(page).to have_css(".list-container")
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(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 do
|
||||
find(".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_logo
|
||||
expect(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 do
|
||||
find(".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_logo
|
||||
|
||||
expect(page).to have_current_path("/")
|
||||
expect(page).to have_css(".new-home", text: "Hi friends!")
|
||||
|
17
spec/system/page_objects/components/logo.rb
Normal file
17
spec/system/page_objects/components/logo.rb
Normal file
@ -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
|
||||
end
|
@ -30,10 +30,6 @@ module PageObjects
|
||||
find(".search-cta").click
|
||||
end
|
||||
|
||||
def click_home_logo
|
||||
find(".d-header .logo-mobile").click
|
||||
end
|
||||
|
||||
def click_search_icon
|
||||
find(".d-header #search-button").click
|
||||
end
|
||||
|
@ -105,7 +105,7 @@ describe "Request tracking", type: :system do
|
||||
)
|
||||
end
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
try_until_success do
|
||||
CachedCounting.flush
|
||||
@ -153,7 +153,7 @@ describe "Request tracking", type: :system do
|
||||
)
|
||||
end
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
try_until_success do
|
||||
CachedCounting.flush
|
||||
|
@ -38,7 +38,7 @@ describe "Ember route-scroll-manager service", type: :system do
|
||||
try_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_logo
|
||||
try_until_success { expect(current_scroll_y).to eq(0) }
|
||||
end
|
||||
end
|
||||
|
@ -27,14 +27,14 @@ describe "Search", type: :system do
|
||||
expect(search_page).to have_search_result
|
||||
expect(search_page.heading_text).not_to eq("Search")
|
||||
|
||||
search_page.click_home_logo
|
||||
click_logo
|
||||
expect(search_page).to be_not_active
|
||||
|
||||
page.go_back
|
||||
# ensure results are still there when using browser's history
|
||||
expect(search_page).to have_search_result
|
||||
|
||||
search_page.click_home_logo
|
||||
click_logo
|
||||
search_page.click_search_icon
|
||||
|
||||
expect(search_page).to have_no_search_result
|
||||
@ -103,7 +103,6 @@ describe "Search", type: :system do
|
||||
search_page.type_in_search_menu("test")
|
||||
search_page.click_search_menu_link
|
||||
expect(search_page).to have_topic_title_for_first_search_result(topic.title)
|
||||
|
||||
search_page.click_first_topic
|
||||
search_page.click_search_icon
|
||||
expect(search_page).to have_topic_title_for_first_search_result(topic.title)
|
||||
|
@ -47,7 +47,7 @@ describe "User preferences | Profile", type: :system do
|
||||
|
||||
expect(page).to have_current_path("/faq")
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(page).to have_current_path("/u/#{user.username}/preferences/profile")
|
||||
|
||||
@ -60,7 +60,7 @@ describe "User preferences | Profile", type: :system do
|
||||
it "disables client-side routing while missing required fields" do
|
||||
user_preferences_profile_page.visit(user)
|
||||
|
||||
find("#site-logo").click
|
||||
click_logo
|
||||
|
||||
expect(page).to have_current_path("/u/#{user.username}/preferences/profile")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user