wip
This commit is contained in:
parent
8ab287ed73
commit
65cfa7c0fc
|
|
@ -1,6 +1,7 @@
|
|||
context = window
|
||||
|
||||
SessionsActions = @SessionsActions
|
||||
LatencyActions = @LatencyActions
|
||||
|
||||
@FindSessionOpen = React.createClass({
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ SessionsActions = @SessionsActions
|
|||
registeredInfiniteScroll: false
|
||||
|
||||
getInitialState: () ->
|
||||
{active: false, sessions: [], searching: false, count: 0, currentPage: 0, end: false}
|
||||
{active: false, sessions: [], searching: false, count: 0, currentPage: 0, end: false, participant_ids: []}
|
||||
|
||||
sessionResults: () ->
|
||||
results = []
|
||||
|
|
@ -188,6 +189,15 @@ SessionsActions = @SessionsActions
|
|||
|
||||
onSessionsChanged: (sessionsChanged) ->
|
||||
if sessionsChanged.type == @props.mode
|
||||
|
||||
for session in sessionsChanged.sessions
|
||||
for participant in session.active_music_session.participants
|
||||
@state.participant_ids.push(participant.user.id)
|
||||
|
||||
# for rsvp in session.approved_rsvps
|
||||
# @state.participant_ids.push(rsvp.id)
|
||||
#logger.debug("<<<<<<>>>>>>>>", _.unique(@state.participant_ids))
|
||||
LatencyActions.resolve(_.unique(@state.participant_ids))
|
||||
@setState(sessionsChanged)
|
||||
|
||||
})
|
||||
|
|
@ -5,13 +5,16 @@ EVENTS = context.JK.EVENTS
|
|||
SessionsActions = context.SessionsActions
|
||||
AppStore = context.AppStore
|
||||
MAX_MINUTES_SHOW_START = 15
|
||||
SessionUtils = context.JK.SessionUtils
|
||||
|
||||
@FindSessionRow = React.createClass({
|
||||
|
||||
mixins: [Reflux.listenTo(@LatencyStore, "onLatencyUpdate")]
|
||||
|
||||
ui: null
|
||||
|
||||
getInitialState: () ->
|
||||
{rsvpToggle: false, openSlotToggle: false}
|
||||
{ rsvpToggle: false, openSlotToggle: false, userLatencies: [] }
|
||||
|
||||
createInstrument: (participant) ->
|
||||
|
||||
|
|
@ -26,12 +29,26 @@ MAX_MINUTES_SHOW_START = 15
|
|||
|
||||
instruments
|
||||
|
||||
createLatencyBadge: (participant) ->
|
||||
logger.debug(">>>userLatencies", @state.userLatencies)
|
||||
latency = @state.userLatencies.find((latency) ->
|
||||
latency.user_id == participant.id;
|
||||
)
|
||||
# latencyData = SessionUtils.changeLatencyDataStructure(latency)
|
||||
# data = $.extend(latencyData, SessionUtils.createLatency(latencyData))
|
||||
# latency_text = data.latency_text
|
||||
# latency_style = data.latency_text
|
||||
|
||||
`<span class="latency {latency_style}">{latency_text}</span>`
|
||||
|
||||
|
||||
createInSessionUser: (participant) ->
|
||||
|
||||
instruments = @createInstrument(participant)
|
||||
instruments = @createInstrument(participant)
|
||||
|
||||
`<HoverUser more={null} user={participant.user} instruments={instruments} />`
|
||||
latencyBadge = @createLatencyBadge(participant)
|
||||
|
||||
`<HoverUser more={null} user={participant.user} instruments={instruments} latency={latencyBadge} />`
|
||||
|
||||
createOpenSlot:(slot, isLast) ->
|
||||
|
||||
|
|
@ -73,7 +90,6 @@ MAX_MINUTES_SHOW_START = 15
|
|||
<td>{more_link} </td>
|
||||
</tr>`
|
||||
|
||||
|
||||
createRsvpUser: (user, session, isLast) ->
|
||||
instruments = []
|
||||
|
||||
|
|
@ -99,10 +115,9 @@ MAX_MINUTES_SHOW_START = 15
|
|||
|
||||
moreLinkHtml = `<td><span><a onClick={this.toggleRsvp.bind(this)} className="rsvps more">{text}</a><a className={computedClass}></a></span></td>`
|
||||
|
||||
latencyBadge = @createLatencyBadge(user)
|
||||
|
||||
`<HoverUser user={user} instruments={instruments} more={moreLinkHtml} />`
|
||||
|
||||
|
||||
`<HoverUser user={user} instruments={instruments} more={moreLinkHtml} latency={latencyBadge} />`
|
||||
|
||||
inSessionUsersHtml: (session) ->
|
||||
inSessionUsers = []
|
||||
|
|
@ -121,7 +136,6 @@ MAX_MINUTES_SHOW_START = 15
|
|||
</table>`
|
||||
return [result, inSessionUsers]
|
||||
|
||||
|
||||
createRsvpUsers:(session) ->
|
||||
|
||||
firstResults = []
|
||||
|
|
@ -144,8 +158,6 @@ MAX_MINUTES_SHOW_START = 15
|
|||
|
||||
[firstResults, lastResults]
|
||||
|
||||
|
||||
|
||||
createOpenSlots: (session) ->
|
||||
|
||||
firstResults = []
|
||||
|
|
@ -195,7 +207,6 @@ MAX_MINUTES_SHOW_START = 15
|
|||
<div className="join-link-text">{joinText}</div>
|
||||
</div>`
|
||||
|
||||
|
||||
rsvpLink: (session) ->
|
||||
|
||||
pendingRsvpId = null
|
||||
|
|
@ -385,7 +396,6 @@ MAX_MINUTES_SHOW_START = 15
|
|||
)
|
||||
return false
|
||||
|
||||
|
||||
inSessionMusicians: (in_session_musicians) ->
|
||||
if @props.mode == 'upcoming'
|
||||
return null
|
||||
|
|
@ -399,6 +409,10 @@ MAX_MINUTES_SHOW_START = 15
|
|||
|
||||
createListenLink: () ->
|
||||
null
|
||||
|
||||
onLatencyUpdate: (userLatencies) ->
|
||||
@setState(userLatencies: userLatencies)
|
||||
|
||||
render: () ->
|
||||
|
||||
session = @props.session
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ MAX_MINUTES_SHOW_START = 15
|
|||
<td>
|
||||
<div className="instruments nowrap">{this.props.instruments}</div>
|
||||
</td>
|
||||
<td>
|
||||
<div className="latency-badge" data-user-id={userId}>GOOD</div>
|
||||
</td>
|
||||
{this.props.more}
|
||||
</tr>`
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
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
|
||||
Loading…
Reference in New Issue