2016-04-05 18:26:17 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe 'Awards Emoji', feature: true do
|
2017-04-05 21:13:06 -04:00
|
|
|
include WaitForVueResource
|
2016-10-18 19:12:26 -04:00
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
let!(:project) { create(:project, :public) }
|
2016-04-05 18:26:17 -04:00
|
|
|
let!(:user) { create(:user) }
|
2016-11-22 05:25:09 -05:00
|
|
|
let(:issue) do
|
|
|
|
create(:issue,
|
2017-05-04 08:11:15 -04:00
|
|
|
assignees: [user],
|
2016-11-22 05:25:09 -05:00
|
|
|
project: project)
|
2016-04-05 18:26:17 -04:00
|
|
|
end
|
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
context 'authorized user' do
|
2016-04-05 18:26:17 -04:00
|
|
|
before do
|
2016-11-22 05:25:09 -05:00
|
|
|
project.team << [user, :master]
|
|
|
|
login_as(user)
|
2016-04-05 18:26:17 -04:00
|
|
|
end
|
|
|
|
|
2017-03-16 06:03:35 -04:00
|
|
|
describe 'visiting an issue with a legacy award emoji that is not valid anymore' do
|
|
|
|
before do
|
|
|
|
# The `heart_tip` emoji is not valid anymore so we need to skip validation
|
|
|
|
issue.award_emoji.build(user: user, name: 'heart_tip').save!(validate: false)
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
2017-04-05 21:13:06 -04:00
|
|
|
wait_for_vue_resource
|
2017-03-16 06:03:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# Regression test: https://gitlab.com/gitlab-org/gitlab-ce/issues/29529
|
2017-04-05 21:13:06 -04:00
|
|
|
it 'does not shows a 500 page', js: true do
|
2017-03-16 06:03:35 -04:00
|
|
|
expect(page).to have_text(issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
describe 'Click award emoji from issue#show' do
|
2017-03-16 06:03:35 -04:00
|
|
|
let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
|
2016-04-05 18:26:17 -04:00
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
before do
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
2017-04-05 21:13:06 -04:00
|
|
|
wait_for_vue_resource
|
2016-04-05 18:26:17 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'increments the thumbsdown emoji', js: true do
|
2017-02-27 23:44:34 -05:00
|
|
|
find('[data-name="thumbsdown"]').click
|
2016-10-18 19:12:26 -04:00
|
|
|
wait_for_ajax
|
2016-04-05 18:26:17 -04:00
|
|
|
expect(thumbsdown_emoji).to have_text("1")
|
|
|
|
end
|
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
context 'click the thumbsup emoji' do
|
|
|
|
it 'increments the thumbsup emoji', js: true do
|
2017-02-27 23:44:34 -05:00
|
|
|
find('[data-name="thumbsup"]').click
|
2016-11-22 05:25:09 -05:00
|
|
|
wait_for_ajax
|
|
|
|
expect(thumbsup_emoji).to have_text("1")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'decrements the thumbsdown emoji', js: true do
|
|
|
|
expect(thumbsdown_emoji).to have_text("0")
|
|
|
|
end
|
2016-04-05 18:26:17 -04:00
|
|
|
end
|
2016-10-18 19:12:26 -04:00
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
context 'click the thumbsdown emoji' do
|
|
|
|
it 'increments the thumbsdown emoji', js: true do
|
2017-02-27 23:44:34 -05:00
|
|
|
find('[data-name="thumbsdown"]').click
|
2016-11-22 05:25:09 -05:00
|
|
|
wait_for_ajax
|
|
|
|
expect(thumbsdown_emoji).to have_text("1")
|
|
|
|
end
|
2016-10-18 19:12:26 -04:00
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
it 'decrements the thumbsup emoji', js: true do
|
|
|
|
expect(thumbsup_emoji).to have_text("0")
|
|
|
|
end
|
2016-10-18 19:12:26 -04:00
|
|
|
end
|
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
it 'toggles the smiley emoji on a note', js: true do
|
|
|
|
toggle_smiley_emoji(true)
|
|
|
|
|
|
|
|
within('.note-awards') do
|
|
|
|
expect(find(emoji_counter)).to have_text("1")
|
|
|
|
end
|
|
|
|
|
|
|
|
toggle_smiley_emoji(false)
|
2016-10-18 19:12:26 -04:00
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
within('.note-awards') do
|
|
|
|
expect(page).not_to have_selector(emoji_counter)
|
|
|
|
end
|
2016-10-18 19:12:26 -04:00
|
|
|
end
|
2017-02-28 15:38:19 -05:00
|
|
|
|
|
|
|
context 'execute /award slash command' do
|
|
|
|
it 'toggles the emoji award on noteable', js: true do
|
|
|
|
execute_slash_command('/award :100:')
|
|
|
|
|
|
|
|
expect(find(noteable_award_counter)).to have_text("1")
|
|
|
|
|
|
|
|
execute_slash_command('/award :100:')
|
|
|
|
|
|
|
|
expect(page).not_to have_selector(noteable_award_counter)
|
|
|
|
end
|
|
|
|
end
|
2016-10-18 19:12:26 -04:00
|
|
|
end
|
2016-04-05 18:26:17 -04:00
|
|
|
end
|
|
|
|
|
2016-11-22 05:25:09 -05:00
|
|
|
context 'unauthorized user', js: true do
|
|
|
|
before do
|
|
|
|
visit namespace_project_issue_path(project.namespace, project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has disabled emoji button' do
|
2016-12-30 09:44:21 -05:00
|
|
|
expect(first('.award-control')[:class]).to have_text('disabled')
|
2016-11-22 05:25:09 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-28 15:38:19 -05:00
|
|
|
def execute_slash_command(cmd)
|
|
|
|
within('.js-main-target-form') do
|
|
|
|
fill_in 'note[note]', with: cmd
|
|
|
|
click_button 'Comment'
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_ajax
|
|
|
|
end
|
|
|
|
|
2016-04-05 18:26:17 -04:00
|
|
|
def thumbsup_emoji
|
2016-10-18 19:12:26 -04:00
|
|
|
page.all(emoji_counter).first
|
2016-04-05 18:26:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def thumbsdown_emoji
|
2016-10-18 19:12:26 -04:00
|
|
|
page.all(emoji_counter).last
|
|
|
|
end
|
|
|
|
|
|
|
|
def emoji_counter
|
|
|
|
'span.js-counter'
|
|
|
|
end
|
|
|
|
|
2017-02-28 15:38:19 -05:00
|
|
|
def noteable_award_counter
|
|
|
|
".awards .active"
|
|
|
|
end
|
|
|
|
|
2016-10-18 19:12:26 -04:00
|
|
|
def toggle_smiley_emoji(status)
|
|
|
|
within('.note') do
|
|
|
|
find('.note-emoji-button').click
|
|
|
|
end
|
|
|
|
|
|
|
|
unless status
|
2017-02-27 23:44:34 -05:00
|
|
|
first('[data-name="smiley"]').click
|
2016-10-18 19:12:26 -04:00
|
|
|
else
|
2017-02-27 23:44:34 -05:00
|
|
|
find('[data-name="smiley"]').click
|
2016-10-18 19:12:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_ajax
|
2016-04-05 18:26:17 -04:00
|
|
|
end
|
|
|
|
end
|