VRFS-1558 added tests

This commit is contained in:
Brian Smith 2014-04-29 03:33:37 -04:00
parent 8eedd63d7f
commit 8b43e63800
13 changed files with 126 additions and 43 deletions

View File

@ -108,8 +108,19 @@
function events() {
var $btnSelector = $('#btn-add-comment', $screen);
$btnSelector.unbind('click');
$btnSelector.click(addComment);
var $txtComment = $('#txtComment', $screen);
if (!context.JK.currentUserId) {
console.log('here1');
$txtComment.attr('placeholder', 'You must be logged in to add a comment.');
$btnSelector.removeClass('button-orange');
$btnSelector.addClass('button-grey');
}
else {
console.log('here2');
$btnSelector.unbind('click');
$btnSelector.click(addComment);
}
}
function showDialog() {

View File

@ -283,24 +283,6 @@
return false;
}
function toggleUserProfile() {
var userId = $(this).attr('user-id');
window.location = '/client#/profile/' + userId;
return false;
}
function toggleBandProfile() {
var bandId = $(this).attr('band-id');
if (bandId == null) {
var userId = $(this).attr('user-id');
window.location = '/client#/profile/' + userId;
}
else {
window.location = '/client#/bandProfile/' + bandId;
}
return false;
}
function renderFeeds(feeds) {
$.each(feeds.entries, function(i, feed) {
@ -320,9 +302,6 @@
$('.details', $feedItem).click(toggleSessionDetails);
$('.details-arrow', $feedItem).click(toggleSessionDetails);
$('.play-button', $feedItem).click(toggleSessionPlay);
$('.avatar-tiny', $feedItem).click(toggleUserProfile);
$('.musician-name', $feedItem).click(toggleUserProfile);
$('.artist', $feedItem).click(toggleBandProfile);
if (!feed.session_removed_at)
{
@ -407,7 +386,9 @@
else {
logger.warn("skipping feed type: " + feed.type);
}
})
context.JK.bindProfileClickEvents();
});
}
function renderFeed(feed) {

View File

@ -170,14 +170,14 @@
$("[profileaction='band']", $parent).click(function(evt) {
closeDialogs();
console.log("navigating to band profile %o", $(this).attr('band-id'));
context.location = "/client#/bandProfile/" + $(this).attr('band-id');
window.location = "/client#/bandProfile/" + $(this).attr('band-id');
});
$("[profileaction='musician']", $parent).unbind('click');
$("[profileaction='musician']", $parent).click(function(evt) {
closeDialogs();
console.log("navigating to musician profile %o", $(this).attr('user-id'));
context.location = "/client#/profile/" + $(this).attr('user-id');
window.location = "/client#/profile/" + $(this).attr('user-id');
});
}

View File

@ -35,6 +35,7 @@
//= require hoverSession
//= require hoverRecording
//= require shareDialog
//= require commentDialog
//= require layout
//= require user_dropdown
//= require jamkazam

View File

@ -16,7 +16,7 @@
<div class="left w50 mr20">
<div class="field w100">
<label for="name">Recording name:</label><br/>
<input type="text" name="name" id="claim-recording-name" class="w100"/>
<input type="text" name="name" id="claim-recording-name" class="recording-name" class="w100"/>
</div>
</div>
<div class="right w40 genre-selector">

View File

@ -80,7 +80,6 @@
<%= render "clients/hoverBand" %>
<%= render "clients/hoverSession" %>
<%= render "clients/hoverRecording" %>
<%= render "clients/commentDialog" %>
<%= yield(:extra_dialogs) %>

View File

@ -4,7 +4,7 @@
= session_avatar(feed_item)
/ type and artist
.left.ml20.w15
.title{:'session-id' => feed_item.id }
.title{hoveraction: 'session', :'session-id' => feed_item.id }
%a{:href => "/sessions/#{feed_item.id}", :target => "_blank"} SESSION
.artist
= session_artist_name(feed_item)

View File

@ -6,7 +6,7 @@
%img{ src: '{{data.feed_item.helpers.avatar}}' }
/ type and artist
.left.ml20.w15
.title{:'session-id' => '{{data.feed_item.id}}' }
.title{hoveraction: 'session', :'session-id' => '{{data.feed_item.id}}' }
%a{:href => "/sessions/{{data.feed_item.id}}", :rel => "external"} SESSION
.artist
%a.artist{:hoveraction => '{{data.feed_item.helpers.artist_hoveraction}}', :profileaction => "{{data.feed_item.helpers.artist_hoveraction}}", :'{{data.feed_item.helpers.artist_datakey}}' => '{{data.feed_item.helpers.artist_id}}'}
@ -63,10 +63,10 @@
= '{% _.each(data.feed_item.participants, function(user) { %}'
%tr
%td{:width => "24"}
%a.avatar-tiny{:href => "#", :hoveraction => "musician", :'user-id' => '{{user.id}}'}
%a.avatar-tiny{:hoveraction => "musician", :profileaction => "musician", :'user-id' => '{{user.id}}'}
%img{src: '{{user.helpers.avatar}}'}
%td
%a.musician-name{:href => "#", :hoveraction => "musician", :'user-id' => '{{user.id}}'}
%a.musician-name{:hoveraction => "musician", :profileaction => "musician", :'user-id' => '{{user.id}}'}
= '{{user.first_name}} {{user.last_name}}'
%td
.nowrap

View File

@ -7,7 +7,7 @@
= recording_avatar(feed_item)
/ type and artist
.left.ml20.w15.feed-type-title
.title{:'recording-id' => feed_item.candidate_claimed_recording.id }
.title{hoveraction: 'recording', :'recording-id' => feed_item.candidate_claimed_recording.id }
%a{:href => "/recordings/#{feed_item.candidate_claimed_recording.id}", :target => "_blank"} RECORDING
.artist
= recording_artist_name(feed_item)

View File

@ -6,7 +6,7 @@
%img{ src: '{{data.feed_item.helpers.avatar}}' }
/ type and artist
.left.ml20.w15
.title{:'recording-id' => '{{data.candidate_claimed_recording.id}}' }
.title{hoveraction: 'recording', :'recording-id' => '{{data.candidate_claimed_recording.id}}' }
%a{:href => "/recordings/{{data.candidate_claimed_recording.id}}", :rel => "external"} RECORDING
.artist
%a.artist{:hoveraction => '{{data.feed_item.helpers.artist_hoveraction}}', :profileaction => "{{data.feed_item.helpers.artist_hoveraction}}", :'{{data.feed_item.helpers.artist_datakey}}' => '{{data.feed_item.helpers.artist_id}}'}
@ -83,10 +83,10 @@
= '{% _.each(data.feed_item.grouped_tracks, function(track) { %}'
%tr
%td{:width => "24"}
%a.avatar-tiny{:href => "#", :hoveraction => "musician", :"user-id" => '{{track.musician.id}}'}
%a.avatar-tiny{:hoveraction => "musician", :profileaction => "musician", :"user-id" => '{{track.musician.id}}'}
%img{src: '{{track.musician.helpers.avatar}}'}
%td
%a.musician-name{:href => "#", :hoveraction => "musician", :"user-id" => '{{track.musician.id}}'}
%a.musician-name{:hoveraction => "musician", :profileaction => "musician", :"user-id" => '{{track.musician.id}}'}
= '{{track.musician.first_name}} {{track.musician.last_name}}'
%td
.nowrap

View File

@ -13,19 +13,58 @@ describe "Feed", :js => true, :type => :feature, :capybara_feature => true do
describe "sessions" do
before(:each) do
MusicSessionHistory.delete_all
create_session(creator: user)
formal_leave_by(user)
end
# it "should render avatar" do
# it " and link to profile" do
# end
# it " and render artist hover bubble" do
# end
# end
# it "should render description" do
# it " and link to session landing" do
# end
# it " and render session hover bubble" do
# end
# end
# it "should render stats" do
# it "should render artist name" do
# it " and link to profile" do
# end
# it " and render artist hover bubble"
# end
it "should render stats" do
visit "/client#/feed"
# initial stats
find('span.plays').should have_content('0')
find('span.comments').should have_content('0')
find('span.likes').should have_content('0')
# Comments
find('a.btn-comment').trigger(:click)
comment = 'this sounds great'
fill_in "txtComment", with: comment
find('#btn-add-comment').trigger(:click)
find('div.comment-text', text: comment)
find('#dialog-close-button', '[layout-id="comment-dialog"]').trigger(:click)
find('#btn-refresh-feed').trigger(:click)
find('span.comments').should have_content('1')
# Likes
find('a.btn-like').trigger(:click)
find('span.likes').should have_content('1')
end
it "should render details" do
visit "/client#/feed"
find('.feed-details a.details').trigger(:click)
@ -56,26 +95,78 @@ describe "Feed", :js => true, :type => :feature, :capybara_feature => true do
before(:each) do
MusicSessionHistory.delete_all
Recording.delete_all
start_recording_with(user)
stop_recording
formal_leave_by(user)
end
# it "should render avatar" do
# it " and link to profile" do
# end
# it " and render artist hover bubble" do
# end
# end
# it "should render description" do
# it " and link to recording landing" do
# end
# it " and render recording hover bubble" do
# end
# end
# it "should render stats" do
# it "should render artist name" do
# it " and link to profile" do
# end
# it " and render artist hover bubble"
# end
it "should render stats" do
visit "/client#/feed"
# close recording finished dialog
claim_recording("my recording", "my recording description")
MusicSessionHistory.delete_all
find('#btn-refresh-feed').trigger(:click)
# initial stats
find('span.plays').should have_content('0')
find('span.comments').should have_content('0')
find('span.likes').should have_content('0')
# ensure Share icon exists
find('a.btn-share')
# Comments
find('a.btn-comment').trigger(:click)
comment = 'this sounds great'
fill_in "txtComment", with: comment
find('#btn-add-comment').trigger(:click)
find('div.comment-text', text: comment)
find('#dialog-close-button', '[layout-id="comment-dialog"]').trigger(:click)
find('#btn-refresh-feed').trigger(:click)
find('span.comments').should have_content('1')
# Likes
find('a.btn-like').trigger(:click)
find('span.likes').should have_content('1')
end
it "should render details" do
visit "/client#/feed"
# close recording finished dialog
find('#recording-finished-dialog h1')
find('#discard-session-recording').trigger(:click)
claim_recording("my recording", "my recording description")
MusicSessionHistory.delete_all
find('#btn-refresh-feed').trigger(:click)
find('.feed-details a.details').trigger(:click)
@ -94,7 +185,7 @@ describe "Feed", :js => true, :type => :feature, :capybara_feature => true do
# confirm navigate to user profile page
find(".avatar-tiny[user-id=\"#{user.id}\"][hoveraction=\"musician\"]").trigger(:click)
find("#user-profile h2[id=profile-username]", text: user.name)
find("#user-profile h2[id=profile-username]", text: user.name)
end
# it "should render play widget" do

View File

@ -14,7 +14,7 @@ describe "Home Screen", :js => true, :type => :feature, :capybara_feature => tru
let(:user) { FactoryGirl.create(:user) }
share_examples_for :has_footer do
shared_examples_for :has_footer do
it "should have footer elements" do
should have_selector('#footer-links')
find('#footer-links').should have_content('about')

View File

@ -322,7 +322,7 @@ def claim_recording(name, description)
fill_in "claim-recording-name", with: name
fill_in "claim-recording-description", with: description
find('#keep-session-recording').trigger(:click)
should have_no_selector('h1', text: 'recording finished')
page.should have_no_selector('h1', text: 'recording finished')
end
def set_session_as_private()