BigW Consortium Gitlab

award_emoji.rb 2.92 KB
Newer Older
Valery Sizov committed
1 2 3 4 5 6 7
class Spinach::Features::AwardEmoji < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedProject
  include SharedPaths
  include Select2Helper

  step 'I visit "Bugfix" issue page' do
8
    visit project_issue_path(@project, @issue)
Valery Sizov committed
9 10
  end

11 12
  step 'I click the thumbsup award Emoji' do
    page.within '.awards' do
13
      thumbsup = page.first('.award-control')
14 15 16 17 18
      thumbsup.click
      thumbsup.hover
    end
  end

Valery Sizov committed
19
  step 'I click to emoji-picker' do
20 21
    page.within '.awards' do
      page.find('.js-add-award').click
Valery Sizov committed
22 23 24 25
    end
  end

  step 'I click to emoji in the picker' do
Valery Sizov committed
26
    page.within '.emoji-menu-content' do
27 28 29
      emoji_button = page.first('.js-emoji-btn')
      emoji_button.hover
      emoji_button.click
Valery Sizov committed
30 31 32 33
    end
  end

  step 'I can remove it by clicking to icon' do
34
    page.within '.awards' do
Valery Sizov committed
35
      expect do
36
        page.find('.js-emoji-btn.active').click
37 38
        wait_for_requests
      end.to change { page.all(".award-control.js-emoji-btn").size }.from(3).to(2)
Valery Sizov committed
39 40 41
    end
  end

Valery Sizov committed
42 43
  step 'I can see the activity and food categories' do
    page.within '.emoji-menu' do
44 45
      expect(page).not_to have_selector 'Activity'
      expect(page).not_to have_selector 'Food'
Valery Sizov committed
46 47 48
    end
  end

mhasbini committed
49
  step 'I have new comment with emoji added' do
50
    expect(page).to have_selector 'gl-emoji[data-name="smile"]'
mhasbini committed
51 52
  end

Valery Sizov committed
53
  step 'I have award added' do
54
    page.within '.awards' do
55 56
      expect(page).to have_selector '.js-emoji-btn'
      expect(page.find('.js-emoji-btn.active .js-counter')).to have_content '1'
57
      expect(page).to have_css(".js-emoji-btn.active[data-original-title='You']")
58 59 60 61 62
    end
  end

  step 'I have no awards added' do
    page.within '.awards' do
63 64
      expect(page).to have_selector '.award-control.js-emoji-btn'
      expect(page.all('.award-control.js-emoji-btn').size).to eq(2)
65 66

      # Check tooltip data
67
      page.all('.award-control.js-emoji-btn').each do |element|
68 69 70
        expect(element['title']).to eq("")
      end

71
      page.all('.award-control .js-counter').each do |element|
72 73
        expect(element).to have_content '0'
      end
Valery Sizov committed
74 75 76 77
    end
  end

  step 'project "Shop" has issue "Bugfix"' do
78 79 80 81 82 83 84
    @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
      fill_in 'note[note]', with: ':smile:'
Phil Hughes committed
85
      click_button 'Comment'
86
    end
Valery Sizov committed
87
  end
Valery Sizov committed
88 89

  step 'I search "hand"' do
90
    fill_in 'emoji-menu-search', with: 'hand'
Valery Sizov committed
91 92 93 94
  end

  step 'I see search result for "hand"' do
    page.within '.emoji-menu-content' do
95
      expect(page).to have_selector '[data-name="raised_hand"]'
Valery Sizov committed
96 97
    end
  end
98

99 100 101 102
  step 'The emoji menu is visible' do
    page.find(".emoji-menu.is-visible")
  end

103
  step 'The search field is focused' do
104 105
    expect(page).to have_selector('.js-emoji-menu-search')
    expect(page.evaluate_script("document.activeElement.classList.contains('js-emoji-menu-search')")).to eq(true)
106
  end
Valery Sizov committed
107
end