Sha256: 05617521fc24abb1369fbdd1ac46cfad79182daf178b58c2710852f78cd392db

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

module Spree
  module TestingSupport
    module AuthHelpers
      def login_button
        Spree.version.to_f == 4.1 ? Spree.t(:log_in) : Spree.t(:login)
      end

      def logout_button
        Spree.version.to_f == 4.1 ? Spree.t('nav_bar.log_out') : Spree.t(:logout).upcase
      end

      def log_in(email:, password:, remember_me: true, locale: nil)
        visit spree.login_path(locale: locale)

        fill_in Spree.t(:email), with: email
        fill_in Spree.t(:password), with: password

        # Regression test for #1257
        first('label', text: Spree.t(:remember_me)).click if remember_me
        click_button login_button

        expect(page).to have_content Spree.t(:logged_in_successfully)
      end

      def log_out
        show_user_menu
        click_link logout_button

        expect(page).to have_content 'Signed out successfully'
      end

      def show_user_menu
        find("button[aria-label='#{Spree.t('nav_bar.show_user_menu')}']").click
      end

      def show_user_account
        within '#nav-bar' do
          show_user_menu
          click_link Spree.t(:my_account).upcase
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_auth_devise-4.4.2 lib/spree/testing_support/auth_helpers.rb
spree_auth_devise-4.4.1 lib/spree/testing_support/auth_helpers.rb
spree_auth_devise-4.4.0 lib/spree/testing_support/auth_helpers.rb