testing hover latency badge
This commit is contained in:
parent
683e93e75e
commit
4f9ffa6a80
|
|
@ -7,23 +7,25 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature =>
|
||||||
|
|
||||||
let(:latency_data_uri) { /\S+\/dev\/user_latencies/ }
|
let(:latency_data_uri) { /\S+\/dev\/user_latencies/ }
|
||||||
|
|
||||||
before(:all) do
|
before do
|
||||||
Capybara.current_driver = :jamkazam
|
#Capybara.current_driver = :jamkazam
|
||||||
WebMock.disable_net_connect!(allow_localhost: true)
|
WebMock.disable_net_connect!(allow_localhost: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:all) do
|
after do
|
||||||
Capybara.use_default_driver
|
#Capybara.use_default_driver
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
fast_signin(user1, "/client")
|
fast_signin(user1, "/client")
|
||||||
wait_until_curtain_gone
|
wait_until_curtain_gone
|
||||||
|
#sleep(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe "Latency badge" do
|
describe "Latency badge" do
|
||||||
|
|
||||||
it "show FAILED" do
|
xit "show FAILED", focus: true do
|
||||||
response_body = latency_response(user2, -3) #sessionUtils.LATENCY.FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3}
|
response_body = latency_response(user2, -3) #sessionUtils.LATENCY.FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3}
|
||||||
stub_request(:post, latency_data_uri)
|
stub_request(:post, latency_data_uri)
|
||||||
.to_return( body: response_body, status: 200)
|
.to_return( body: response_body, status: 200)
|
||||||
|
|
@ -32,89 +34,97 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature =>
|
||||||
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
||||||
find('h3', text: user2.name)
|
find('h3', text: user2.name)
|
||||||
find("#musician-latency-badge div.latency", text: 'FAILED')
|
find("#musician-latency-badge div.latency", text: 'FAILED')
|
||||||
|
sleep(1)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it "show GOOD" do
|
|
||||||
response_body = latency_response(user2, 0.0) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0},
|
|
||||||
stub_request(:post, latency_data_uri)
|
|
||||||
.to_return( body: response_body, status: 200)
|
|
||||||
|
|
||||||
site_search(user2.first_name, expand: true)
|
|
||||||
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
|
||||||
find('h3', text: user2.name)
|
|
||||||
find("#musician-latency-badge div.latency", text: 'GOOD')
|
|
||||||
end
|
|
||||||
|
|
||||||
it "show MEDIUM" do
|
|
||||||
response_body = latency_response(user2, 41) #MEDIUM : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0},
|
|
||||||
stub_request(:post, latency_data_uri)
|
|
||||||
.to_return( body: response_body, status: 200)
|
|
||||||
|
|
||||||
site_search(user2.first_name, expand: true)
|
|
||||||
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
|
||||||
find('h3', text: user2.name)
|
|
||||||
find("#musician-latency-badge div.latency", text: 'MEDIUM')
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
it "show POOR" do
|
|
||||||
response_body = latency_response(user2, 71) #POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100},
|
|
||||||
stub_request(:post, latency_data_uri)
|
|
||||||
.to_return( body: response_body, status: 200)
|
|
||||||
|
|
||||||
site_search(user2.first_name, expand: true)
|
|
||||||
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
|
||||||
find('h3', text: user2.name)
|
|
||||||
find("#musician-latency-badge div.latency", text: 'POOR')
|
|
||||||
end
|
|
||||||
|
|
||||||
it "show UNACCEPTABLE" do
|
|
||||||
response_body = latency_response(user2, 101) #UNACCEPTABLE : {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100.0, max: 10000000},
|
|
||||||
stub_request(:post, latency_data_uri)
|
|
||||||
.to_return( body: response_body, status: 200)
|
|
||||||
|
|
||||||
site_search(user2.first_name, expand: true)
|
|
||||||
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
|
||||||
find('h3', text: user2.name)
|
|
||||||
find("#musician-latency-badge div.latency", text: 'UNACCEPTABLE')
|
|
||||||
end
|
|
||||||
|
|
||||||
it "show UNKNOWN" do
|
|
||||||
response_body = latency_response(user2, -2) #UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2}
|
|
||||||
stub_request(:post, latency_data_uri)
|
|
||||||
.to_return( body: response_body, status: 200)
|
|
||||||
|
|
||||||
site_search(user2.first_name, expand: true)
|
|
||||||
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
|
||||||
find('h3', text: user2.name)
|
|
||||||
find("#musician-latency-badge div.latency", text: 'UNKNOWN')
|
|
||||||
end
|
|
||||||
|
|
||||||
def latency_response(user, latency)
|
|
||||||
{
|
|
||||||
"users": [
|
|
||||||
{
|
|
||||||
"user_id": user.id,
|
|
||||||
"first_name": user.first_name,
|
|
||||||
"last_name": user.last_name,
|
|
||||||
"audio_latency": 4.0,
|
|
||||||
"audio_latency_unknown": false,
|
|
||||||
"ars": {
|
|
||||||
"internet_latency": latency,
|
|
||||||
"total_latency": latency
|
|
||||||
},
|
|
||||||
"p2p": {
|
|
||||||
"internet_latency": latency,
|
|
||||||
"total_latency": latency
|
|
||||||
},
|
|
||||||
"wifi": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"my_audio_latency": 4.0,
|
|
||||||
"my_audio_latency_unknown": false
|
|
||||||
}.to_json
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
it "show POOR", focus: true do
|
||||||
|
response_body = latency_response(user2, 71.0) #sessionUtils.LATENCY.POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100},
|
||||||
|
stub_request(:post, latency_data_uri)
|
||||||
|
.to_return( body: response_body, status: 200)
|
||||||
|
|
||||||
|
site_search(user2.first_name, expand: true)
|
||||||
|
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
||||||
|
find('h3', text: user2.name)
|
||||||
|
find("#musician-latency-badge div.latency", text: 'POOR')
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "show GOOD", focus: true do
|
||||||
|
response_body = latency_response(user2, 1.0) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0},
|
||||||
|
stub_request(:post, latency_data_uri)
|
||||||
|
.to_return( body: response_body, status: 200)
|
||||||
|
|
||||||
|
site_search(user2.first_name, expand: true)
|
||||||
|
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
||||||
|
find('h3', text: user2.name)
|
||||||
|
find("#musician-latency-badge div.latency", text: 'GOOD')
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "show FAIR", focus: true do
|
||||||
|
response_body = latency_response(user2, 41.0) #sessionUtils.LATENCY.FAIR : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0},
|
||||||
|
stub_request(:post, latency_data_uri)
|
||||||
|
.to_return( body: response_body, status: 200)
|
||||||
|
|
||||||
|
site_search(user2.first_name, expand: true)
|
||||||
|
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
||||||
|
find('h3', text: user2.name)
|
||||||
|
find("#musician-latency-badge div.latency", text: 'FAIR')
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it "show UNACCEPTABLE", focus: true do
|
||||||
|
response_body = latency_response(user2, 101.0) #sessionUtils.LATENCY.UNACCEPTABLE : {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100.0, max: 10000000},
|
||||||
|
stub_request(:post, latency_data_uri)
|
||||||
|
.to_return( body: response_body, status: 200)
|
||||||
|
|
||||||
|
site_search(user2.first_name, expand: true)
|
||||||
|
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
||||||
|
find('h3', text: user2.name)
|
||||||
|
find("#musician-latency-badge div.latency", text: 'UNACCEPTABLE')
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "show UNKNOWN", focus: true do
|
||||||
|
response_body = latency_response(user2, nil) #sessionUtils.LATENCY.UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2}
|
||||||
|
stub_request(:post, latency_data_uri)
|
||||||
|
.to_return( body: response_body, status: 200)
|
||||||
|
|
||||||
|
site_search(user2.first_name, expand: true)
|
||||||
|
find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent
|
||||||
|
find('h3', text: user2.name)
|
||||||
|
find("#musician-latency-badge div.latency", text: 'UNKNOWN')
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
def latency_response(user, latency)
|
||||||
|
resp = {
|
||||||
|
"users": [
|
||||||
|
{
|
||||||
|
"user_id": user.id,
|
||||||
|
"first_name": user.first_name,
|
||||||
|
"last_name": user.last_name,
|
||||||
|
"audio_latency": 4.0,
|
||||||
|
"audio_latency_unknown": false,
|
||||||
|
"ars": {
|
||||||
|
"internet_latency": latency,
|
||||||
|
"total_latency": latency
|
||||||
|
},
|
||||||
|
"p2p": {
|
||||||
|
"internet_latency": latency,
|
||||||
|
"total_latency": latency
|
||||||
|
},
|
||||||
|
"wifi": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"my_audio_latency": 4.0,
|
||||||
|
"my_audio_latency_unknown": false
|
||||||
|
}
|
||||||
|
#resp[:users][0][:ars][:total_latency] = latency unless latency.nil?
|
||||||
|
resp.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue