gitlab-org--gitlab-foss/spec/features/issues/award_emoji_spec.rb
Filipa Lacerda e4f8aa719b Merge branch 'master' into issue-discussions-refactor
* master: (162 commits)
  Since mysql is not a priority anymore, test it less
  Add container registry and spam logs icons
  Fix different Markdown styles
  Backport to CE for:
  Make new dropdown dividers full width
  Bump GITLAB_SHELL_VERSION and GITALY_VERSION to support unhiding refs
  Install yarn via apt in update guides
  Use long curl options
  Remove monkey-patched Array.prototype.first() and last() methods
  Openshift Getting Started
  35659 Rename Pipelines tab to CI / CD in new navigation
  Don't bother going through an entire Banzai pipeline for empty text
  Add active state for pipelines settings on old nav
  Bump rspec to 3.6.0
  Resolve "Specific Async Script Loading by using a Page Variable"
  Revert "Merge branch 'rs-warm-capybara-only-in-ci' into 'master'"
  another rubocop style fix
  Use mixin for new dropdown style
  Migrate Repository#last_commit_for_path to Gitaly
  Migrate blame loading to Gitaly
  ...
2017-08-04 19:38:37 +01:00

146 lines
3.6 KiB
Ruby

require 'rails_helper'
describe 'Awards Emoji' do
let!(:project) { create(:project, :public) }
let!(:user) { create(:user) }
let(:issue) do
create(:issue,
assignees: [user],
project: project)
end
context 'authorized user' do
before do
project.team << [user, :master]
sign_in(user)
end
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 project_issue_path(project, issue)
wait_for_requests
end
# Regression test: https://gitlab.com/gitlab-org/gitlab-ce/issues/29529
it 'does not shows a 500 page', js: true do
expect(page).to have_text(issue.title)
end
end
describe 'Click award emoji from issue#show' do
let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
before do
visit project_issue_path(project, issue)
wait_for_requests
end
it 'increments the thumbsdown emoji', js: true do
find('[data-name="thumbsdown"]').click
wait_for_requests
expect(thumbsdown_emoji).to have_text("1")
end
context 'click the thumbsup emoji' do
it 'increments the thumbsup emoji', js: true do
find('[data-name="thumbsup"]').click
wait_for_requests
expect(thumbsup_emoji).to have_text("1")
end
it 'decrements the thumbsdown emoji', js: true do
expect(thumbsdown_emoji).to have_text("0")
end
end
context 'click the thumbsdown emoji' do
it 'increments the thumbsdown emoji', js: true do
find('[data-name="thumbsdown"]').click
wait_for_requests
expect(thumbsdown_emoji).to have_text("1")
end
it 'decrements the thumbsup emoji', js: true do
expect(thumbsup_emoji).to have_text("0")
end
end
it 'toggles the smiley emoji on a note', js: true do
toggle_smiley_emoji(true)
within('.note-body') do
expect(find(emoji_counter)).to have_text("1")
end
toggle_smiley_emoji(false)
within('.note-body') do
expect(page).not_to have_selector(emoji_counter)
end
end
context 'execute /award quick action' do
it 'toggles the emoji award on noteable', js: true do
execute_quick_action('/award :100:')
expect(find(noteable_award_counter)).to have_text("1")
execute_quick_action('/award :100:')
expect(page).not_to have_selector(noteable_award_counter)
end
end
end
end
context 'unauthorized user', js: true do
before do
visit project_issue_path(project, issue)
end
it 'has disabled emoji button' do
expect(first('.award-control')[:class]).to have_text('disabled')
end
end
def execute_quick_action(cmd)
within('.js-main-target-form') do
fill_in 'note[note]', with: cmd
click_button 'Comment'
end
wait_for_requests
end
def thumbsup_emoji
page.all(emoji_counter).first
end
def thumbsdown_emoji
page.all(emoji_counter).last
end
def emoji_counter
'span.js-counter'
end
def noteable_award_counter
".awards .active"
end
def toggle_smiley_emoji(status)
within('.note') do
find('.note-emoji-button').click
end
unless status
first('[data-name="smiley"]').click
else
find('[data-name="smiley"]').click
end
wait_for_requests
end
end