wip find session latency
This commit is contained in:
parent
20376500b5
commit
85d5044622
|
|
@ -30,6 +30,53 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
|
|||
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
|
||||
|
|
@ -45,7 +92,7 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
|
|||
|
||||
it "finds session" do
|
||||
in_client(finder_user) do
|
||||
response_body = mock_latency_response([{ user: user2, 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},
|
||||
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'})
|
||||
|
|
|
|||
Loading…
Reference in New Issue