BigW Consortium Gitlab

markdown_render.rb 10.4 KB
Newer Older
1 2 3
# If you need to modify the existing seed repository for your tests,
# it is recommended that you make the changes on the `markdown` branch of the seed project repository,
# which should only be used by tests in this file. See `/spec/factories.rb#project` for more info.
4
class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
5 6
  include SharedAuthentication
  include SharedPaths
7
  include SharedMarkdown
8
  include WaitForRequests
9

10
  step 'I own project "Delta"' do
11
    @project = ::Project.find_by(name: "Delta")
12
    @project ||= create(:project, :repository, name: "Delta", namespace: @user.namespace)
13 14 15
    @project.team << [@user, :master]
  end

16
  step 'I should see files from repository in markdown' do
17
    expect(current_path).to eq project_tree_path(@project, "markdown")
18 19
    expect(page).to have_content "README.md"
    expect(page).to have_content "CHANGELOG"
20 21
  end

22
  step 'I should see rendered README which contains correct links' do
23 24 25 26 27 28 29
    expect(page).to have_content "Welcome to GitLab GitLab is a free project and repository management application"
    expect(page).to have_link "GitLab API doc"
    expect(page).to have_link "GitLab API website"
    expect(page).to have_link "Rake tasks"
    expect(page).to have_link "backup and restore procedure"
    expect(page).to have_link "GitLab API doc directory"
    expect(page).to have_link "Maintenance"
30 31
  end

32
  step 'I click on Gitlab API in README' do
33 34 35
    click_link "GitLab API doc"
  end

36
  step 'I should see correct document rendered' do
37
    expect(current_path).to eq project_blob_path(@project, "markdown/doc/api/README.md")
38
    wait_for_requests
39
    expect(page).to have_content "All API requests require authentication"
40 41
  end

42
  step 'I click on Rake tasks in README' do
43 44 45
    click_link "Rake tasks"
  end

46
  step 'I should see correct directory rendered' do
47
    expect(current_path).to eq project_tree_path(@project, "markdown/doc/raketasks")
48 49
    expect(page).to have_content "backup_restore.md"
    expect(page).to have_content "maintenance.md"
50 51
  end

52
  step 'I click on GitLab API doc directory in README' do
53 54 55
    click_link "GitLab API doc directory"
  end

56
  step 'I should see correct doc/api directory rendered' do
57
    expect(current_path).to eq project_tree_path(@project, "markdown/doc/api")
58 59
    expect(page).to have_content "README.md"
    expect(page).to have_content "users.md"
60 61
  end

62
  step 'I click on Maintenance in README' do
63 64 65
    click_link "Maintenance"
  end

66
  step 'I should see correct maintenance file rendered' do
67
    expect(current_path).to eq project_blob_path(@project, "markdown/doc/raketasks/maintenance.md")
68
    wait_for_requests
69
    expect(page).to have_content "bundle exec rake gitlab:env:info RAILS_ENV=production"
70 71
  end

72
  step 'I click on link "empty" in the README' do
73
    page.within('.readme-holder') do
74 75 76 77
      click_link "empty"
    end
  end

78
  step 'I click on link "id" in the README' do
79
    page.within('.readme-holder') do
80 81 82 83
      click_link "#id"
    end
  end

84
  step 'I navigate to the doc/api/README' do
85
    page.within '.tree-table' do
86 87 88
      click_link "doc"
    end

89
    page.within '.tree-table' do
90 91 92
      click_link "api"
    end

93 94
    wait_for_requests

95
    page.within '.tree-table' do
96 97
      click_link "README.md"
    end
98 99
  end

100
  step 'I see correct file rendered' do
101
    expect(current_path).to eq project_blob_path(@project, "markdown/doc/api/README.md")
102
    wait_for_requests
103 104 105
    expect(page).to have_content "Contents"
    expect(page).to have_link "Users"
    expect(page).to have_link "Rake tasks"
106 107
  end

108
  step 'I click on users in doc/api/README' do
109 110 111
    click_link "Users"
  end

112
  step 'I should see the correct document file' do
113
    expect(current_path).to eq project_blob_path(@project, "markdown/doc/api/users.md")
114
    expect(page).to have_content "Get a list of users."
115 116
  end

117
  step 'I click on raketasks in doc/api/README' do
118 119 120
    click_link "Rake tasks"
  end

121 122
  # Markdown branch

123
  When 'I visit markdown branch' do
124
    visit project_tree_path(@project, "markdown")
125
    wait_for_requests
126 127
  end

128
  When 'I visit markdown branch "README.md" blob' do
129
    visit project_blob_path(@project, "markdown/README.md")
130 131 132
  end

  When 'I visit markdown branch "d" tree' do
133
    visit project_tree_path(@project, "markdown/d")
134 135 136
  end

  When 'I visit markdown branch "d/README.md" blob' do
137
    visit project_blob_path(@project, "markdown/d/README.md")
138 139
  end

140
  step 'I should see files from repository in markdown branch' do
141
    expect(current_path).to eq project_tree_path(@project, "markdown")
142 143
    expect(page).to have_content "README.md"
    expect(page).to have_content "CHANGELOG"
144 145
  end

146
  step 'I see correct file rendered in markdown branch' do
147
    expect(current_path).to eq project_blob_path(@project, "markdown/doc/api/README.md")
148
    wait_for_requests
149 150 151
    expect(page).to have_content "Contents"
    expect(page).to have_link "Users"
    expect(page).to have_link "Rake tasks"
152 153
  end

154
  step 'I should see correct document rendered for markdown branch' do
155
    expect(current_path).to eq project_blob_path(@project, "markdown/doc/api/README.md")
156
    wait_for_requests
157
    expect(page).to have_content "All API requests require authentication"
158 159
  end

160
  step 'I should see correct directory rendered for markdown branch' do
161
    expect(current_path).to eq project_tree_path(@project, "markdown/doc/raketasks")
162 163
    expect(page).to have_content "backup_restore.md"
    expect(page).to have_content "maintenance.md"
164 165
  end

166
  step 'I should see the users document file in markdown branch' do
167
    expect(current_path).to eq project_blob_path(@project, "markdown/doc/api/users.md")
168
    expect(page).to have_content "Get a list of users."
169 170
  end

171 172
  # Expected link contents

173
  step 'The link with text "empty" should have url "tree/markdown"' do
174
    wait_for_requests
175
    find('a', text: /^empty$/)['href'] == current_host + project_tree_path(@project, "markdown")
176 177
  end

178
  step 'The link with text "empty" should have url "blob/markdown/README.md"' do
179
    find('a', text: /^empty$/)['href'] == current_host + project_blob_path(@project, "markdown/README.md")
180 181
  end

182
  step 'The link with text "empty" should have url "tree/markdown/d"' do
183
    find('a', text: /^empty$/)['href'] == current_host + project_tree_path(@project, "markdown/d")
184 185
  end

186 187
  step 'The link with text "empty" should have '\
       'url "blob/markdown/d/README.md"' do
188
    find('a', text: /^empty$/)['href'] == current_host + project_blob_path(@project, "markdown/d/README.md")
189 190
  end

191
  step 'The link with text "ID" should have url "tree/markdownID"' do
192
    find('a', text: /^#id$/)['href'] == current_host + project_tree_path(@project, "markdown") + '#id'
193 194
  end

195
  step 'The link with text "/ID" should have url "tree/markdownID"' do
196
    find('a', text: /^\/#id$/)['href'] == current_host + project_tree_path(@project, "markdown") + '#id'
197 198
  end

199 200
  step 'The link with text "README.mdID" '\
       'should have url "blob/markdown/README.mdID"' do
201
    find('a', text: /^README.md#id$/)['href'] == current_host + project_blob_path(@project, "markdown/README.md") + '#id'
202 203
  end

204 205
  step 'The link with text "d/README.mdID" should have '\
       'url "blob/markdown/d/README.mdID"' do
206
    find('a', text: /^d\/README.md#id$/)['href'] == current_host + project_blob_path(@project, "d/markdown/README.md") + '#id'
207 208
  end

209
  step 'The link with text "ID" should have url "blob/markdown/README.mdID"' do
210
    wait_for_requests
211
    find('a', text: /^#id$/)['href'] == current_host + project_blob_path(@project, "markdown/README.md") + '#id'
212 213
  end

214
  step 'The link with text "/ID" should have url "blob/markdown/README.mdID"' do
215
    find('a', text: /^\/#id$/)['href'] == current_host + project_blob_path(@project, "markdown/README.md") + '#id'
216 217 218 219
  end

  # Wiki

220
  step 'I go to wiki page' do
221
    click_link "Wiki"
222
    expect(current_path).to eq project_wiki_path(@project, "home")
223 224
  end

225
  step 'I add various links to the wiki page' do
Marin Jankovski committed
226
    fill_in "wiki[content]", with: "[test](test)\n[GitLab API doc](api)\n[Rake tasks](raketasks)\n"
227
    fill_in "wiki[message]", with: "Adding links to wiki"
228 229 230
    page.within '.wiki-form' do
      click_button "Create page"
    end
231 232
  end

233
  step 'Wiki page should have added links' do
234
    expect(current_path).to eq project_wiki_path(@project, "home")
235
    expect(page).to have_content "test GitLab API doc Rake tasks"
236 237
  end

238 239 240
  step 'I add a header to the wiki page' do
    fill_in "wiki[content]", with: "# Wiki header\n"
    fill_in "wiki[message]", with: "Add header to wiki"
241 242 243
    page.within '.wiki-form' do
      click_button "Create page"
    end
244 245 246 247 248 249
  end

  step 'Wiki header should have correct id and link' do
    header_should_have_correct_id_and_link(1, 'Wiki header', 'wiki-header')
  end

250
  step 'I click on test link' do
251 252 253
    click_link "test"
  end

254
  step 'I see new wiki page named test' do
255
    expect(current_path).to eq  project_wiki_path(@project, "test")
256 257 258

    page.within(:css, ".nav-text") do
      expect(page).to have_content "Test"
259
      expect(page).to have_content "Create Page"
260
    end
261 262 263
  end

  When 'I go back to wiki page home' do
264 265
    visit project_wiki_path(@project, "home")
    expect(current_path).to eq project_wiki_path(@project, "home")
266 267
  end

268
  step 'I click on GitLab API doc link' do
269 270 271
    click_link "GitLab API"
  end

272
  step 'I see Gitlab API document' do
273
    expect(current_path).to eq project_wiki_path(@project, "api")
274 275

    page.within(:css, ".nav-text") do
276
      expect(page).to have_content "Create"
277 278
      expect(page).to have_content "Api"
    end
279 280
  end

281
  step 'I click on Rake tasks link' do
282 283 284
    click_link "Rake tasks"
  end

285
  step 'I see Rake tasks directory' do
286
    expect(current_path).to eq project_wiki_path(@project, "raketasks")
287 288

    page.within(:css, ".nav-text") do
289
      expect(page).to have_content "Create"
290 291
      expect(page).to have_content "Rake"
    end
292
  end
293

294
  step 'I go directory which contains README file' do
295 296
    visit project_tree_path(@project, "markdown/doc/api")
    expect(current_path).to eq project_tree_path(@project, "markdown/doc/api")
297 298
  end

299
  step 'I click on a relative link in README' do
300 301 302
    click_link "Users"
  end

303
  step 'I should see the correct markdown' do
304
    expect(current_path).to eq project_blob_path(@project, "markdown/doc/api/users.md")
305
    wait_for_requests
306
    expect(page).to have_content "List users"
307
  end
308 309

  step 'Header "Application details" should have correct id and link' do
310
    wait_for_requests
311 312 313 314 315 316
    header_should_have_correct_id_and_link(2, 'Application details', 'application-details')
  end

  step 'Header "GitLab API" should have correct id and link' do
    header_should_have_correct_id_and_link(1, 'GitLab API', 'gitlab-api')
  end
317
end