Sha256: 059ffd72af85065369e55c50db24614d033335e55414c21421627fab2916ad67

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Managing volume prices' do
  stub_authorization!

  let(:variant) { create(:variant) }

  it 'a admin can create and remove volume prices', :js do
    visit spree.edit_admin_product_path(variant.product)
    click_on 'Volume Pricing'
    expect(page).to have_content('Volume Prices')

    fill_in 'variant_volume_prices_attributes_0_name', with: '5 pieces discount'
    select 'Total price', from: 'variant_volume_prices_attributes_0_discount_type'
    fill_in 'variant_volume_prices_attributes_0_range', with: '1..5'
    fill_in 'variant_volume_prices_attributes_0_amount', with: '1'
    click_on 'Update'

    within 'tr.volume_price.fields' do
      expect(page).to have_field('variant_volume_prices_attributes_0_name', with: '5 pieces discount')
      page.find('a[data-action="remove"]').click
      expect(page).not_to have_field('variant_volume_prices_attributes_0_name', with: '5 pieces discount')
    end
  end

  it 'a admin editing a variant has a new volume price already built for her' do
    visit spree.edit_admin_product_variant_path(product_id: variant.product, id: variant)
    within '#volume_prices' do
      expect(page).to have_field('variant_volume_prices_attributes_0_name')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_volume_pricing-1.0.0 spec/features/manage_volume_prices_feature_spec.rb