discourse/plugins/poll/spec/system/page_objects/pages/poll.rb
Sam f0fc5646dc
FEATURE: dynamic poll support (#34368)
If a poll is created with `dynamic-poll=true`
then options can be amended after you post poll.

This is useful for polls like: "favorite IDE" where you want
people to easily be allowed to add options.

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2025-08-19 16:43:36 +10:00

39 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class Poll < PageObjects::Pages::Base
def initialize(topic_page: nil)
@topic_page = topic_page || PageObjects::Pages::Topic.new
end
def has_poll_for_post?(post)
@topic_page.post_by_number(post.post_number).has_css?(".poll")
end
def find_poll_for_post(post)
@topic_page.post_by_number(post.post_number).find(".poll")
end
def has_option?(post, option)
post_element = @topic_page.post_by_number(post.post_number)
post_element.has_css?(".poll .option-text", text: option)
end
def has_no_option?(post, option)
post_element = @topic_page.post_by_number(post.post_number)
post_element.has_no_css?(".poll .option-text", text: option)
end
def vote_for_option(post, option)
post_element = @topic_page.post_by_number(post.post_number)
post_element.find("li[data-poll-option-id] button", text: option).click
end
def has_vote_count?(post, count)
post_element = @topic_page.post_by_number(post.post_number)
post_element.has_css?(".poll .info-number", text: count.to_s)
end
end
end
end