Preferences
-verify the preferences form loads
-verify that clicking cancel doesnt submit the form and closes the window. -verify that submitting the form on the landingpage changes the timerange
-verify that submitting the form from a search re-runs the search
-verify that after submitting a preference change, reloading the page shows the new preferences
-verify that after submitting a preference change, going to a permalink uses timerange from the permalink, not preferences

openAndWait / (open the main interface)
comment Wait for page to load up
waitForDispatchCompleted 30000
comment DOA check, open prefs popup and close it
click preferencesPopup
waitForElementPresent sbaFormElements 5000
pause 1000
click //form[@name='preferencesForm']//input[@value='Cancel']
pause 200
verifyNotVisible adminPopupLayer
comment DOA check, open prefs popup and close it
click preferencesPopup
waitForElementPresent sbaFormElements 5000
comment Check that negative values for maxresults are not allowed.
type //input[@name='maxResults'] -21312
click //div[@id='adminPopupLayer']//input[@value='Save']
assertAlert Max Results must be a positive integer.
comment Set the default time range to 24 hours
select //select[@name='defaultTimeRange'] Last 24 hours
comment Set the max results to 10000
type //input[@name='maxResults'] 10000
comment Save it
click //div[@id='adminPopupLayer']//input[@value='Save']
waitForNotVisible sbaFormElements
pause 500
verifySelectedLabel timelineValues Last 24 hours
pause 1000
click preferencesPopup
waitForElementPresent sbaFormElements 5000
verifyValue //input[@name='maxResults'] 10000
verifySelectedLabel //select[@name='defaultTimeRange'] Last 24 hours
comment Change it to all time, 3000 and check that on the landing page, this propagates.
select //select[@name='defaultTimeRange'] All time
type //input[@name='maxResults'] 3000
click //div[@id='adminPopupLayer']//input[@value='Save']
waitForNotVisible sbaFormElements
pause 500
verifySelectedLabel timelineValues All time
comment run a search.
type entry source="*apache.error.log"
click entrySubmit (Click submit button)
comment check that it persists the settings when we search.
waitForDispatchCompleted 10000
comment Verify >=3,000 search results with default time range set to the default relative value.
verifyText eventCount ≥3,000 results
comment Change from 3000 to 10000.
click preferencesPopup
waitForElementPresent sbaFormElements 5000
verifyValue //input[@name='maxResults'] 3000
comment Change it to all time, 10000 and check that it reruns the search.
select //select[@name='defaultTimeRange'] All time
type //input[@name='maxResults'] 10000
click //div[@id='adminPopupLayer']//input[@value='Save']
waitForNotVisible sbaFormElements
pause 500
comment wait for it to rerun the search
waitForDispatchCompleted 10000
comment Verify >=10,000 search results with default time range set to the default relative value.
verifyText eventCount ≥10,000 results
comment Change from 10000 to 7600.
click preferencesPopup
waitForElementPresent sbaFormElements 5000
verifyValue //input[@name='maxResults'] 10000
type //input[@name='maxResults'] 7600
click //div[@id='adminPopupLayer']//input[@value='Save']
waitForNotVisible sbaFormElements
pause 500
comment Reload the page.
openAndWait / (open the main interface)
comment Wait for page to load up
waitForDispatchCompleted 30000
type entry source="*apache.error.log"
click entrySubmit (Click submit button)
comment check that it persists the settings when we search.
waitForDispatchCompleted 10000
verifyText eventCount ≥7,600 results
comment Change back to 10000.
click preferencesPopup
waitForElementPresent sbaFormElements 5000
verifyValue //input[@name='maxResults'] 7600
type //input[@name='maxResults'] 10000
comment Change it to Last 24 hours.
select //select[@name='defaultTimeRange'] Last 24 hours
click //div[@id='adminPopupLayer']//input[@value='Save']
waitForNotVisible sbaFormElements
pause 500
comment Go to a permalink with time terms.
openAndWait /?q=source%3D%22*apache.error.log%22%20sourcetype%3Dapache_error%20reba%20startminutesago%3D60
comment Permalinks need a pause before dispatch even starts.
pause 2000
comment Wait for page to load up
waitForDispatchCompleted 30000
pause 1000
verifySelectedLabel timelineValues Last 60 minutes
verifyText eventCount 0 results