96 lines
3.3 KiB
Ruby
96 lines
3.3 KiB
Ruby
require 'spec_helper'
|
|
require 'webmock/rspec'
|
|
|
|
describe "Find session latency badge", js: true, type: :feature, capybara_feature: true do
|
|
let(:creator_user){ FactoryGirl.create(:user) }
|
|
let(:joiner_user){ FactoryGirl.create(:user) }
|
|
let(:finder_user){ FactoryGirl.create(:user) }
|
|
let(:latency_data_uri) { /\S+\/user_latencies/ }
|
|
|
|
def create_and_join_session(creator_user, joiner_user)
|
|
in_client(creator_user) do
|
|
fast_signin(creator_user, "/client#/createSession")
|
|
wait_until_curtain_gone
|
|
find("h1", text: "session")
|
|
find(".quick-start-open").click
|
|
end
|
|
in_client(joiner_user) do
|
|
joiner_response_body = mock_latency_response([{ user: joiner_user, ars_total_latency: 1.0, ars_internet_latency: 0.5, audio_latency: 0.5 }])
|
|
|
|
stub_request(:post, latency_data_uri)
|
|
.with(
|
|
:headers => {
|
|
'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}
|
|
)
|
|
.to_return( body: joiner_response_body, status: 200)
|
|
|
|
fast_signin(joiner_user, "/client#/findSession")
|
|
wait_until_curtain_gone
|
|
find("h1", text: "find a session")
|
|
find("a", text: "Open Jams").click
|
|
expect(page).to have_selector("#sessions-active .found-session", count: 1)
|
|
find("#sessions-active .found-session .join-link").click
|
|
find("#session-terms-conditions")
|
|
within("#session-terms-conditions") do
|
|
find("#btn-accept-terms").click
|
|
end
|
|
find("h1", text: "session")
|
|
end
|
|
end
|
|
|
|
|
|
before(:all) do
|
|
Capybara.default_max_wait_time = 10
|
|
end
|
|
|
|
describe "In public session" do
|
|
|
|
before(:each) do
|
|
emulate_client
|
|
ActiveMusicSession.delete_all
|
|
create_and_join_session(creator_user, joiner_user)
|
|
end
|
|
|
|
|
|
it "show GOOD" do
|
|
in_client(finder_user) do
|
|
creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: 1.0, ars_internet_latency: 0.5, audio_latency: 0.5 }]) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0},
|
|
|
|
|
|
stub_request(:post, latency_data_uri)
|
|
.with(
|
|
:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}
|
|
)
|
|
.to_return( body: creator_response_body, status: 200)
|
|
|
|
|
|
|
|
|
|
fast_signin(finder_user, "/client#/findSession")
|
|
wait_until_curtain_gone
|
|
find("h1", text: "find a session")
|
|
find("a", text: "Open Jams").click
|
|
expect(page).to have_selector("#sessions-active .found-session table.musicians-category tr", count: 2)
|
|
|
|
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "GOOD")
|
|
#expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD")
|
|
|
|
# selector = "#sessions-active a[data-user-id=\"#{creator_user.id}\"][data-hoveraction=\"musician\"]"
|
|
# find(selector, text: creator_user.name).hover_intent
|
|
# find('h3', text: creator_user.name)
|
|
# find("#musician-latency-badge .latency", text: 'GOOD')
|
|
# page.execute_script("$('#{selector}').mouseleave();")
|
|
# sleep(1)
|
|
|
|
# selector = "#sessions-active a[data-user-id=\"#{joiner_user.id}\"][data-hoveraction=\"musician\"]"
|
|
# find(selector, text: joiner_user.name).hover_intent
|
|
# find('h3', text: joiner_user.name)
|
|
# find("#musician-latency-badge .latency", text: 'GOOD')
|
|
# page.execute_script("$('#{selector}').mouseleave();")
|
|
# sleep(1)
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
end |