Skip to content

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

2.7 KB
Raw Blame
# frozen_string_literal: true

module PageObjects
  module Pages
    class Rewind < PageObjects::Pages::Base
      def visit_my_activity
        page.visit("/my/activity")
        self
      end

      def has_rewind_tab?
        has_selector?(".user-nav__activity-rewind")
      end

      def has_no_rewind_tab?
        has_no_selector?(".user-nav__activity-rewind")
      end

      def has_rewind_notification_active?
        has_css?("body.rewind-notification-active")
      end

      def has_no_rewind_notification_active?
        has_no_css?("body.rewind-notification-active")
      end

      def has_callout?
        has_css?(".rewind-callout__container")
      end

      def has_no_callout?
        has_no_css?(".rewind-callout__container")
      end

      def click_callout
        find(".rewind-callout__container .rewind-callout").click
      end

      def has_rewind_profile_link?
        has_css?("#quick-access-profile a[href*='/activity/rewind']")
      end

      def has_no_rewind_profile_link?
        has_no_css?("#quick-access-profile a[href*='/activity/rewind']")
      end

      def visit_rewind(username)
        page.visit("/u/#{username}/activity/rewind")
        self
      end

      def share_toggle
        PageObjects::Components::DToggleSwitch.new(".rewind__share-toggle")
      end

      def has_share_toggle?
        has_css?(".rewind__share-toggle")
      end

      def has_no_share_toggle?
        has_no_css?(".rewind__share-toggle")
      end

      def has_copy_link_button?
        has_css?(".rewind__copy-link-btn")
      end

      def has_no_copy_link_button?
        has_no_css?(".rewind__copy-link-btn")
      end

      def click_copy_link_button
        find(".rewind__copy-link-btn").click
        self
      end

      def has_viewing_other_user_message?(username)
        has_css?(".rewind-other-user", text: username)
      end

      def has_cannot_view_rewind_error?
        has_css?(".rewind-error")
      end

      def has_no_cannot_view_rewind_error?
        has_no_css?(".rewind-error")
      end

      def has_rewind_loaded?
        has_css?(".rewind__scroll-wrapper")
      end

      def visit_my_preferences
        page.visit("/my/preferences")
        self
      end

      def has_rewind_preferences_nav?
        has_css?(".user-nav__preferences-rewind")
      end

      def has_no_rewind_preferences_nav?
        has_no_css?(".user-nav__preferences-rewind")
      end

      def has_most_viewed_tags_report?
        has_css?(".rewind-report-page.--most-viewed-tags")
      end

      def has_tag_in_report?(tag)
        has_css?(
          "a.folder-wrapper[href='/tag/#{tag.slug}/#{tag.id}'] .most-viewed-tags__tag",
          text: "##{tag.name}",
        )
      end
    end
  end
end