<commit_before># frozen_string_literal: true

require 'spec_helper'

feature "Registration", js: true do
  include AuthenticationHelper
  include WebHelper

  describe "Registering a Profile" do
    let(:user) { create(:user, password: "password", password_confirmation: "password") }

    before do
      Spree::Config.enterprises_require_tos = false

      albania = Spree::Country.create!({ name: "Albania", iso3: "ALB", iso: "AL", iso_name: "ALBANIA", numcode: "8" })
      Spree::State.create!({ name: "Berat", abbr: "BRA", country: albania })
      Spree::Country.create!({ name: "Chad", iso3: "TCD", iso: "TD", iso_name: "CHAD", numcode: "148" })
    end

    after do
      Spree::State.where(name: 'Berat').delete_all
      Spree::Country.where(name: 'Albania').delete_all
      Spree::Country.where(name: 'Chad').delete_all
    end

    it "Allows a logged in user to register a profile" do
      visit registration_path

      expect(Spree::Config.enterprises_require_tos).to eq false
      expect(URI.parse(current_url).path).to eq registration_auth_path

      page.has_selector? "dd", text: "Login"
      switch_to_login_tab

      # Enter Login details
      fill_in "Email", with: user.email
      fill_in "Password", with: <PASSWORD>

      click_button "Login"
      expect(page).to have_content("Hi there!")

      expect(URI.parse(current_url).path).to eq registration_path

      # Done reading introduction
      page.has_content?
      click_button "Let's get started!"
      expect(page).to have_content 'Woot!'

      # Filling in details
      fill_in 'enterprise_name', with: "My Awesome Enterprise"

      # Filling in address
      fill_in 'enterprise_address', with: '123 Abc Street'
      fill_in 'enterprise_city', with: 'Northcote'
      fill_in 'enterprise_zipcode', with: '3070'
      expect(page).to have_select('enterprise_country', options: %w(Albania Australia), selected: 'Australia')
      select 'Vic', from: 'enterprise_state'
      click_button "Continue"
      expect(page).to have_content 'Who is responsible for managing My Awesome Enterprise?'<commit_msg>Adapt matchers to capybara v3<commit_after># frozen_string_literal: true

require 'spec_helper'

feature "Registration", js: true do
  include AuthenticationHelper
  include WebHelper

  describe "Registering a Profile" do
    let(:user) { create(:user, password: "password", password_confirmation: "password") }

    before do
      Spree::Config.enterprises_require_tos = false

      albania = Spree::Country.create!({ name: "Albania", iso3: "ALB", iso: "AL", iso_name: "ALBANIA", numcode: "8" })
      Spree::State.create!({ name: "Berat", abbr: "BRA", country: albania })
      Spree::Country.create!({ name: "Chad", iso3: "TCD", iso: "TD", iso_name: "CHAD", numcode: "148" })
    end

    after do
      Spree::State.where(name: 'Berat').delete_all
      Spree::Country.where(name: 'Albania').delete_all
      Spree::Country.where(name: 'Chad').delete_all
    end

    it "Allows a logged in user to register a profile" do
      visit registration_path

      expect(Spree::Config.enterprises_require_tos).to eq false
      expect(URI.parse(current_url).path).to eq registration_auth_path

      page.has_selector? "dd", text: "Login"
      switch_to_login_tab

      # Enter Login details
      fill_in "Email", with: user.email
      fill_in "Password", with: <PASSWORD>

      click_button "Login"
      expect(page).to have_content("Hi there!")

      expect(URI.parse(current_url).path).to eq registration_path

      # Done reading introduction
      expect(page).to have_text "What do I get?"
      click_button "Let's get started!"
      expect(page).to have_content 'Woot!'

      # Filling in details
      fill_in 'enterprise_name', with: "My Awesome Enterprise"

      # Filling in address
      fill_in 'enterprise_address', with: '123 Abc Street'
      fill_in 'enterprise_city', with: 'Northcote'
      fill_in 'enterprise_zipcode', with: '3070'
      expect(page).to have_select('enterprise_country', options: ["Albania", "Australia"], selected: 'Australia')
      select 'Vic', from: 'enterprise_state'
      click_button "Continue"
      expect(page).to have_content 'Who is responsible for managing My Awesome Enterprise?'
{'fraction_non_alphanumeric': 0.12094117647058823, 'fraction_numerical': 0.006352941176470588, 'mean_word_length': 3.7338530066815143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '7381145', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1317, 'n_words': 352}