diff options
Diffstat (limited to 'test/helpers/reactions_helper_test.rb')
-rw-r--r-- | test/helpers/reactions_helper_test.rb | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/test/helpers/reactions_helper_test.rb b/test/helpers/reactions_helper_test.rb index f3a4e38d8..1c5c82418 100644 --- a/test/helpers/reactions_helper_test.rb +++ b/test/helpers/reactions_helper_test.rb @@ -106,12 +106,30 @@ class ReactionsHelperTest < ActionView::TestCase assert_select_in result, 'a.reaction-button[title=?]', expected_tooltip end - test 'reaction_button displays non-visible users as "X other" in the tooltip' do + test 'reaction_button should be label less when no reactions' do + issue = issues(:issues_002) + + result = with_locale('en') do + reaction_button(issue) + end + assert_select_in result, 'a.reaction-button' do + assert_select 'span.icon-label', false + end + + # readonly + User.current = nil + result = with_locale('en') do + reaction_button(issue) + end + assert_select_in result, 'span.reaction-button.readonly' do + assert_select 'span.icon-label', false + end + end + + test 'reaction_button should not count and display non-visible users' do issue2 = issues(:issues_002) issue2.reaction_detail = Reaction::Detail.new( - # The remaining 3 users are non-visible users - reaction_count: 5, visible_users: users(:users_002, :users_003) ) @@ -119,11 +137,10 @@ class ReactionsHelperTest < ActionView::TestCase reaction_button(issue2) end - assert_select_in result, 'a.reaction-button[title=?]', 'John Smith, Dave Lopper, and 3 others' + assert_select_in result, 'a.reaction-button[title=?]', 'John Smith and Dave Lopper' # When all users are non-visible users issue2.reaction_detail = Reaction::Detail.new( - reaction_count: 2, visible_users: [] ) @@ -131,7 +148,10 @@ class ReactionsHelperTest < ActionView::TestCase reaction_button(issue2) end - assert_select_in result, 'a.reaction-button[title=?]', '2 others' + assert_select_in result, 'a.reaction-button[title]', false + assert_select_in result, 'a.reaction-button' do + assert_select 'span.icon-label', false + end end test 'reaction_button formats the tooltip content based on the support.array settings of each locale' do @@ -152,7 +172,7 @@ class ReactionsHelperTest < ActionView::TestCase end tooltip = 'Dave Lopper, John Smith, and Redmine Admin' - assert_select_in result, 'span[data-reaction-button-id=?]', 'reaction_issue_1' do + assert_select_in result, 'span.reaction-button-wrapper[data-reaction-button-id=?]', 'reaction_issue_1' do href = reaction_path(issue.reaction_detail.user_reaction, object_type: 'Issue', object_id: 1) assert_select 'a.icon.reaction-button.reacted[href=?]', href do @@ -174,7 +194,7 @@ class ReactionsHelperTest < ActionView::TestCase end tooltip = 'Dave Lopper, John Smith, and Redmine Admin' - assert_select_in result, 'span[data-reaction-button-id=?]', 'reaction_issue_1' do + assert_select_in result, 'span.reaction-button-wrapper[data-reaction-button-id=?]', 'reaction_issue_1' do href = reactions_path(object_type: 'Issue', object_id: 1) assert_select 'a.icon.reaction-button[href=?]', href do |