Fix the notification highlighter tests

This commit is contained in:
Seth Call 2021-03-28 23:29:42 -05:00
parent cf4f5c89e0
commit 6f27f40962
9 changed files with 35 additions and 29 deletions

View File

@ -310,6 +310,7 @@
evt.stopPropagation();
var uid = $(this).parent().data('musician-id');
rest.sendFriendRequest(app, uid, friendRequestCallback);
return false;
}
function friendRequestCallback(user_id) {

View File

@ -1152,7 +1152,7 @@
processData: false,
success: function (response) {
if (callback) {
callback(userId);
callback(userId, app);
}
context.JK.GA.trackFriendConnect(context.JK.GA.FriendConnectTypes.request);
},

View File

@ -445,16 +445,20 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter extends BaseSearchF
_bindFriendMusician: () =>
objThis = this
callback = this.friendRequestCallback
@screen.find('.search-m-friend').on 'click', (evt) ->
# if the musician is already a friend, remove the button-orange class, and prevent the link from working
console.log("friend request connected")
if 0 == $(this).closest('.button-orange').size()
console.log("friend request bail out")
return false
$(this).click (ee) ->
ee.preventDefault()
return
return false
evt.stopPropagation()
uid = $(this).parent().data('musician-id')
objThis.rest.sendFriendRequest objThis.app, uid, this.friendRequestCallback
objThis.rest.sendFriendRequest(objThis.app, uid, callback)
return false
_bindFollowMusician: () =>
objThis = this
@ -493,8 +497,9 @@ context.JK.MusicianSearchFilter = class MusicianSearchFilter extends BaseSearchF
else
'Location Unavailable'
friendRequestCallback: (user_id)=>
# TODO:
friendRequestCallback: (user_id, app)=>
$('div[data-musician-id=' + user_id + '] .search-m-friend').removeClass('button-orange').addClass('button-grey');
app.notify({title: 'Friend Request Sent', text: 'Your friend request has been sent! They have to approve to become friends.'});
paginate: () =>
super()

View File

@ -94,6 +94,11 @@
}
function onNotificationOccurred(payload) {
incrementNotificationCount();
highlightCount();
if(userCanSeeNotifications(payload)) {
app.updateNotificationSeen(payload.notification_id, payload.created_at);
}
@ -105,8 +110,6 @@
}
else {
queueNotificationSeen(payload.notification_id, payload.created_at, payload.description);
highlightCount();
incrementNotificationCount();
missedNotificationsWhileAway = true;
}
}

View File

@ -215,7 +215,7 @@
if ($btn.is('.disabled')) {
logger.debug("ignoring send friend request on disabled btn")
return;
return false;
}
var userId = $btn.parent().attr('user-id');
@ -232,7 +232,7 @@
app.notify({title: 'Friend Request Sent', text: 'Your friend request has been sent'})
$btn.addClass('disabled')
})
return false;
}
}

View File

@ -181,7 +181,7 @@
> a.smallbutton {
margin: 4px;
&.button-grey {
display:none; // @FIXME VRFS-930 / VRFS-931 per comment from David - don't show.
//display:none; // @FIXME VRFS-930 / VRFS-931 per comment from David - don't show.
}
}
}

View File

@ -47,7 +47,7 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f
notification.errors.any?.should be false
end
it_behaves_like :notification_badge, highlighted: false, count:0, action: :click
it_behaves_like :notification_badge, highlighted: true, count:1, action: :click
end
describe "document out of focus" do
@ -83,7 +83,7 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f
find('#notification #btn-reply') # wait for notification to show, so that we know the sidebar had a chance to update
end
it_behaves_like :notification_badge, highlighted: false, count:0
it_behaves_like :notification_badge, highlighted: true, count:1
end
describe "document out of focus" do
@ -150,9 +150,7 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f
JamRuby::Score.connection.execute('delete from current_network_scores').check
JamRuby::Score.createx(1, 'a', 1, 2, 'b', 2, 10)
in_client(user) do
sign_in_poltergeist(user)
end
sign_in_poltergeist(user)
in_client(user2) do
sign_in_poltergeist(user2)
@ -160,15 +158,14 @@ describe "Notification Highlighter", :js => true, :type => :feature, :capybara_f
find(".result-list-button-wrapper[data-musician-id='#{user.id}'] .search-m-friend").click
end
in_client(user) do
badge = find("#{NOTIFICATION_PANEL} .badge", text: '1')
badge['class'].include?('highlighted').should == true
find('#notification #btn-accept', text: 'ACCEPT').trigger(:click)
badge = find("#{NOTIFICATION_PANEL} .badge", text: '1')
badge['class'].include?('highlighted').should == true
badge = find("#{NOTIFICATION_PANEL} .badge", text: '0')
badge['class'].include?('highlighted').should == false
end
find('#notification #btn-accept', text: 'ACCEPT').click
badge = find("#{NOTIFICATION_PANEL} .badge", text: '0')
badge['class'].include?('highlighted').should == false
end
end
end

View File

@ -88,10 +88,10 @@ Thread.new do
JamWebsockets::Server.new.run(
:port => 6759,
:emwebsocket_debug => false,
:connect_time_stale_client => 4,
:connect_time_expire_client => 6,
:connect_time_stale_browser => 4,
:connect_time_expire_browser => 6,
:connect_time_stale_client => 80,
:connect_time_expire_client => 120,
:connect_time_stale_browser => 80,
:connect_time_expire_browser => 120,
:max_connections_per_user => 20,
:rabbitmq_host => '127.0.0.1',
:rabbitmq_port => 5672,

View File

@ -46,12 +46,12 @@ end
# in place of ever using Capybara.session_name directly,
# this utility is used to handle the mapping of session names in a way across all tests runs
def in_client(name)
def in_client(name, &blk)
session_name = name.class == JamRuby::User ? name.id : name
Capybara.session_name = mapped_session_name(session_name)
#Capybara.session_name = mapped_session_name(session_name)
yield
Capybara.using_session(session_name, &blk)
end