<commit_before>require 'spec_helper'

# In order to reduce confusion and thereby grease the wheels of commerce
# As a customer
# <NAME> submits invalid or incomplete information and receives instant feedback

describe "A customer", type: :feature, js: true do
  before(:all) { configure_store }

  before do
    sign_up!
  end

  let(:beef_slab) { create(:product) }
  let!(:shipping_method) { create(:shipping_method) }

  context "when submitting invalid address details" do
    it "displays inline form-validation errors" do
      visit spree.product_path(beef_slab)

      # product.add_to_cart
      click_button 'Add To Cart'

      # cart.checkout
      click_button 'Checkout'

      # address.supply
      within '[data-hook=opco-shipping-address]' do
        within '[data-hook=opco-new-address]' do
          click_on 'Add Address'

          fill_in 'First Name', with: 'Guy'
          fill_in 'Last Name', with: 'Incognito'
          fill_in 'Address', with: '1234 Fake St.'
          fill_in 'City', with: 'New York City'
          select 'New York', from: 'State'
          fill_in 'Zip Code', with: '10001'
          fill_in 'Telephone', with: '555-555-1234'

          # Use the default country
          # select 'United States', from: 'Country'

          # Submit empty last name and zip-code
          fill_in 'Last Name', with: ''
          fill_in 'Zip Code', with: ''

          click_button 'Save'
        end
      end

      within '[data-hook=opco-shipping-address]' do
        expect(page).to have_content "can't be blank", count: 2
      end
    end
  end

  context "when submitting invalid credit-card information" do
    it "displays inline form-validation errors" do
      visit spree.product_path(beef_slab)

      # product.add_to_cart
      click_button 'Add To Cart'

      # cart.checkout
      click_button 'Checkout'

      # credit_card.create
      within '[data-hook=opco-payment-method]' do
        within '[data-hook=opco-new-credit-card]' do
          click_on 'Add Credit Card'

          fill_in 'Card Number', with: '4111111111111111'
          select '1', from: 'Expiration Month'
          select '2015', from: 'Expiration Year'
          fill_in 'Verification Value', with: '123'

          # Submit empty credit-card number and CVV
          fill_in 'Card Number', with: ''
          fill_in 'Verification Value', with: ''

          click_button 'Save'
        end
      end

      within '[data-hook=opco-payment-method]' do
        expect(page).to have_content "can't be blank", count: 2
      end
    end
  end
end
<commit_msg>Categorizes form-validation feature spec within new_customer role<commit_after>require 'spec_helper'

# In order to reduce confusion and thereby grease the wheels of commerce
# As a new customer
# <NAME> submits invalid or incomplete information and receives instant feedback

describe "A new customer", type: :feature, js: true do
  before(:all) { configure_store }

  before do
    sign_up!
  end

  let(:beef_slab) { create(:product) }
  let!(:shipping_method) { create(:shipping_method) }

  context "when submitting invalid address details" do
    it "displays inline form-validation errors" do
      visit spree.product_path(beef_slab)

      # product.add_to_cart
      click_button 'Add To Cart'

      # cart.checkout
      click_button 'Checkout'

      # address.supply
      within '[data-hook=opco-shipping-address]' do
        within '[data-hook=opco-new-address]' do
          click_on 'Add Address'

          fill_in 'First Name', with: 'Guy'
          fill_in 'Last Name', with: 'Incognito'
          fill_in 'Address', with: '1234 Fake St.'
          fill_in 'City', with: 'New York City'
          select 'New York', from: 'State'
          fill_in 'Zip Code', with: '10001'
          fill_in 'Telephone', with: '555-555-1234'

          # Use the default country
          # select 'United States', from: 'Country'

          # Submit empty last name and zip-code
          fill_in 'Last Name', with: ''
          fill_in 'Zip Code', with: ''

          click_button 'Save'
        end
      end

      within '[data-hook=opco-shipping-address]' do
        expect(page).to have_content "can't be blank", count: 2
      end
    end
  end

  context "when submitting invalid credit-card information" do
    it "displays inline form-validation errors" do
      visit spree.product_path(beef_slab)

      # product.add_to_cart
      click_button 'Add To Cart'

      # cart.checkout
      click_button 'Checkout'

      # credit_card.create
      within '[data-hook=opco-payment-method]' do
        within '[data-hook=opco-new-credit-card]' do
          click_on 'Add Credit Card'

          fill_in 'Card Number', with: '4111111111111111'
          select '1', from: 'Expiration Month'
          select '2015', from: 'Expiration Year'
          fill_in 'Verification Value', with: '123'

          # Submit empty credit-card number and CVV
          fill_in 'Card Number', with: ''
          fill_in 'Verification Value', with: ''

          click_button 'Save'
        end
      end

      within '[data-hook=opco-payment-method]' do
        expect(page).to have_content "can't be blank", count: 2
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.0977055449330784, 'fraction_numerical': 0.017208413001912046, 'mean_word_length': 2.4324146981627295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6265591', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1529, 'n_words': 488}