Sha256: 8c282828267283950055a6bb162e9ed323b57957e56bafe09f9496c3c1de4511

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class GlobalECheckoutsIntegrationTest < Workarea::IntegrationTest
      def test_domestic_orders_are_not_redirected
        cookies['GlobalE_IsOperated'] = false
        product = create_product

        post storefront.cart_items_path,
          params: {
            product_id: product.id,
            sku: product.skus.first,
            quantity: 2
          }

        get storefront.checkout_path
        assert_redirected_to storefront.checkout_addresses_url
      end

      def test_externational_orders_are_redirected
        cookies['GlobalE_IsOperated'] = true

        product = create_product
        post storefront.cart_items_path,
          params: {
            product_id: product.id,
            sku: product.skus.first,
            quantity: 2
          }

        get storefront.checkout_path
        assert_redirected_to storefront.ge_checkout_url
      end

      def test_guest_checkout_clears_user_order_details
        cookies['GlobalE_IsOperated'] = true
        cookies['GlobalE_Data'] = JSON.generate({
          "countryISO" => "CA",
          "currencyCode" => "CAD",
          "cultureCode" => "en-CA"
        })

        user = create_user(password: 'W3bl1nc!')

        post storefront.login_path,
          params: { email: user.email, password: 'W3bl1nc!' }

        product = create_product

        post storefront.cart_items_path,
          params: {
            product_id: product.id,
            sku: product.skus.first,
            quantity: 2
          }

        order = Workarea::Order.first
        assert_equal user.id.to_s, order.user_id

        travel_to Workarea.config.customer_session_timeout.from_now do
          get storefront.checkout_path

          assert_redirected_to storefront.ge_checkout_url
          assert_nil order.reload.user_id
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-global_e-1.3.0 test/integration/workarea/storefront/global_e_checkouts_integration_test.rb