Sha256: 4fc1186c93d8d46c7a3c4e244e32f0b66e9458c6e04e190c1c7e581adcbbba12

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 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

      def wait_for_turbo
        if Spree.version.to_f < 4.5
          expect(page).to have_no_css '.turbolinks-progress-bar'
        else
          expect(page).to have_no_css '.turbo-progress-bar'
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_auth_devise-4.6.3 lib/spree/testing_support/auth_helpers.rb
spree_auth_devise-4.6.2 lib/spree/testing_support/auth_helpers.rb
spree_auth_devise-4.6.1 lib/spree/testing_support/auth_helpers.rb
spree_auth_devise-4.6.0 lib/spree/testing_support/auth_helpers.rb
spree_auth_devise-4.5.0 lib/spree/testing_support/auth_helpers.rb