<commit_before>require 'rails_helper'

RSpec.feature 'Requested Enhancements', :focus, js: true do
  let!(:provider) { create(:provider) }

  background do
    attrs = create(:aaf_attributes, :from_subject, subject: user)
    RapidRack::TestAuthenticator.jwt = create(:jwt, aaf_attributes: attrs)

    visit '/auth/login'
    click_button 'Login'

    expect(current_path).to eq('/dashboard')
  end

  context 'as a regular user' do
    let(:user) { create(:subject) }
    let(:attrs) { attributes_for(:requested_enhancement) }

    it 'requests the enhancement' do
      click_link('Request Enhancement')

      within('.search form') do
        fill_in(:filter, with: provider.name)
        click_button('Search')
      end

      within('tr', text: provider.name) do
        click_link('Select')
      end

      within('form') do<commit_msg>Remove focus from capybara spec<commit_after>require 'rails_helper'

RSpec.feature 'Requested Enhancements', js: true do
  let!(:provider) { create(:provider) }

  background do
    attrs = create(:aaf_attributes, :from_subject, subject: user)
    RapidRack::TestAuthenticator.jwt = create(:jwt, aaf_attributes: attrs)

    visit '/auth/login'
    click_button 'Login'

    expect(current_path).to eq('/dashboard')
  end

  context 'as a regular user' do
    let(:user) { create(:subject) }
    let(:attrs) { attributes_for(:requested_enhancement) }

    it 'requests the enhancement' do
      click_link('Request Enhancement')

      within('.search form') do
        fill_in(:filter, with: provider.name)
        click_button('Search')
      end

      within('tr', text: provider.name) do
        click_link('Select')
      end

      within('form') do
{'fraction_non_alphanumeric': 0.12352941176470589, 'fraction_numerical': 0.0, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4218991', 'n_tokens_mistral': 536, 'n_tokens_neox': 513, 'n_words': 126}