Replace the 'project/issues/award_emoji.feature' spinach test with an rspec analog

parent 5d3f7b13
---
title: Replace the 'project/issues/award_emoji.feature' spinach test with an rspec analog
merge_request: 14202
author: Vitaliy @blackst0ne Klachkov
type: other
@project_issues
Feature: Award Emoji
Background:
Given I sign in as a user
And I own project "Shop"
And project "Shop" has issue "Bugfix"
And I visit "Bugfix" issue page
@javascript
Scenario: I repeatedly add and remove thumbsup award in the issue
Given I click the thumbsup award Emoji
Then I have award added
Given I click the thumbsup award Emoji
Then I have no awards added
Given I click the thumbsup award Emoji
Then I have award added
@javascript
Scenario: I add and remove custom award in the issue
Given I click to emoji-picker
Then The emoji menu is visible
And The search field is focused
Then I click to emoji in the picker
Then I have award added
And I can remove it by clicking to icon
@javascript
Scenario: I can see the list of emoji categories
Given I click to emoji-picker
Then The emoji menu is visible
And The search field is focused
Then I can see the activity and food categories
@javascript
Scenario: I can search emoji
Given I click to emoji-picker
Then The emoji menu is visible
And The search field is focused
And I search "hand"
Then I see search result for "hand"
@javascript
Scenario: I add award emoji using regular comment
Given I leave comment with a single emoji
Then I have new comment with emoji added
class Spinach::Features::AwardEmoji < Spinach::FeatureSteps require 'spec_helper'
include SharedAuthentication
include SharedProject describe 'User interacts with awards in an issue', :js do
include SharedPaths let(:issue) { create(:issue, project: project)}
include Select2Helper let(:project) { create(:project) }
let(:user) { create(:user) }
step 'I visit "Bugfix" issue page' do
visit project_issue_path(@project, @issue) before do
project.add_master(user)
sign_in(user)
visit(project_issue_path(project, issue))
end end
step 'I click the thumbsup award Emoji' do it 'toggles the thumbsup award emoji' do
page.within '.awards' do page.within('.awards') do
thumbsup = page.first('.award-control')
thumbsup.click
thumbsup.hover
expect(page).to have_selector('.js-emoji-btn')
expect(page).to have_css(".js-emoji-btn.active[data-original-title='You']")
expect(page.find('.js-emoji-btn.active .js-counter')).to have_content('1')
thumbsup = page.first('.award-control')
thumbsup.click
thumbsup.hover
expect(page).to have_selector('.award-control.js-emoji-btn')
expect(page.all('.award-control.js-emoji-btn').size).to eq(2)
page.all('.award-control.js-emoji-btn').each do |element|
expect(element['title']).to eq('')
end
page.all('.award-control .js-counter').each do |element|
expect(element).to have_content('0')
end
thumbsup = page.first('.award-control') thumbsup = page.first('.award-control')
thumbsup.click thumbsup.click
thumbsup.hover thumbsup.hover
expect(page).to have_selector('.js-emoji-btn')
expect(page).to have_css(".js-emoji-btn.active[data-original-title='You']")
expect(page.find('.js-emoji-btn.active .js-counter')).to have_content('1')
end end
end end
step 'I click to emoji-picker' do it 'toggles a custom award emoji' do
page.within '.awards' do page.within('.awards') do
page.find('.js-add-award').click page.find('.js-add-award').click
end end
end
step 'I click to emoji in the picker' do page.find('.emoji-menu.is-visible')
page.within '.emoji-menu-content' do
expect(page).to have_selector('.js-emoji-menu-search')
expect(page.evaluate_script("document.activeElement.classList.contains('js-emoji-menu-search')")).to eq(true)
page.within('.emoji-menu-content') do
emoji_button = page.first('.js-emoji-btn') emoji_button = page.first('.js-emoji-btn')
emoji_button.hover emoji_button.hover
emoji_button.click emoji_button.click
end end
end
step 'I can remove it by clicking to icon' do page.within('.awards') do
page.within '.awards' do expect(page).to have_selector('.js-emoji-btn')
expect(page.find('.js-emoji-btn.active .js-counter')).to have_content('1')
expect(page).to have_css(".js-emoji-btn.active[data-original-title='You']")
expect do expect do
page.find('.js-emoji-btn.active').click page.find('.js-emoji-btn.active').click
wait_for_requests wait_for_requests
end.to change { page.all(".award-control.js-emoji-btn").size }.from(3).to(2) end.to change { page.all('.award-control.js-emoji-btn').size }.from(3).to(2)
end end
end end
step 'I can see the activity and food categories' do it 'shows the list of award emoji categories' do
page.within '.emoji-menu' do page.within('.awards') do
expect(page).not_to have_selector 'Activity' page.find('.js-add-award').click
expect(page).not_to have_selector 'Food'
end end
end
step 'I have new comment with emoji added' do
expect(page).to have_selector 'gl-emoji[data-name="smile"]'
end
step 'I have award added' do page.find('.emoji-menu.is-visible')
page.within '.awards' do
expect(page).to have_selector '.js-emoji-btn'
expect(page.find('.js-emoji-btn.active .js-counter')).to have_content '1'
expect(page).to have_css(".js-emoji-btn.active[data-original-title='You']")
end
end
step 'I have no awards added' do expect(page).to have_selector('.js-emoji-menu-search')
page.within '.awards' do expect(page.evaluate_script("document.activeElement.classList.contains('js-emoji-menu-search')")).to eq(true)
expect(page).to have_selector '.award-control.js-emoji-btn'
expect(page.all('.award-control.js-emoji-btn').size).to eq(2)
# Check tooltip data fill_in('emoji-menu-search', with: 'hand')
page.all('.award-control.js-emoji-btn').each do |element|
expect(element['title']).to eq("")
end
page.all('.award-control .js-counter').each do |element| page.within('.emoji-menu-content') do
expect(element).to have_content '0' expect(page).to have_selector('[data-name="raised_hand"]')
end
end end
end end
step 'project "Shop" has issue "Bugfix"' do it 'adds an award emoji by a comment' do
@project = Project.find_by(name: 'Shop')
@issue = create(:issue, title: 'Bugfix', project: project)
end
step 'I leave comment with a single emoji' do
page.within('.js-main-target-form') do page.within('.js-main-target-form') do
fill_in 'note[note]', with: ':smile:' fill_in('note[note]', with: ':smile:')
click_button 'Comment'
end
end
step 'I search "hand"' do click_button('Comment')
fill_in 'emoji-menu-search', with: 'hand'
end
step 'I see search result for "hand"' do
page.within '.emoji-menu-content' do
expect(page).to have_selector '[data-name="raised_hand"]'
end end
end
step 'The emoji menu is visible' do expect(page).to have_selector('gl-emoji[data-name="smile"]')
page.find(".emoji-menu.is-visible")
end
step 'The search field is focused' do
expect(page).to have_selector('.js-emoji-menu-search')
expect(page.evaluate_script("document.activeElement.classList.contains('js-emoji-menu-search')")).to eq(true)
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment