Skip to content

A platform for community discussion. Free, open, simple.

1.1 KB
Raw Blame
# frozen_string_literal: true

module TopicVotingTopic
  include ::RSpec::Matchers

  def vote_count
    find(".title-voting .voting-wrapper__count-text")
  end

  def vote_popup
    find(".see-votes")
  end

  def vote
    find(".title-voting button.voting-wrapper__button").click
    self
  end

  def remove_vote
    vote
    find("button.remove-vote").click
    self
  end

  def click_my_votes
    find(".see-votes").click
  end

  def has_no_remove_vote_button?
    has_no_css?("button.remove-vote")
  end

  def has_voted?
    has_css?(".title-voting button.voting-wrapper__button.btn-success")
  end

  def has_not_voted?
    has_css?(".title-voting button.voting-wrapper__button.btn-default") &&
      has_no_css?(".title-voting button.voting-wrapper__button.btn-success")
  end

  def click_watch_toggle
    find(".topic-voting-menu__watch-toggle .btn").click
    self
  end

  def has_watch_toggle_on?
    has_css?(".topic-voting-menu__watch-toggle .d-icon-toggle-on")
  end

  def has_watch_toggle_off?
    has_css?(".topic-voting-menu__watch-toggle .d-icon-toggle-off")
  end
end

PageObjects::Pages::Topic.include(TopicVotingTopic)