diff options
Diffstat (limited to 'spec/features/issues/award_emoji_spec.rb')
-rw-r--r-- | spec/features/issues/award_emoji_spec.rb | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/spec/features/issues/award_emoji_spec.rb b/spec/features/issues/award_emoji_spec.rb index 73e43316dc7..16e453bc328 100644 --- a/spec/features/issues/award_emoji_spec.rb +++ b/spec/features/issues/award_emoji_spec.rb @@ -17,22 +17,35 @@ describe 'Awards Emoji', feature: true do login_as(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 namespace_project_issue_path(project.namespace, project, issue) + end + + # Regression test: https://gitlab.com/gitlab-org/gitlab-ce/issues/29529 + it 'does not shows a 500 page' 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") } + let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") } before do visit namespace_project_issue_path(project.namespace, project, issue) end it 'increments the thumbsdown emoji', js: true do - find('[data-emoji="thumbsdown"]').click + find('[data-name="thumbsdown"]').click wait_for_ajax expect(thumbsdown_emoji).to have_text("1") end context 'click the thumbsup emoji' do it 'increments the thumbsup emoji', js: true do - find('[data-emoji="thumbsup"]').click + find('[data-name="thumbsup"]').click wait_for_ajax expect(thumbsup_emoji).to have_text("1") end @@ -44,7 +57,7 @@ describe 'Awards Emoji', feature: true do context 'click the thumbsdown emoji' do it 'increments the thumbsdown emoji', js: true do - find('[data-emoji="thumbsdown"]').click + find('[data-name="thumbsdown"]').click wait_for_ajax expect(thumbsdown_emoji).to have_text("1") end @@ -67,6 +80,18 @@ describe 'Awards Emoji', feature: true do expect(page).not_to have_selector(emoji_counter) end end + + 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 end end @@ -80,6 +105,15 @@ describe 'Awards Emoji', feature: true do end end + 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 + def thumbsup_emoji page.all(emoji_counter).first end @@ -92,15 +126,19 @@ describe 'Awards Emoji', feature: true do '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-emoji="smiley"]').click + first('[data-name="smiley"]').click else - find('[data-emoji="smiley"]').click + find('[data-name="smiley"]').click end wait_for_ajax |