mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: replaces topic-notifications-options by DMenu (#30298)
This commit introduces <NotificationsTracking /> which is a wrapper component around <DMenu /> which replaces the select-kit component <TopicNotificationsButton />. Each tracking case has its dedicated component: - topic -> `<TopicNotificationsTracking />` - group -> `<GroupNotificationsTracking />` - tag -> `<TagNotificationsTracking />` - category -> `<CategoryNotificationsTracking />` - chat thread -> `<ThreadNotificationsTracking />`
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Components
|
||||
class NotificationsTracking < PageObjects::Components::Base
|
||||
attr_reader :context
|
||||
|
||||
def initialize(context)
|
||||
@context = context
|
||||
end
|
||||
|
||||
def toggle
|
||||
trigger.click
|
||||
self
|
||||
end
|
||||
|
||||
def select_level_id(id)
|
||||
content.find("[data-level-id='#{id}']").click
|
||||
self
|
||||
end
|
||||
|
||||
def select_level_name(name)
|
||||
content.find("[data-level-name='#{name}']").click
|
||||
self
|
||||
end
|
||||
|
||||
def has_selected_level_name?(name)
|
||||
find("[data-trigger][data-identifier='#{identifier}'][data-level-name='#{name}']")
|
||||
end
|
||||
|
||||
def has_selected_level_id?(id)
|
||||
find("[data-trigger][data-identifier='#{identifier}'][data-level-id='#{id}']")
|
||||
end
|
||||
|
||||
def trigger
|
||||
if @context.is_a?(Capybara::Node::Element)
|
||||
@context
|
||||
else
|
||||
find(@context)
|
||||
end
|
||||
end
|
||||
|
||||
def content
|
||||
find("[data-content][data-identifier='#{identifier}']")
|
||||
end
|
||||
|
||||
def identifier
|
||||
trigger["data-identifier"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -12,11 +12,7 @@ module PageObjects
|
||||
end
|
||||
|
||||
def has_tracking_status?(name)
|
||||
select_kit =
|
||||
PageObjects::Components::SelectKit.new(
|
||||
"#topic-footer-buttons .topic-notifications-options",
|
||||
)
|
||||
expect(select_kit).to have_selected_name(name)
|
||||
find("#topic-footer-buttons .notifications-tracking-trigger[data-level-name='#{name}']")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -263,7 +263,7 @@ module PageObjects
|
||||
end
|
||||
|
||||
def click_notifications_button
|
||||
find(".topic-notifications-button .select-kit-header").click
|
||||
find(".topic-notifications-button .notifications-tracking-trigger").click
|
||||
end
|
||||
|
||||
def click_admin_menu_button
|
||||
@@ -272,7 +272,7 @@ module PageObjects
|
||||
|
||||
def watch_topic
|
||||
click_notifications_button
|
||||
find('li[data-name="watching"]').click
|
||||
find('.notifications-tracking-btn[data-level-name="watching"]').click
|
||||
end
|
||||
|
||||
def close_topic
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
describe "Tag notification level", type: :system do
|
||||
let(:tags_page) { PageObjects::Pages::Tag.new }
|
||||
let(:select_kit) { PageObjects::Components::SelectKit.new(".tag-notifications-button") }
|
||||
let(:notifications_tracking) do
|
||||
PageObjects::Components::NotificationsTracking.new(".tag-notifications-tracking")
|
||||
end
|
||||
|
||||
fab!(:tag_1) { Fabricate(:tag) }
|
||||
fab!(:current_user) { Fabricate(:admin) }
|
||||
@@ -12,11 +14,13 @@ describe "Tag notification level", type: :system do
|
||||
describe "when changing a tag's notification level" do
|
||||
it "should change instantly" do
|
||||
tags_page.visit_tag(tag_1)
|
||||
expect(select_kit).to have_selected_name("regular")
|
||||
|
||||
select_kit.select_row_by_name("watching")
|
||||
expect(notifications_tracking).to have_selected_level_name("regular")
|
||||
|
||||
expect(select_kit).to have_selected_name("watching")
|
||||
notifications_tracking.toggle
|
||||
notifications_tracking.select_level_name("watching")
|
||||
|
||||
expect(notifications_tracking).to have_selected_level_name("watching")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user