Skip to content

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

1.3 KB
Raw Blame
# frozen_string_literal: true

module PageObjects
  module Modals
    class Flag < PageObjects::Modals::Base
      BODY_SELECTOR = ".flag-modal-body"
      MODAL_SELECTOR = ".flag-modal"

      def choose_type(type)
        body.find("#radio_#{type}").click
      end

      def report_illegal_content
        body.choose("radio_dsa_report")
        footer.click_button("Continue")
      end

      def has_no_selected_illegal_report?
        body.has_unchecked_field?("radio_dsa_report")
      end

      def has_no_message_input?
        body.has_no_css?(".flag-message")
      end

      def has_no_confirmation?
        body.has_no_css?(".flag-confirmation")
      end

      def confirm_flag
        click_primary_button
      end

      def take_action(action)
        select_kit =
          PageObjects::Components::SelectKit.new(".d-modal__footer .reviewable-action-dropdown")
        select_kit.expand
        select_kit.select_row_by_value(action)
      end

      def fill_message(message)
        body.fill_in("message", with: message)
      end

      def check_confirmation
        body.check("confirmation")
      end

      def has_choices?(*choices)
        expect(body.all(".flag-action-type-details strong").map(&:text)).to eq(choices)
      end
    end
  end
end