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
    expect(find('.subscribe-button span')).to have_content 'Unsubscribe'
Valery Sizov committed
24 25 26
  end

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

30
  step 'I click link "Closed"' do
Phil Hughes committed
31
    find('.issues-state-filters a', text: "Closed").click
32 33
  end

Valery Sizov committed
34 35 36 37
  step 'I click button "Unsubscribe"' do
    click_on "Unsubscribe"
  end

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

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

46
  step 'I click link "All"' do
47 48 49
    click_link "All"
  end

50
  step 'I click link "Release 0.4"' do
51 52 53
    click_link "Release 0.4"
  end

54
  step 'I should see issue "Release 0.4"' do
55
    expect(page).to have_content "Release 0.4"
56 57
  end

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

62
  step 'I click link "New Issue"' do
63 64 65
    click_link "New Issue"
  end

66
  step 'I click "author" dropdown' do
Phil Hughes committed
67 68
    page.find('.js-author-search').click
    sleep 1
69 70 71
  end

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

78
  step 'I submit new issue "500 error on profile"' do
79
    fill_in "issue_title", with: "500 error on profile"
80
    click_button "Submit issue"
81 82
  end

83 84 85
  step 'I submit new issue "500 error on profile" with label \'bug\'' do
    fill_in "issue_title", with: "500 error on profile"
    select 'bug', from: "Labels"
86
    click_button "Submit issue"
87 88
  end

89
  step 'I click link "500 error on profile"' do
90 91 92
    click_link "500 error on profile"
  end

93
  step 'I should see label \'bug\' with issue' do
Douwe Maan committed
94
    page.within '.issuable-show-labels' do
95
      expect(page).to have_content 'bug'
96 97 98
    end
  end

99
  step 'I should see issue "500 error on profile"' do
skv committed
100
    issue = Issue.find_by(title: "500 error on profile")
101 102 103
    expect(page).to have_content issue.title
    expect(page).to have_content issue.author_name
    expect(page).to have_content issue.project.name
104 105
  end

106
  step 'I fill in issue search with "Re"' do
107
    filter_issue "Re"
108 109
  end

110
  step 'I fill in issue search with "Bu"' do
111
    filter_issue "Bu"
112 113
  end

114
  step 'I fill in issue search with ".3"' do
115
    filter_issue ".3"
116 117
  end

118
  step 'I fill in issue search with "Something"' do
119
    filter_issue "Something"
120 121
  end

122
  step 'I fill in issue search with ""' do
123
    filter_issue ""
124 125
  end

126
  step 'project "Shop" has milestone "v2.2"' do
127

128
    milestone = create(:milestone, title: "v2.2", project: project)
129

130
    3.times { create(:issue, project: project, milestone: milestone) }
131 132
  end

133
  step 'project "Shop" has milestone "v3.0"' do
134

135
    milestone = create(:milestone, title: "v3.0", project: project)
136

137
    3.times { create(:issue, project: project, milestone: milestone) }
138 139 140 141 142 143
  end

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

144
  step 'I should see selected milestone with title "v3.0"' do
145
    issues_milestone_selector = "#issue_milestone_id_chzn > a"
146
    expect(find(issues_milestone_selector)).to have_content("v3.0")
147 148 149
  end

  When 'I select first assignee from "Shop" project' do
150

151 152 153 154
    first_assignee = project.users.first
    select first_assignee.name, from: "assignee_id"
  end

155
  step 'I should see first assignee from "Shop" as selected assignee' do
156
    issues_assignee_selector = "#issue_assignee_id_chzn > a"
157

158
    assignee_name = project.users.first.name
159
    expect(find(issues_assignee_selector)).to have_content(assignee_name)
160 161
  end

162
  step 'project "Shop" have "Release 0.4" open issue' do
163

164
    create(:issue,
165 166
           title: "Release 0.4",
           project: project,
167 168 169
           author: project.users.first,
           description: "# Description header"
          )
170 171
  end

172
  step 'project "Shop" have "Tweet control" open issue' do
173
    create(:issue,
174
           title: "Tweet control",
175 176 177 178
           project: project,
           author: project.users.first)
  end

179 180 181 182 183 184 185
  step 'project "Shop" have "Bugfix" open issue' do
    create(:issue,
           title: "Bugfix",
           project: project,
           author: project.users.first)
  end

186
  step 'project "Shop" have "Release 0.3" closed issue' do
Andrew8xx8 committed
187
    create(:closed_issue,
188 189 190
           title: "Release 0.3",
           project: project,
           author: project.users.first)
191
  end
192

193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
  step 'issue "Release 0.4" have 2 upvotes and 1 downvote' do
    issue = Issue.find_by(title: 'Release 0.4')
    create_list(:upvote_note, 2, project: project, noteable: issue)
    create(:downvote_note, project: project, noteable: issue)
  end

  step 'issue "Tweet control" have 1 upvote and 2 downvotes' do
    issue = Issue.find_by(title: 'Tweet control')
    create(:upvote_note, project: project, noteable: issue)
    create_list(:downvote_note, 2, project: project, noteable: issue)
  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'
219
        expect(page).to_not have_content '0 0'
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
      end
    end
  end

  step 'The list should be sorted by "Most popular"' do
    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'
238
        expect(page).to_not have_content '0 0'
239 240 241 242
      end
    end
  end

243
  step 'empty project "Empty Project"' do
244
    create :project_empty_repo, name: 'Empty Project', namespace: @user.namespace
245 246 247 248
  end

  When 'I visit empty project page' do
    project = Project.find_by(name: 'Empty Project')
Vinnie Okada committed
249
    visit namespace_project_path(project.namespace, project)
250 251
  end

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

259 260 261 262 263
  When "I visit project \"Community\" issues page" do
    project = Project.find_by(name: 'Community')
    visit namespace_project_issues_path(project.namespace, project)
  end

264 265
  When "I visit empty project's issues page" do
    project = Project.find_by(name: 'Empty Project')
Vinnie Okada committed
266
    visit namespace_project_issues_path(project.namespace, project)
267
  end
Marin Jankovski committed
268 269

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

277
  step 'I should see an error alert section within the comment form' do
278
    page.within(".js-main-target-form") do
279 280 281 282
      find(".error-alert")
    end
  end

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

287
  step 'project \'Shop\' has issue \'Bugfix1\' with description: \'Description for issue1\'' do
288
    create(:issue, title: 'Bugfix1', description: 'Description for issue1', project: project)
289 290
  end

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

295
  step 'I fill in issue search with \'Description for issue1\'' do
296
    filter_issue 'Description for issue'
297 298
  end

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

303
  step 'I fill in issue search with \'Rock and roll\'' do
304
    filter_issue 'Description for issue'
305 306
  end

307
  step 'I should see \'Bugfix1\' in issues' do
308
    expect(page).to have_content 'Bugfix1'
309 310
  end

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

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

319 320 321 322 323 324 325
  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
326
    page.within ".issues-list" do
327 328 329 330
      click_link 'bug'
    end
  end

331
  step 'I should not see labels field' do
332
    page.within '.issue-form' do
333 334 335 336 337
      expect(page).not_to have_content("Labels")
    end
  end

  step 'I should not see milestone field' do
338
    page.within '.issue-form' do
339 340 341 342 343
      expect(page).not_to have_content("Milestone")
    end
  end

  step 'I should not see assignee field' do
344
    page.within '.issue-form' do
345 346 347 348
      expect(page).not_to have_content("Assign to")
    end
  end

349 350 351 352 353 354 355 356 357 358
  step 'another user adds a comment with text "Yay!" to issue "Release 0.4"' do
    issue = Issue.find_by!(title: 'Release 0.4')
    create(:note_on_issue, noteable: issue,  note: 'Yay!')
  end

  step 'I should see a new comment with text "Yay!"' do
    page.within '#notes' do
      expect(page).to have_content('Yay!')
    end
  end
359

360 361 362
  def filter_issue(text)
    fill_in 'issue_search', with: text
  end
363

364
end