BigW Consortium Gitlab

issues.rb 10.1 KB
Newer Older
1
class Spinach::Features::ProjectIssues < Spinach::FeatureSteps
Nihad Abbasov committed
2
  include SharedAuthentication
3
  include SharedIssuable
Nihad Abbasov committed
4 5 6
  include SharedProject
  include SharedNote
  include SharedPaths
7
  include SharedMarkdown
8
  include SharedUser
Nihad Abbasov committed
9

10
  step 'I should see "Release 0.4" in issues' do
11
    expect(page).to have_content "Release 0.4"
12 13
  end

14
  step 'I should not see "Release 0.3" in issues' do
15
    expect(page).not_to have_content "Release 0.3"
16 17
  end

18
  step 'I should not see "Tweet control" in issues' do
19
    expect(page).not_to have_content "Tweet control"
20 21
  end

Valery Sizov committed
22
  step 'I should see that I am subscribed' do
23 24
    wait_for_requests
    expect(find('.js-issuable-subscribe-button span')).to have_content 'Unsubscribe'
Valery Sizov committed
25 26 27
  end

  step 'I should see that I am unsubscribed' do
28 29
    wait_for_requests
    expect(find('.js-issuable-subscribe-button span')).to have_content 'Subscribe'
Valery Sizov committed
30 31
  end

32
  step 'I click link "Closed"' do
33
    find('.issues-state-filters [data-state="closed"] span', text: 'Closed').click
34 35
  end

Valery Sizov committed
36 37 38 39
  step 'I click button "Unsubscribe"' do
    click_on "Unsubscribe"
  end

40
  step 'I should see "Release 0.3" in issues' do
41
    expect(page).to have_content "Release 0.3"
42 43
  end

44
  step 'I should not see "Release 0.4" in issues' do
45
    expect(page).not_to have_content "Release 0.4"
46 47
  end

48
  step 'I click link "All"' do
49
    find('.issues-state-filters [data-state="all"] span', text: 'All').click
50 51
    # Waits for load
    expect(find('.issues-state-filters > .active')).to have_content 'All'
52 53
  end

54
  step 'I click link "Release 0.4"' do
55 56 57
    click_link "Release 0.4"
  end

58
  step 'I should see issue "Release 0.4"' do
59
    expect(page).to have_content "Release 0.4"
60 61
  end

62 63 64 65
  step 'I should see issue "Tweet control"' do
    expect(page).to have_content "Tweet control"
  end

66
  step 'I click link "New issue"' do
67 68 69
    page.within '#content-body' do
      page.has_link?('New Issue') ? click_link('New Issue') : click_link('New issue')
    end
70 71
  end

72
  step 'I click "author" dropdown' do
Phil Hughes committed
73 74
    page.find('.js-author-search').click
    sleep 1
75 76 77
  end

  step 'I see current user as the first user' do
Phil Hughes committed
78 79
    expect(page).to have_selector('.dropdown-content', visible: true)
    users = page.all('.dropdown-menu-author .dropdown-content li a')
80
    expect(users[0].text).to eq 'Any Author'
Phil Hughes committed
81
    expect(users[1].text).to eq "#{current_user.name} #{current_user.to_reference}"
82 83
  end

84
  step 'I submit new issue "500 error on profile"' do
85
    fill_in "issue_title", with: "500 error on profile"
86
    click_button "Submit issue"
87 88
  end

89 90
  step 'I submit new issue "500 error on profile" with label \'bug\'' do
    fill_in "issue_title", with: "500 error on profile"
91 92
    click_button "Label"
    click_link "bug"
93
    click_button "Submit issue"
94 95
  end

96
  step 'I click link "500 error on profile"' do
97 98 99
    click_link "500 error on profile"
  end

100
  step 'I should see label \'bug\' with issue' do
Douwe Maan committed
101
    page.within '.issuable-show-labels' do
102
      expect(page).to have_content 'bug'
103 104 105
    end
  end

106
  step 'I should see issue "500 error on profile"' do
skv committed
107
    issue = Issue.find_by(title: "500 error on profile")
108 109 110
    expect(page).to have_content issue.title
    expect(page).to have_content issue.author_name
    expect(page).to have_content issue.project.name
111 112
  end

113
  step 'I fill in issue search with "Re"' do
114
    filter_issue "Re"
115 116
  end

117
  step 'I fill in issue search with "Bu"' do
118
    filter_issue "Bu"
119 120
  end

121
  step 'I fill in issue search with ".3"' do
122
    filter_issue ".3"
123 124
  end

125
  step 'I fill in issue search with "Something"' do
126
    filter_issue "Something"
127 128
  end

129
  step 'I fill in issue search with ""' do
130
    filter_issue ""
131 132
  end

133
  step 'project "Shop" has milestone "v2.2"' do
134
    milestone = create(:milestone, title: "v2.2", project: project)
135

136
    3.times { create(:issue, project: project, milestone: milestone) }
137 138
  end

139
  step 'project "Shop" has milestone "v3.0"' do
140
    milestone = create(:milestone, title: "v3.0", project: project)
141

142
    3.times { create(:issue, project: project, milestone: milestone) }
143 144 145 146 147 148
  end

  When 'I select milestone "v3.0"' do
    select "v3.0", from: "milestone_id"
  end

149
  step 'I should see selected milestone with title "v3.0"' do
150
    issues_milestone_selector = "#issue_milestone_id_chzn > a"
151
    expect(find(issues_milestone_selector)).to have_content("v3.0")
152 153 154 155 156 157 158
  end

  When 'I select first assignee from "Shop" project' do
    first_assignee = project.users.first
    select first_assignee.name, from: "assignee_id"
  end

159
  step 'I should see first assignee from "Shop" as selected assignee' do
160
    issues_assignee_selector = "#issue_assignee_id_chzn > a"
161

162
    assignee_name = project.users.first.name
163
    expect(find(issues_assignee_selector)).to have_content(assignee_name)
164 165
  end

166
  step 'project "Shop" have "Release 0.4" open issue' do
167
    create(:issue,
168 169
           title: "Release 0.4",
           project: project,
170 171 172
           author: project.users.first,
           description: "# Description header"
          )
173
    wait_for_requests
174 175
  end

176
  step 'project "Shop" have "Tweet control" open issue' do
177
    create(:issue,
178
           title: "Tweet control",
179 180 181 182
           project: project,
           author: project.users.first)
  end

183 184 185 186 187 188 189
  step 'project "Shop" have "Bugfix" open issue' do
    create(:issue,
           title: "Bugfix",
           project: project,
           author: project.users.first)
  end

190
  step 'project "Shop" have "Release 0.3" closed issue' do
Andrew8xx8 committed
191
    create(:closed_issue,
192 193 194
           title: "Release 0.3",
           project: project,
           author: project.users.first)
195
  end
196

197
  step 'issue "Release 0.4" have 2 upvotes and 1 downvote' do
198
    awardable = Issue.find_by(title: 'Release 0.4')
199 200
    create_list(:award_emoji, 2, awardable: awardable)
    create(:award_emoji, :downvote, awardable: awardable)
201 202 203
  end

  step 'issue "Tweet control" have 1 upvote and 2 downvotes' do
204 205 206
    awardable = Issue.find_by(title: 'Tweet control')
    create(:award_emoji, :upvote, awardable: awardable)
    create_list(:award_emoji, 2, awardable: awardable, name: 'thumbsdown')
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
  end

  step 'The list should be sorted by "Least popular"' do
    page.within '.issues-list' do
      page.within 'li.issue:nth-child(1)' do
        expect(page).to have_content 'Tweet control'
        expect(page).to have_content '1 2'
      end

      page.within 'li.issue:nth-child(2)' do
        expect(page).to have_content 'Release 0.4'
        expect(page).to have_content '2 1'
      end

      page.within 'li.issue:nth-child(3)' do
        expect(page).to have_content 'Bugfix'
223
        expect(page).not_to have_content '0 0'
224 225 226 227
      end
    end
  end

228
  step 'The list should be sorted by "Popularity"' do
229 230 231 232 233 234 235 236 237 238 239 240 241
    page.within '.issues-list' do
      page.within 'li.issue:nth-child(1)' do
        expect(page).to have_content 'Release 0.4'
        expect(page).to have_content '2 1'
      end

      page.within 'li.issue:nth-child(2)' do
        expect(page).to have_content 'Tweet control'
        expect(page).to have_content '1 2'
      end

      page.within 'li.issue:nth-child(3)' do
        expect(page).to have_content 'Bugfix'
242
        expect(page).not_to have_content '0 0'
243 244 245 246
      end
    end
  end

247
  step 'empty project "Empty Project"' do
248
    create :project_empty_repo, name: 'Empty Project', namespace: @user.namespace
249 250 251 252
  end

  When 'I visit empty project page' do
    project = Project.find_by(name: 'Empty Project')
253
    visit project_path(project)
254 255
  end

256
  step 'I see empty project details with ssh clone info' do
257
    project = Project.find_by(name: 'Empty Project')
258
    page.all(:css, '.git-empty .clone').each do |element|
259
      expect(element.text).to include(project.url_to_repo)
260 261 262
    end
  end

263 264
  When "I visit project \"Community\" issues page" do
    project = Project.find_by(name: 'Community')
265
    visit project_issues_path(project)
266 267
  end

268 269
  When "I visit empty project's issues page" do
    project = Project.find_by(name: 'Empty Project')
270
    visit project_issues_path(project)
271
  end
Marin Jankovski committed
272 273

  step 'I leave a comment with code block' do
274
    page.within(".js-main-target-form") do
Marin Jankovski committed
275
      fill_in "note[note]", with: "```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```"
Phil Hughes committed
276
      click_button "Comment"
Marin Jankovski committed
277 278 279 280
      sleep 0.05
    end
  end

281
  step 'I should see an error alert section within the comment form' do
282
    page.within(".js-main-target-form") do
283 284 285 286
      find(".error-alert")
    end
  end

Marin Jankovski committed
287
  step 'The code block should be unchanged' do
288
    expect(page).to have_content("```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```")
Marin Jankovski committed
289
  end
290

291
  step 'project \'Shop\' has issue \'Bugfix1\' with description: \'Description for issue1\'' do
292
    create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
293 294
  end

295
  step 'project \'Shop\' has issue \'Feature1\' with description: \'Feature submitted for issue1\'' do
296
    create(:issue, title: 'Feature1', description: 'Feature submitted for issue1', project: project)
297 298
  end

299
  step 'I fill in issue search with \'Description for issue1\'' do
300
    filter_issue 'Description for issue'
301 302
  end

303
  step 'I fill in issue search with \'issue1\'' do
304
    filter_issue 'issue1'
305 306
  end

307
  step 'I fill in issue search with \'Rock and roll\'' do
308
    filter_issue 'Rock and roll'
309 310
  end

311
  step 'I should see \'Bugfix1\' in issues' do
312
    expect(page).to have_content 'Bugfix1'
313 314
  end

315
  step 'I should see \'Feature1\' in issues' do
316
    expect(page).to have_content 'Feature1'
317 318
  end

319
  step 'I should not see \'Bugfix1\' in issues' do
320
    expect(page).not_to have_content 'Bugfix1'
321
  end
322

323 324 325 326 327 328 329
  step 'issue \'Release 0.4\' has label \'bug\'' do
    label = project.labels.create!(name: 'bug', color: '#990000')
    issue = Issue.find_by!(title: 'Release 0.4')
    issue.labels << label
  end

  step 'I click label \'bug\'' do
330
    page.within ".issues-list" do
331 332 333 334
      click_link 'bug'
    end
  end

335
  step 'I should not see labels field' do
336
    page.within '.issue-form' do
337 338 339 340 341
      expect(page).not_to have_content("Labels")
    end
  end

  step 'I should not see milestone field' do
342
    page.within '.issue-form' do
343 344 345 346 347
      expect(page).not_to have_content("Milestone")
    end
  end

  step 'I should not see assignee field' do
348
    page.within '.issue-form' do
349 350 351 352
      expect(page).not_to have_content("Assign to")
    end
  end

353
  def filter_issue(text)
barthc committed
354
    fill_in 'issuable_search', with: text
355
  end
356
end