167 lines
5.1 KiB
Ruby
167 lines
5.1 KiB
Ruby
|
|
# methods here all assume you are in /client
|
|
|
|
NOTIFICATION_PANEL = '[layout-id="panelNotifications"]'
|
|
|
|
# enters text into the search sidebar
|
|
def site_search(text, options = {})
|
|
within('#searchForm') do
|
|
fill_in "search-input", with: text
|
|
end
|
|
|
|
if options[:expand]
|
|
page.driver.execute_script("jQuery('#searchForm').submit()")
|
|
find('h1', text:'search results')
|
|
end
|
|
end
|
|
|
|
# goes to the musician tile, and tries to find a musician
|
|
def find_musician(user)
|
|
visit "/client#/musicians"
|
|
|
|
timeout = 30
|
|
|
|
start = Time.now
|
|
# scroll by 100px until we find a user with the right id
|
|
while page.all('#end-of-musician-list').length == 0
|
|
page.execute_script('jQuery("#musician-filter-results").scrollTo("+=100px", 0, {axis:"y"})')
|
|
found = page.all(".result-list-button-wrapper[data-musician-id='#{user.id}']")
|
|
if found.length == 1
|
|
return found[0]
|
|
elsif found.length > 1
|
|
raise "ambiguous results in musician list"
|
|
end
|
|
|
|
if Time.now - start > timeout
|
|
raise "unable to find musician #{user.id} within #{timeout} seconds"
|
|
end
|
|
end
|
|
|
|
raise "unable to find musician #{user.id}"
|
|
end
|
|
|
|
def initiate_text_dialog(user)
|
|
|
|
# verify that the chat window is grayed out
|
|
site_search(user.first_name, expand: true)
|
|
|
|
find("#search-results a[user-id=\"#{user.id}\"][hoveraction=\"musician\"]", text: user.name).hover_intent
|
|
find('#musician-hover #btnMessage').trigger(:click)
|
|
find('h1', text: 'conversation with ' + user.name)
|
|
end
|
|
|
|
# sends a text message in the chat interface.
|
|
def send_text_message(msg, options={})
|
|
find('#text-message-dialog') # assert that the dialog is showing already
|
|
|
|
within('#text-message-dialog form.text-message-box') do
|
|
fill_in 'new-text-message', with: msg
|
|
end
|
|
find('#text-message-dialog .btn-send-text-message').trigger(:click)
|
|
find('#text-message-dialog .previous-message-text', text: msg) unless options[:should_fail]
|
|
|
|
# close the dialog if caller specified close_on_send
|
|
if options[:close_on_send]
|
|
find('#text-message-dialog .btn-close-dialog', text: 'CLOSE').trigger(:click) if options[:close_on_send]
|
|
page.should have_no_selector('#text-message-dialog')
|
|
end
|
|
|
|
if options[:should_fail]
|
|
find('#notification').should have_text(options[:should_fail])
|
|
end
|
|
end
|
|
|
|
# sends a chat message during session
|
|
def send_chat_message(msg)
|
|
find("[layout-id=\"panelChat\"] .chat-sender").should be_visible
|
|
|
|
within("[layout-id=\"panelChat\"] .chat-sender form.chat-message-form") do
|
|
fill_in 'new-chat-message', with: msg
|
|
end
|
|
find("[layout-id=\"panelChat\"] .chat-sender .btn-send-chat-message").trigger(:click)
|
|
end
|
|
|
|
def open_notifications
|
|
find("#{NOTIFICATION_PANEL} .panel-header").trigger(:click)
|
|
end
|
|
|
|
|
|
def hover_intent(element)
|
|
element.hover
|
|
element.hover
|
|
end
|
|
|
|
# forces document.hasFocus() to return false
|
|
def document_blur
|
|
page.evaluate_script(%{(function() {
|
|
// save original
|
|
if(!window.documentFocus) { window.documentFocus = window.document.hasFocus; }
|
|
|
|
window.document.hasFocus = function() {
|
|
console.log("document.hasFocus() returns false");
|
|
return false;
|
|
}
|
|
})()})
|
|
end
|
|
|
|
def document_focus
|
|
page.evaluate_script(%{(function() {
|
|
// save original
|
|
if(!window.documentFocus) { window.documentFocus = window.document.hasFocus; }
|
|
|
|
window.document.hasFocus = function() {
|
|
console.log("document.hasFocus() returns true");
|
|
return true;
|
|
}
|
|
})()})
|
|
end
|
|
|
|
# simulates focus event on window
|
|
def window_focus
|
|
page.evaluate_script(%{window.jQuery(window).trigger('focus');})
|
|
end
|
|
|
|
def close_websocket
|
|
page.evaluate_script("window.JK.JamServer.close(true)")
|
|
end
|
|
|
|
# does not launch it; expects that to have just been done
|
|
def walk_gear_wizard
|
|
# step 1 - intro
|
|
find('.btn-next').trigger(:click)
|
|
|
|
# step 2 - select gear
|
|
find('.ftue-step-title', text: 'Select & Test Audio Gear')
|
|
should_not have_selector('.resync-status') # when you enter this step,
|
|
jk_select('Built-in', 'div[layout-wizard-step="1"] select.select-audio-input-device')
|
|
find('.btn-next.button-orange:not(.disabled)').trigger(:click)
|
|
|
|
# step 3 - configure tracks
|
|
find('.ftue-step-title', text: 'Configure Tracks')
|
|
|
|
# drag one input over to tracks area http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Element#drag_to-instance_method
|
|
input = first('.ftue-input')
|
|
track_slot = first('.track-target')
|
|
input.drag_to(track_slot)
|
|
|
|
find('.btn-next.button-orange:not(.disabled)').trigger(:click)
|
|
|
|
# step 4 - configure voice chat
|
|
find('.ftue-step-title', text: 'Configure Voice Chat')
|
|
find('.btn-next.button-orange:not(.disabled)').trigger(:click)
|
|
|
|
# step 5 - configure direct monitoring
|
|
find('.ftue-step-title', text: 'Turn Off Direct Monitoring')
|
|
find('.btn-next.button-orange:not(.disabled)').trigger(:click)
|
|
|
|
# step 6 - Test Router & Network
|
|
find('.ftue-step-title', text: 'Test Router & Network')
|
|
find('.button-orange.start-network-test').trigger(:click)
|
|
find('.user-btn', text: 'RUN NETWORK TEST ANYWAY').trigger(:click)
|
|
find('.button-orange.start-network-test')
|
|
find('.btn-next.button-orange:not(.disabled)').trigger(:click)
|
|
|
|
# step 7 - Success
|
|
find('.ftue-step-title', text: 'Success!')
|
|
find('.btn-close.button-orange').trigger(:click)
|
|
end |