<commit_before>require File.join(File.dirname(__FILE__), 'spec_helper')

describe "save as Menu" do
  before do

    login('edcadmin', 'secret')
    visit("#/workspaces")

    click_button "Create Workspace"
    within("#facebox") do
      fill_in 'name', :with => "partyman#{Time.now.to_i}"
      click_button "Create Workspace"
    end
    wait_until { current_route =~ /workspaces\/\d+/ }

    click_link "Work Files"
    wait_until { current_route =~ /workspaces\/\d+\/workfiles/ }

    click_button "Create SQL File"
    fill_in 'fileName', :with => "wicked_data#{Time.now.to_i}"
    click_button "Add SQL File"
    wait_until { current_route =~ /workspaces\/\d+\/workfiles\/\d+/ }

  end
  it "pops up the right menu" do

    page.find(".save_options .save_as_new").should_not be_visible
    page.find(".save_options .save_as_current").should_not be_visible
    page.find(".save .save_as").click
    wait_until { page.find(".qtip[aria-hidden=false]") }
    page.find("a.save_as_new").should be_visible
    page.find("a.save_as_current").should be_visible

  end

  it "click the save as replace version" do
    page.execute_script('chorus.page.mainContent.content.editor.setValue("new Blood")')
    page.find(".save .save_as").click
    wait_until { page.find(".qtip[aria-hidden=false]") }
    page.find("a.save_as_current").click
    wait_until { page.find(".qtip[aria-hidden=true]") }
    page.find("textarea.text_editor").should have_content('new Blood')
  end

  it "click the save as new  version" do
    page.execute_script('chorus.page.mainContent.content.editor.setValue("new Blood -2")')
    page.find(".save .save_as").click
    wait_until { page.find(".qtip[aria-hidden=false]") }
    page.find("a.save_as_new").click
    wait_until { page.find(".qtip[aria-hidden=true]") }
    fill_in 'commitMessage', :with => "commit Message -2"
    click_button "Save New Version"
    wait_until { current_route =~ /workspaces\/\d+\/workfiles\/\d+/ }
    page.find("textarea.text_editor").should have_content('new Blood -2')
  end
end<commit_msg>Wait until codemirror has initialized<commit_after>require File.join(File.dirname(__FILE__), 'spec_helper')

describe "save as Menu" do
  before do

    login('edcadmin', 'secret')
    visit("#/workspaces")

    click_button "Create Workspace"
    within("#facebox") do
      fill_in 'name', :with => "partyman#{Time.now.to_i}"
      click_button "Create Workspace"
    end
    wait_until { current_route =~ /workspaces\/\d+/ }

    click_link "Work Files"
    wait_until { current_route =~ /workspaces\/\d+\/workfiles/ }

    click_button "Create SQL File"
    fill_in 'fileName', :with => "wicked_data#{Time.now.to_i}"
    click_button "Add SQL File"
    wait_until { current_route =~ /workspaces\/\d+\/workfiles\/\d+/ }
    wait_until { evaluate_script('$(".content").css("height")').to_i > 10 }
  end
  it "pops up the right menu" do

    page.find(".save_options .save_as_new").should_not be_visible
    page.find(".save_options .save_as_current").should_not be_visible
    page.find(".save .save_as").click
    wait_until { page.find(".qtip[aria-hidden=false]") }
    page.find("a.save_as_new").should be_visible
    page.find("a.save_as_current").should be_visible

  end

  it "click the save as replace version" do
    page.execute_script('chorus.page.mainContent.content.editor.setValue("new Blood")')
    page.find(".save .save_as").click
    wait_until { page.find(".qtip[aria-hidden=false]") }
    page.find("a.save_as_current").click
    wait_until { page.find(".qtip[aria-hidden=true]") }
    page.find("textarea.text_editor").should have_content('new Blood')
  end

  it "click the save as new  version" do
    page.execute_script('chorus.page.mainContent.content.editor.setValue("new Blood -2")')
    page.find(".save .save_as").click
    wait_until { page.find(".qtip[aria-hidden=false]") }
    page.find("a.save_as_new").click
    wait_until { page.find(".qtip[aria-hidden=true]") }
    fill_in 'commitMessage', :with => "commit Message -2"
    click_button "Save New Version"
    wait_until { current_route =~ /workspaces\/\d+\/workfiles\/\d+/ }
    page.find("textarea.text_editor").should have_content('new Blood -2')
  end
end
{'fraction_non_alphanumeric': 0.15646582519647534, 'fraction_numerical': 0.0019052155275065491, 'mean_word_length': 3.7565118912797284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '5889979', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1418, 'n_words': 268}