diff --git a/web/spec/features/musician_hover_spec.rb b/web/spec/features/musician_hover_spec.rb index 22537431f..3b180018d 100644 --- a/web/spec/features/musician_hover_spec.rb +++ b/web/spec/features/musician_hover_spec.rb @@ -8,7 +8,9 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } before do - #Capybara.current_driver = :jamkazam + #Capybara.javascript_driver = :capybara_webmock + #Capybara.current_driver = Capybara.javascript_driver + Capybara.default_max_wait_time = 30 # these tests are SLOOOOOW WebMock.disable_net_connect!(allow_localhost: true) end @@ -17,9 +19,8 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => end before(:each) do - fast_signin(user1, "/client") + fast_signin(user1, "/client") wait_until_curtain_gone - #sleep(1) end @@ -28,74 +29,80 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => xit "show FAILED", focus: true do response_body = latency_response(user2, -3) #sessionUtils.LATENCY.FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3} stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .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: 'FAILED') - sleep(1) + find("#musician-latency-badge", text: 'FAILED') + #screenshot_and_save_page 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) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .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) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .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) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .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) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .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) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .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)