<commit_before>require File.expand_path(File.dirname(__FILE__) + '/common')

shared_examples_for "discussions selenium tests" do
  it_should_behave_like "in-process server selenium tests"

  it "should not record a javascript error when creating the first topic" do
    course_with_teacher_logged_in

    get "/courses/#{@course.id}/discussion_topics"

    driver.find_element(:css, ".add_topic_link").click
    driver.execute_script("return INST.errorCount;").should == 0

    form = keep_trying_until {
      driver.find_element(:id, 'add_topic_form_topic_new')
    }

    tiny_frame = wait_for_tiny(form.find_element(:css, '.content_box'))
    in_frame tiny_frame["id"] do
      driver.find_element(:id, 'tinymce').send_keys('This is the discussion description.')
    end
    form.find_element(:id, "discussion_topic_title").send_keys("This is my test title")
    form.find_element(:css, ".submit_button").click
    keep_trying_until { DiscussionTopic.count.should == 1 }

    find_all_with_jquery(".add_topic_form_new:visible").length.should == 0
    driver.execute_script("return INST.errorCount;").should == 0
  end
end<commit_msg>fix discussions selenium failure<commit_after>require File.expand_path(File.dirname(__FILE__) + '/common')

shared_examples_for "discussions selenium tests" do
  it_should_behave_like "in-process server selenium tests"

  it "should not record a javascript error when creating the first topic" do
    course_with_teacher_logged_in

    get "/courses/#{@course.id}/discussion_topics"

    form = keep_trying_until {
      driver.find_element(:css, ".add_topic_link").click
      driver.find_element(:id, 'add_topic_form_topic_new')
    }
    driver.execute_script("return INST.errorCount;").should == 0

    tiny_frame = wait_for_tiny(form.find_element(:css, '.content_box'))
    in_frame tiny_frame["id"] do
      driver.find_element(:id, 'tinymce').send_keys('This is the discussion description.')
    end
    form.find_element(:id, "discussion_topic_title").send_keys("This is my test title")
    form.find_element(:css, ".submit_button").click
    keep_trying_until { DiscussionTopic.count.should == 1 }

    find_all_with_jquery(".add_topic_form_new:visible").length.should == 0
    driver.execute_script("return INST.errorCount;").should == 0
  end
end
{'fraction_non_alphanumeric': 0.11682650392327812, 'fraction_numerical': 0.0034873583260680036, 'mean_word_length': 4.869565217391305, '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': '906477', 'n_tokens_mistral': 755, 'n_tokens_neox': 709, 'n_words': 140}