show latency badge in find session screen
This commit is contained in:
parent
6483c40f82
commit
d8fa7efdae
|
|
@ -192,11 +192,11 @@ LatencyActions = @LatencyActions
|
|||
|
||||
for session in sessionsChanged.sessions
|
||||
for participant in session.active_music_session.participants
|
||||
@state.participant_ids.push(participant.user.id)
|
||||
@state.participant_ids.push(participant.user.id) unless _.contains(@state.participant_ids, participant.user.id)
|
||||
|
||||
# for rsvp in session.approved_rsvps
|
||||
# @state.participant_ids.push(rsvp.id)
|
||||
#logger.debug("<<<<<<>>>>>>>>", _.unique(@state.participant_ids))
|
||||
for rsvp in session.approved_rsvps
|
||||
@state.participant_ids.push(rsvp.id) unless _.contains(@state.participant_ids, rsvp.id)
|
||||
|
||||
LatencyActions.resolve(_.unique(@state.participant_ids))
|
||||
@setState(sessionsChanged)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ SessionUtils = context.JK.SessionUtils
|
|||
instruments
|
||||
|
||||
createLatencyBadge: (userId) ->
|
||||
#logger.debug(">>>PARTICIPANT", userId)
|
||||
#logger.debug(">>>userLatencies", @state.userLatencies)
|
||||
#logger.debug(">>>userLatenciesFailed", @state.userLatenciesFailed)
|
||||
|
||||
latency = null
|
||||
failed = false
|
||||
|
||||
|
|
@ -46,8 +44,6 @@ SessionUtils = context.JK.SessionUtils
|
|||
failedId == userId
|
||||
)
|
||||
|
||||
logger.debug(">>>createLatencyBadge.latency = ", latency)
|
||||
logger.debug(">>>createLatencyBadge.failed =", failed)
|
||||
`<LatencyBadge latency={latency} failed={failed} />`
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ MAX_MINUTES_SHOW_START = 15
|
|||
<div className="instruments nowrap">{this.props.instruments}</div>
|
||||
</td>
|
||||
<td>
|
||||
<div className="latency-badge" data-user-id={userId}>{latencyBadge}</div>
|
||||
<div className="latency-badge find-session-latency-badge" data-user-id={userId}>{latencyBadge}</div>
|
||||
</td>
|
||||
{this.props.more}
|
||||
</tr>`
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ LATENCY = {
|
|||
@LatencyBadge = React.createClass({
|
||||
|
||||
render: () ->
|
||||
latencyDescription = @props.failed
|
||||
|
||||
if @props.latency
|
||||
latency = @props.latency
|
||||
|
|
@ -21,56 +20,54 @@ LATENCY = {
|
|||
|
||||
latencyDescription = ""
|
||||
latencyStyle = ""
|
||||
iconName = ""
|
||||
description = ""
|
||||
latencyDetails = ""
|
||||
#iconName = ""
|
||||
#description = ""
|
||||
#latencyDetails = ""
|
||||
|
||||
if !full_score || full_score <= LATENCY.UNKNOWN.max
|
||||
latencyDescription = LATENCY.UNKNOWN.description
|
||||
latencyStyle = LATENCY.UNKNOWN.style
|
||||
iconName = "purple"
|
||||
description = "missing"
|
||||
latencyDetails = ""
|
||||
#iconName = "purple"
|
||||
#description = "missing"
|
||||
#latencyDetails = ""
|
||||
else if full_score <= LATENCY.GOOD.max
|
||||
latencyDescription = LATENCY.GOOD.description
|
||||
latencyStyle = LATENCY.GOOD.style;
|
||||
iconName = "green"
|
||||
description = "good"
|
||||
latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
|
||||
#iconName = "green"
|
||||
#description = "good"
|
||||
#latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
|
||||
else if full_score <= LATENCY.MEDIUM.max
|
||||
latencyDescription = LATENCY.MEDIUM.description
|
||||
latencyStyle = LATENCY.MEDIUM.style
|
||||
iconName = "yellow"
|
||||
description = "fair"
|
||||
latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
|
||||
#iconName = "yellow"
|
||||
#description = "fair"
|
||||
#latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
|
||||
else if full_score <= LATENCY.POOR.max
|
||||
latencyDescription = LATENCY.POOR.description
|
||||
latencyStyle = LATENCY.POOR.style
|
||||
iconName = "red"
|
||||
description = "poor"
|
||||
latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
|
||||
#iconName = "red"
|
||||
#description = "poor"
|
||||
#latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
|
||||
else if full_score > LATENCY.UNACCEPTABLE.min
|
||||
latencyDescription = LATENCY.UNACCEPTABLE.description
|
||||
latencyStyle = LATENCY.UNACCEPTABLE.style
|
||||
iconName = "blue"
|
||||
description = "unacceptable"
|
||||
latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
|
||||
#iconName = "blue"
|
||||
#description = "unacceptable"
|
||||
#latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
|
||||
|
||||
else if @props.failed
|
||||
latencyDescription = LATENCY.FAILED.description
|
||||
latencyStyle = LATENCY.FAILED.style
|
||||
iconName = "gray"
|
||||
description = "failed"
|
||||
latencyDetails = ""
|
||||
|
||||
{
|
||||
latency_style: latencyStyle,
|
||||
latency_text: latencyDescription,
|
||||
icon_name: iconName,
|
||||
description: description,
|
||||
latency_details: latencyDetails
|
||||
}
|
||||
#iconName = "gray"
|
||||
#description = "failed"
|
||||
#latencyDetails = ""
|
||||
else
|
||||
latencyDescription = LATENCY.UNKNOWN.description
|
||||
latencyStyle = LATENCY.UNKNOWN.style
|
||||
#iconName = "gray"
|
||||
#description = "failed"
|
||||
#latencyDetails = ""
|
||||
|
||||
`<span className="latency {latencyStyle}">{latencyDescription}</span>`
|
||||
`<span className={latencyStyle}>{latencyDescription}</span>`
|
||||
|
||||
})
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
@import "client/common";
|
||||
|
||||
|
||||
table.findsession-table, table.local-recordings, table.open-jam-tracks, table.open-backing-tracks, table.cart-items, #account-session-detail, table.payment-table, table.jamtable {
|
||||
table.findsession-table, table.local-recordings, table.open-jam-tracks, table.open-backing-tracks, table.cart-items, #account-session-detail, table.payment-table, table.jamtable, .find-session-latency-badge {
|
||||
|
||||
.latency-unacceptable {
|
||||
width: 50px;
|
||||
|
|
@ -164,6 +164,11 @@ table.findsession-table, table.local-recordings, table.open-jam-tracks, table.op
|
|||
}
|
||||
}
|
||||
|
||||
.find-session-latency-badge{
|
||||
span{
|
||||
padding: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.avatar-tiny {
|
||||
float:left;
|
||||
|
|
|
|||
|
|
@ -3,32 +3,29 @@ 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(:user1){ FactoryGirl.create(:user) }
|
||||
let(:user2){ FactoryGirl.create(:user) }
|
||||
let(:user3){ FactoryGirl.create(:user) }
|
||||
let(:user4){ FactoryGirl.create(:user) }
|
||||
let(:latency_data_uri) { /\S+\/user_latencies/ }
|
||||
|
||||
def create_and_join_session(creator_user, joiner_user)
|
||||
def create_session(creator_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)
|
||||
end
|
||||
|
||||
def join_session(joiner_user)
|
||||
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
|
||||
|
|
@ -47,12 +44,12 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
|
|||
before(:each) do
|
||||
emulate_client
|
||||
ActiveMusicSession.delete_all
|
||||
create_and_join_session(creator_user, joiner_user)
|
||||
create_session(creator_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},
|
||||
creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: 1.0, ars_internet_latency: 0.5, audio_latency: 0.5 }])
|
||||
|
||||
stub_request(:post, latency_data_uri)
|
||||
.with(
|
||||
|
|
@ -60,19 +57,15 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
|
|||
)
|
||||
.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("#sessions-active .found-session table.musicians-category tr", count: 1)
|
||||
|
||||
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")
|
||||
|
||||
|
||||
save_screenshot("find_session_latency.png")
|
||||
|
||||
# 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)
|
||||
|
|
@ -89,7 +82,7 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
|
|||
end
|
||||
end
|
||||
|
||||
xit "show FAIR" do
|
||||
it "show FAIR" do
|
||||
in_client(finder_user) do
|
||||
creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: 41.0, ars_internet_latency: 21.0, audio_latency: 20.0 }])
|
||||
|
||||
|
|
@ -103,7 +96,7 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
|
|||
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("#sessions-active .found-session table.musicians-category tr", count: 1)
|
||||
|
||||
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "FAIR")
|
||||
#expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD")
|
||||
|
|
@ -111,6 +104,122 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
|
|||
end
|
||||
end
|
||||
|
||||
it "show POOR" do
|
||||
in_client(finder_user) do
|
||||
creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: 71.0, ars_internet_latency: 41.0, audio_latency: 30.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: 1)
|
||||
|
||||
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "POOR")
|
||||
#expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
it "show UNACCEPTABLE" do
|
||||
in_client(finder_user) do
|
||||
creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: 101.0, ars_internet_latency: 51.0, audio_latency: 50.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: 1)
|
||||
|
||||
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "UNACCEPTABLE")
|
||||
#expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
it "show UNKNOWN" do
|
||||
in_client(finder_user) do
|
||||
creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: -2, ars_internet_latency: 0, audio_latency: 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: 1)
|
||||
|
||||
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "UNKNOWN")
|
||||
#expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
it "show FAILED" do
|
||||
in_client(finder_user) do
|
||||
creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: -3, ars_internet_latency: 0, audio_latency: 0 }])
|
||||
|
||||
stub_request(:post, latency_data_uri)
|
||||
.to_raise("some error")
|
||||
|
||||
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: 1)
|
||||
|
||||
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "FAILED")
|
||||
#expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
it "shows latency of joiners of the session" do
|
||||
response_body = mock_latency_response([
|
||||
{ user: creator_user, ars_total_latency: 1.0, ars_internet_latency: 0.4, audio_latency: 0.6 }, #GOOD
|
||||
{ user: user1, ars_total_latency: 1.0, ars_internet_latency: 0.4, audio_latency: 0.6 }, #GOOD
|
||||
{ user: user2, ars_total_latency: 71.0, ars_internet_latency: 35, audio_latency: 36 }, #POOR
|
||||
{ user: user3, ars_total_latency: 41.0, ars_internet_latency: 15, audio_latency: 26.0 }, #FAIR
|
||||
{ user: user4, ars_total_latency: 101.0, ars_internet_latency: 31.75, audio_latency: 70.25 } #UNACCEPTABLE
|
||||
])
|
||||
|
||||
stub_request(:post, latency_data_uri)
|
||||
.with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'})
|
||||
.to_return( body: response_body, status: 200)
|
||||
|
||||
[user1, user2, user3, user4].each do |user|
|
||||
join_session(user)
|
||||
end
|
||||
|
||||
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: 5)
|
||||
|
||||
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=\"#{user1.id}\"]", text: "GOOD")
|
||||
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{user2.id}\"]", text: "POOR")
|
||||
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{user3.id}\"]", text: "FAIR")
|
||||
expect(page).to have_selector("div.latency-badge[data-user-id=\"#{user4.id}\"]", text: "UNACCEPTABLE")
|
||||
save_screenshot("findSessionLatency.png")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue