<commit_before># Copyright (C) 2007, 2008, The Collaborative Software Foundation
#
# This file is part of TriSano.
#
# TriSano is free software: you can redistribute it and/or modify it under the 
# terms of the GNU Affero General Public License as published by the 
# Free Software Foundation, either version 3 of the License, 
# or (at your option) any later version.
#
# TriSano is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License 
# along with TriSano. If not, see http://www.gnu.org/licenses/agpl-3.0.txt.

require File.dirname(__FILE__) + '/spec_helper'
require 'yaml'

describe "help text for morbidity core fields" do
  #   $dont_kill_browser = true
  
  core_fields = YAML::load_file(File.join(File.dirname(__FILE__), '..', '..', 'db', 'defaults', 'core_fields.yml'))

  before :all do
    @browser.open '/trisano/core_fields'
  end

  core_fields.collect{ |k,v| v }.select{|f| f['event_type'] == 'morbidity_event'}.each do |core_field|

    # Special exception for reporting agency, as a link needs to be clicked to bring this field into view.
    next if core_field['name'].downcase.include?("reporting agency")
    
    it "should edit #{core_field['event_type']} core field help text for #{core_field['name']}" do
      @browser.click("//div[@id='rot'][1]//a[text()='#{core_field['name']}']")
      @browser.wait_for_page_to_load
      @browser.click("link=Edit")
      @browser.wait_for_page_to_load
      @browser.type "core_field_help_text", "#{core_field['name']} help"
      @browser.click '//input[@value="Update"]'
      @browser.wait_for_page_to_load
      @browser.is_text_present('Core field was successfully updated').should be_true
      @browser.is_text_present("#{core_field['name']} help").should be_true
      @browser.click("link=< Back to Core Fields")
      @browser.wait_for_page_to_load
    end 

    it "should navigate to a morbidity event edit view" do
      @browser.click("link=NEW CMR")
      @browser.wait_for_page_to_load
    end

    it "should have #{core_field['event_type']} help bubble after #{core_field['name']}" do
      #@browser.click "//a[@id='add_reporting_agency_link']" if core_field['name'] == 'Reporting agency'
      assert_tooltip_exists(@browser, "#{core_field['name']} help").should be_true
      @browser.open("/trisano/core_fields")
      @browser.wait_for_page_to_load
    end
      
  end
end<commit_msg>Trying to debug a problem that occurs only on Hudson. Might commit multiple times. Sorry.<commit_after># Copyright (C) 2007, 2008, The Collaborative Software Foundation
#
# This file is part of TriSano.
#
# TriSano is free software: you can redistribute it and/or modify it under the 
# terms of the GNU Affero General Public License as published by the 
# Free Software Foundation, either version 3 of the License, 
# or (at your option) any later version.
#
# TriSano is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License 
# along with TriSano. If not, see http://www.gnu.org/licenses/agpl-3.0.txt.

require File.dirname(__FILE__) + '/spec_helper'
require 'yaml'

describe "help text for morbidity core fields" do
  #   $dont_kill_browser = true
  
  core_fields = YAML::load_file(File.join(File.dirname(__FILE__), '..', '..', 'db', 'defaults', 'core_fields.yml'))

  before :all do
#    @browser.open '/trisano/core_fields'
  end

  core_fields.collect{ |k,v| v }.select{|f| f['event_type'] == 'morbidity_event'}.each do |core_field|

    # Special exception for reporting agency, as a link needs to be clicked to bring this field into view.
    next if core_field['name'].downcase.include?("reporting agency")
    
    it "should edit #{core_field['event_type']} core field help text for #{core_field['name']}" do
      @browser.open("/trisano/core_fields")
      @browser.wait_for_page_to_load
      @browser.click("//div[@id='rot'][1]//a[text()='#{core_field['name']}']")
      @browser.wait_for_page_to_load
      @browser.click("link=Edit")
      @browser.wait_for_page_to_load
      @browser.type "core_field_help_text", "#{core_field['name']} help"
      @browser.click '//input[@value="Update"]'
      @browser.wait_for_page_to_load
      @browser.is_text_present('Core field was successfully updated').should be_true
      @browser.is_text_present("#{core_field['name']} help").should be_true
    end

    it "should navigate to a morbidity event edit view" do
      @browser.click("link=NEW CMR")
      @browser.wait_for_page_to_load
    end

    it "should have #{core_field['event_type']} help bubble after #{core_field['name']}" do
      @browser.click "//a[@id='add_reporting_agency_link']" if core_field['name'] == 'Reporting agency'
      assert_tooltip_exists(@browser, "#{core_field['name']} help").should be_true     
    end
      
  end
end
{'fraction_non_alphanumeric': 0.12271689497716895, 'fraction_numerical': 0.0045662100456621, 'mean_word_length': 4.0939922480620154, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4823408', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1619, 'n_words': 499}