BigW Consortium Gitlab

issues.rb 9.98 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('.issuable-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('.issuable-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
    click_link "All"
48 49
    # Waits for load
    expect(find('.issues-state-filters > .active')).to have_content 'All'
50 51
  end

52
  step 'I click link "Release 0.4"' do
53 54 55
    click_link "Release 0.4"
  end

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

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

64
  step 'I click link "New issue"' do
65
    page.has_link?('New Issue') ? click_link('New Issue') : click_link('New issue')
66 67
  end

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

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

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

85 86
  step 'I submit new issue "500 error on profile" with label \'bug\'' do
    fill_in "issue_title", with: "500 error on profile"
87 88
    click_button "Label"
    click_link "bug"
89
    click_button "Submit issue"
90 91
  end

92
  step 'I click link "500 error on profile"' do
93 94 95
    click_link "500 error on profile"
  end

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

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

109
  step 'I fill in issue search with "Re"' do
110
    filter_issue "Re"
111 112
  end

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

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

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

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

129
  step 'project "Shop" has milestone "v2.2"' do
130
    milestone = create(:milestone, title: "v2.2", project: project)
131

132
    3.times { create(:issue, project: project, milestone: milestone) }
133 134
  end

135
  step 'project "Shop" has milestone "v3.0"' do
136
    milestone = create(:milestone, title: "v3.0", project: project)
137

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

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

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

  When 'I select first assignee from "Shop" project' do
    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
    create(:issue,
164 165
           title: "Release 0.4",
           project: project,
166 167 168
           author: project.users.first,
           description: "# Description header"
          )
169 170
  end

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

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

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

192
  step 'issue "Release 0.4" have 2 upvotes and 1 downvote' do
193
    awardable = Issue.find_by(title: 'Release 0.4')
194 195
    create_list(:award_emoji, 2, awardable: awardable)
    create(:award_emoji, :downvote, awardable: awardable)
196 197 198
  end

  step 'issue "Tweet control" have 1 upvote and 2 downvotes' do
199 200 201
    awardable = Issue.find_by(title: 'Tweet control')
    create(:award_emoji, :upvote, awardable: awardable)
    create_list(:award_emoji, 2, awardable: awardable, name: 'thumbsdown')
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
  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'
218
        expect(page).not_to have_content '0 0'
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
      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'
237
        expect(page).not_to have_content '0 0'
238 239 240 241
      end
    end
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

348
  def filter_issue(text)
barthc committed
349
    fill_in 'issuable_search', with: text
350
  end
351
end