Sha256: 4e5596ca78fafdd76f68806a5dc18d43aae3380897d7580e9294dda53cd93b8a

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

require "test_helper"

module Workarea
  module Admin
    class FreeShippingMessageSettingsSystemTest < Workarea::SystemTest
      include Admin::IntegrationTest

      setup :create_discount_with_message

      def create_discount_with_message
        shipping_method = create_shipping_service
        @discount = create_shipping_discount(
          name: "Shipping Discount",
          shipping_service: shipping_method,
          amount: 0.to_m,
          order_total_operator: :greater_than,
          order_total: 1.to_m,
          message_active: true,
          message_applied: "You got FREE SHIPPING!",
          message: "You're only {amount} away from FREE SHIPPING!"
        )
      end

      def test_managing_discount_messages
        visit admin.pricing_discounts_path

        click_link("Shipping Discount")

        assert(page.has_content?(t("workarea.admin.pricing_discounts.cards.message.header")))
        click_link(t("workarea.admin.pricing_discounts.cards.message.header"))

        fill_in "discount[message_applied]", with: "Discount Applied"
        fill_in "discount[message]", with: "Before amount {amount} after amount"

        click_button "save_discount_message"
        assert(page.has_content?("Success"))
      end

      def test_card_is_only_displayed_for_discounts_with_messaging_included
        visit admin.pricing_discount_path(@discount)
        assert(page.has_content?(t("workarea.admin.pricing_discounts.cards.message.header")))

        invalid_discount = create_quantity_fixed_price_discount()
        visit admin.pricing_discount_path(invalid_discount)
        refute(page.has_content?(t("workarea.admin.pricing_discounts.cards.message.header")))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-shipping_message-1.2.1 test/system/workarea/admin/free_shipping_message_system_test.rb
workarea-shipping_message-1.2.0 test/system/workarea/admin/free_shipping_message_system_test.rb