#---
#This unit test checks the export data function of webmip
#should check that all the tables are available for export
#may have some issues with the file downloads as I'm not sure how
#we handle these with ie and watir
#---
class Test_01_export_data < Test::Unit::TestCase
  #
  #Test we can logon to the system using the webmip administrator user’s login credentials
  #
  def test_01_data_export_screen_appears
    @@ie.goto(EXPORT_DATA)
    #we'll need to login
    login(JAMIE, JAMIE_PWD)
    assert(@@ie.contains_text('Data Export'),'The data export screen did not appear')
    assert(@@ie.select_list(:id, 'P5_TABLES').exists?,'The tables field was not available')
    assert(@@ie.select_list(:id, 'P5_COLUMN_NAMES').exists?,'The column headings field was not available')
    assert(@@ie.button(:id, 'Export Data').exists?,'The export data button was not available')        
  end
  #
  #Check that all the appropriate tables are listed for export
  #
  def test_02_correct_list_of_tables_displayed
    listoftablestoexport= %W[ACCESS_CONTROLS 
                             ADDRESSES 
                             ASSET_LOCATION_TYPES 
                             BASES 
                             BYPASS_REASONS 
                             CARE_CATEGORIES 
                             CONNECTION_ORIENTATIONS 
                             CONNECTION_TYPES 
                             CONTACT_MECHANISMS 
                             CONTACT_MECHANISM_TYPES 
                             COSTS 
                             DATA_ITEMS 
                             DATA_ITEM_ROLES 
                             DATA_ITEM_ROLES_IMPORT 
                             DRAWINGS 
                             ENQUIRIES 
                             ENQUIRY_EVENTS 
                             ENQUIRY_ROLES 
                             ENQUIRY_STATUS_TYPES 
                             ENQUIRY_TYPES
                             ERROR_LOGS
                             EXCEPTION_MESSAGES 
                             FILTERS 
                             FILTER_TYPES 
                             HOUSINGS 
                             HOUSING_TYPES 
                             METERS 
                             METER_SIZE_CODES 
                             METER_TYPES 
                             MODULES 
                             PARTIES 
                             PARTY_ADDRESSES 
                             PARTY_ADDRESS_ROLES 
                             PARTY_CONTACT_MECHANISMS 
                             PARTY_CONTACT_MECHANISM_ROLES 
                             PARTY_RELATIONSHIPS 
                             PARTY_RELATIONSHIP_TYPES 
                             PARTY_ROLES 
                             PASSWORDS 
                             QUOTES 
                             QUOTE_EVENTS 
                             QUOTE_ITEMS 
                             QUOTE_ROLES 
                             QUOTE_STATUSES 
                             REGIONS 
                             REGULATORS 
                             REGULATOR_TYPES 
                             RELIEF_VALVES 
                             RELIEF_VALVE_TYPES 
                             ROLE_TYPES 
                             SERVICE_PRESSURES 
                             SERVICE_PRESSURE_TYPES 
                             SLAMSHUT_TYPES 
                             SLAMSHUT_VALVES]
    assert_equal(listoftablestoexport,@@ie.select_list(:id, 'P5_TABLES').getAllContents ,'The expected table list for export was not found')
  end

 
end  