wip
This commit is contained in:
parent
85d5044622
commit
98898dd60e
|
|
@ -1,114 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
def mock_latency_response(collection)
|
||||
resp = []
|
||||
if collection && collection.any?
|
||||
resp = collection.map do |latency_item|
|
||||
user = latency_item[:user]
|
||||
latency = latency_item[:latency]
|
||||
audio_latency = latency_item[:audio_latency]
|
||||
audio_latency_unknown = latency_item[:audio_latency_unknown]
|
||||
ars_internet_latency = latency_item[:ars_internet_latency]
|
||||
ars_total_latency = latency_item[:ars_total_latency]
|
||||
p2p_internet_latency = latency_item[:p2p_internet_latency]
|
||||
p2p_total_latency = latency_item[:p2p_total_latency]
|
||||
wifi = latency_item[:wifi]
|
||||
|
||||
{
|
||||
"user_id": user.id,
|
||||
"first_name": user.first_name,
|
||||
"last_name": user.last_name,
|
||||
"audio_latency": audio_latency,
|
||||
"audio_latency_unknown": audio_latency_unknown,
|
||||
"ars": {
|
||||
"internet_latency": ars_internet_latency,
|
||||
"total_latency": ars_total_latency
|
||||
},
|
||||
"p2p": {
|
||||
"internet_latency": p2p_internet_latency,
|
||||
"total_latency": p2p_total_latency
|
||||
},
|
||||
"wifi": wifi
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
output = if resp.any?
|
||||
{
|
||||
"users": resp,
|
||||
"my_audio_latency": 4.0,
|
||||
"my_audio_latency_unknown": false
|
||||
}
|
||||
else
|
||||
{
|
||||
"users": []
|
||||
}
|
||||
end
|
||||
output.to_json
|
||||
end
|
||||
|
||||
before(:all) do
|
||||
Capybara.default_max_wait_time = 10
|
||||
end
|
||||
|
||||
describe "public session" do
|
||||
|
||||
before(:each) do
|
||||
emulate_client
|
||||
ActiveMusicSession.delete_all
|
||||
create_and_join_session(creator_user, joiner_user)
|
||||
end
|
||||
|
||||
|
||||
it "finds session" do
|
||||
in_client(finder_user) do
|
||||
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: 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)
|
||||
|
||||
find("#sessions-active a[data-user-id=\"#{creator_user.id}\"][data-hoveraction=\"musician\"]", text: creator_user.name).hover_intent
|
||||
find('h3', text: creator_user.name)
|
||||
find("#musician-latency-badge .latency", text: 'GOOD')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue