2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-04-01 12:35:10 -04:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Merge request > User awards emoji', :js do
|
2017-07-26 17:52:10 -04:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-08-01 14:03:07 -04:00
|
|
|
let(:user) { project.creator }
|
2017-08-04 13:14:04 -04:00
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, author: create(:user)) }
|
2018-12-11 04:14:59 -05:00
|
|
|
let!(:note) { create(:note, noteable: merge_request, project: merge_request.project) }
|
2016-04-01 12:35:10 -04:00
|
|
|
|
|
|
|
describe 'logged in' do
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2018-12-11 04:14:59 -05:00
|
|
|
|
|
|
|
wait_for_requests
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'adds award to merge request' do
|
2021-04-08 11:09:06 -04:00
|
|
|
first('[data-testid="award-button"]').click
|
2021-06-02 14:10:01 -04:00
|
|
|
expect(page).to have_selector('[data-testid="award-button"].selected')
|
2021-04-08 11:09:06 -04:00
|
|
|
expect(first('[data-testid="award-button"]')).to have_content '1'
|
2016-06-01 05:23:09 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2021-04-08 11:09:06 -04:00
|
|
|
expect(first('[data-testid="award-button"]')).to have_content '1'
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'removes award from merge request' do
|
2021-04-08 11:09:06 -04:00
|
|
|
first('[data-testid="award-button"]').click
|
2021-06-02 14:10:01 -04:00
|
|
|
find('[data-testid="award-button"].selected').click
|
2021-04-08 11:09:06 -04:00
|
|
|
expect(first('[data-testid="award-button"]')).to have_content '0'
|
2016-06-01 05:23:09 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2021-04-08 11:09:06 -04:00
|
|
|
expect(first('[data-testid="award-button"]')).to have_content '0'
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
2018-04-06 14:19:37 -04:00
|
|
|
|
2018-12-11 04:14:59 -05:00
|
|
|
it 'adds awards to note' do
|
2021-04-08 11:09:06 -04:00
|
|
|
page.within('.note-actions') do
|
|
|
|
first('.note-emoji-button').click
|
|
|
|
find('gl-emoji[data-name="8ball"]').click
|
|
|
|
end
|
2018-12-11 04:14:59 -05:00
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.js-awards-block')
|
|
|
|
end
|
|
|
|
|
2018-04-06 14:19:37 -04:00
|
|
|
describe 'the project is archived' do
|
2018-04-11 17:14:02 -04:00
|
|
|
let(:project) { create(:project, :public, :repository, :archived) }
|
2018-04-06 14:19:37 -04:00
|
|
|
|
|
|
|
it 'does not see award menu button' do
|
|
|
|
expect(page).not_to have_selector('.js-award-holder')
|
|
|
|
end
|
|
|
|
end
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'logged out' do
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-04-01 12:35:10 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it 'does not see award menu button' do
|
2016-04-01 12:35:10 -04:00
|
|
|
expect(page).not_to have_selector('.js-award-holder')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|