67 lines
2.3 KiB
Ruby
67 lines
2.3 KiB
Ruby
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
|
|
|
|
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: 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},
|
|
|
|
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 |