discourse/spec/system/page_objects/components/notifications_tracking.rb
Joffrey JAFFEUX 41df705188
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 />`
2024-12-16 19:59:18 +01:00

53 lines
1.1 KiB
Ruby

# 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