<commit_before>require 'spec_helper'

def make_some_form_changes
  expect(page).to_not have_content('Name helper text')
  click_link('Manage Form')
  fill_in('Release_name_label_input', with: 'Name edited')
  fill_in('Release_name_helper_input', with: 'Name helper text')
  click_link('Submit')
  expect(page).to have_content('* Name edited')
  expect(page).to have_content('Name helper text')
end

feature 'Form Manager' do

  before(:each) do
    admin_login
    release = FactoryGirl.create(:release, name: '2012 Chardonnay')
    visit edit_admin_release_path(release.id)
  end

  # Standard main forms.

  scenario 'form manager displays when launched, hides things, shows inputs', js: true do
    expect(page).to have_content('* Name')
    click_link('Manage Form')
    expect(page).to_not have_content('* Name')
    expect(page).to have_selector("input[value='Name']")
  end

  scenario 'form manager goes away and things show their new values', js: true do
    expect(page).to_not have_content('Name helper text')
    click_link('Manage Form')
    fill_in('Release_name_label_input', with: 'Name edited')
    fill_in('Release_name_helper_input', with: 'Name helper text')
    fill_in('Release_hero_image_label_input', with: 'Hero Image edited')
    fill_in('Release_hero_image_helper_input', with: 'Hero Image helper text edited')
    fill_in('Release_label_pdf_label_input', with: 'Label Pdf Edited')
    fill_in('Release_label_pdf_helper_input', with: 'Label Pdf helper text Edited')
    click_link('Submit')
    expect(page).to have_content('* Name edited')
    expect(page).to have_content('Name helper text')
    expect(page).to have_content('Hero Image edited')
    expect(page).to have_content('Hero Image helper text edited')
    # new stuff is persisted across page loads
    page.evaluate_script 'window.location.reload()'
    expect(page).to have_content('* Name edited')
    expect(page).to have_content('Name helper text')
    expect(page).to have_content('Hero Image edited')
    expect(page).to have_content('Hero Image helper text edited')
    expect(page).to have_content('Label Pdf Edited')
    expect(page).to have_content('Label Pdf helper text Edited')
  end

  # Flickering on dev
  # scenario 'form manager saves changes to db and page requests show changes', js: true do
  #   make_some_form_changes
  #   visit new_admin_release_path
  #   expect(page).to have_content('* Name edited')
  #   expect(page).to have_content('Name helper text')
  # end

  # Nested forms
<commit_msg>rm old test<commit_after>require 'spec_helper'

def make_some_form_changes
  expect(page).to_not have_content('Name helper text')
  click_link('Manage Form')
  fill_in('Release_name_label_input', with: 'Name edited')
  fill_in('Release_name_helper_input', with: 'Name helper text')
  click_link('Submit')
  expect(page).to have_content('* Name edited')
  expect(page).to have_content('Name helper text')
end

feature 'Form Manager' do

  before(:each) do
    admin_login
    release = FactoryGirl.create(:release, name: '2012 Chardonnay')
    visit edit_admin_release_path(release.id)
  end

  # Standard main forms.

  scenario 'form manager displays when launched, hides things, shows inputs', js: true do
    expect(page).to have_content('* Name')
    click_link('Manage Form')
    expect(page).to_not have_content('* Name')
    expect(page).to have_selector("input[value='Name']")
  end

  scenario 'form manager goes away and things show their new values', js: true do
    expect(page).to_not have_content('Name helper text')
    click_link('Manage Form')
    fill_in('Release_name_label_input', with: 'Name edited')
    fill_in('Release_name_helper_input', with: 'Name helper text')
    fill_in('Release_hero_image_label_input', with: 'Hero Image edited')
    fill_in('Release_hero_image_helper_input', with: 'Hero Image helper text edited')
    fill_in('Release_label_pdf_label_input', with: 'Label Pdf Edited')
    fill_in('Release_label_pdf_helper_input', with: 'Label Pdf helper text Edited')
    click_link('Submit')
    expect(page).to have_content('* Name edited')
    expect(page).to have_content('Name helper text')
    expect(page).to have_content('Hero Image edited')
    expect(page).to have_content('Hero Image helper text edited')
    # new stuff is persisted across page loads
    page.evaluate_script 'window.location.reload()'
    expect(page).to have_content('* Name edited')
    expect(page).to have_content('Name helper text')
    expect(page).to have_content('Hero Image edited')
    expect(page).to have_content('Hero Image helper text edited')
    expect(page).to have_content('Label Pdf Edited')
    expect(page).to have_content('Label Pdf helper text Edited')
  end

  # Nested forms

{'fraction_non_alphanumeric': 0.11383834109183241, 'fraction_numerical': 0.0016927634363097758, 'mean_word_length': 5.037037037037037, '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': '2744838', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1436, 'n_words': 398}