diff options
author | Rémy Coutable <remy@rymai.me> | 2017-07-05 13:35:10 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-05 13:35:28 +0200 |
commit | 476cc9a9202f48ecb595d81484d9154c54a77c32 (patch) | |
tree | ed4b082a1e269a2af06dc5c1571c924d513867a8 | |
parent | ef0ac7c21d087b8721465edb3a1759b5c3e968d8 (diff) | |
download | gitlab-ce-rc/add-push_activity-scnenario-to-qa.tar.gz |
[ci skip]
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | qa/Gemfile.lock | 7 | ||||
-rw-r--r-- | qa/qa/git/repository.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/project/activity.rb | 15 | ||||
-rw-r--r-- | qa/qa/scenario/gitlab/repository/push.rb | 62 | ||||
-rw-r--r-- | qa/qa/specs/config.rb | 7 | ||||
-rw-r--r-- | qa/qa/specs/features/repository/push_activity_spec.rb | 32 |
6 files changed, 120 insertions, 7 deletions
diff --git a/qa/Gemfile.lock b/qa/Gemfile.lock index 4dd71aa5010..14dc36f0cdf 100644 --- a/qa/Gemfile.lock +++ b/qa/Gemfile.lock @@ -13,14 +13,10 @@ GEM capybara-screenshot (1.0.14) capybara (>= 1.0, < 3) launchy - capybara-webkit (1.12.0) - capybara (>= 2.3.0, < 2.13.0) - json childprocess (0.7.0) ffi (~> 1.0, >= 1.0.11) diff-lcs (1.3) ffi (1.9.18) - json (2.0.3) launchy (2.4.3) addressable (~> 2.3) mime-types (3.1) @@ -62,10 +58,9 @@ PLATFORMS DEPENDENCIES capybara (~> 2.12.1) capybara-screenshot (~> 1.0.14) - capybara-webkit (~> 1.12.0) rake (~> 12.0.0) rspec (~> 3.5) selenium-webdriver (~> 2.53) BUNDLED WITH - 1.14.6 + 1.15.1 diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb index b9e199000d6..9db324ad6bf 100644 --- a/qa/qa/git/repository.rb +++ b/qa/qa/git/repository.rb @@ -66,6 +66,10 @@ module QA def commits `git log --oneline`.split("\n") end + + def last_commit_sha + `git show -s --format=%H HEAD`.strip + end end end end diff --git a/qa/qa/page/project/activity.rb b/qa/qa/page/project/activity.rb new file mode 100644 index 00000000000..9984251b378 --- /dev/null +++ b/qa/qa/page/project/activity.rb @@ -0,0 +1,15 @@ +module QA + module Page + module Project + class Activity < Page::Base + def visit_activity_page + click_on 'Activity' + end + + def filter_by_push_events + click_on 'Push events' + end + end + end + end +end diff --git a/qa/qa/scenario/gitlab/repository/push.rb b/qa/qa/scenario/gitlab/repository/push.rb new file mode 100644 index 00000000000..c6b7b515f7e --- /dev/null +++ b/qa/qa/scenario/gitlab/repository/push.rb @@ -0,0 +1,62 @@ +require 'securerandom' + +module QA + module Scenario + module Gitlab + module Repository + class Push < Scenario::Template + attr_writer :description + + def initialize + @files = {} + @commit = "Commiting files" + end + + def add_file(name, contents) + @files[name] = contents + end + + def commit=(raw_commit) + @raw_commit = raw_commit + end + + def perform + Git::Repository.perform do |repository| + repository.location = Page::Project::Show.act do + choose_repository_clone_http + repository_location + end + + repository.use_default_credentials + + repository.act do + clone + configure_identity('GitLab QA', 'root@gitlab.com') + @files.each { |file, content| add_file(file, content) } + commit(commit_title) + push_changes + @last_commit = last_commit_sha + end + end + + self + end + + def commit_title + "#{@raw_commit} - #{stamp}" + end + + def last_commit(size: :long) + size == :short ? @last_commit[0...8] : @last_commit + end + + private + + def stamp + @stamp ||= SecureRandom.hex(8) + end + end + end + end + end +end diff --git a/qa/qa/specs/config.rb b/qa/qa/specs/config.rb index b341aa3094a..531fde7c53b 100644 --- a/qa/qa/specs/config.rb +++ b/qa/qa/specs/config.rb @@ -55,11 +55,16 @@ module QA Capybara.register_driver :chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( 'chromeOptions' => { - 'binary' => '/usr/bin/google-chrome-stable', + # 'binary' => '/usr/bin/google-chrome-stable', + 'binary' => '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', 'args' => %w[headless no-sandbox disable-gpu] } ) + Capybara::Screenshot.register_driver(:chrome) do |driver, path| + driver.browser.save_screenshot(path) + end + Capybara::Selenium::Driver .new(app, browser: :chrome, desired_capabilities: capabilities) end diff --git a/qa/qa/specs/features/repository/push_activity_spec.rb b/qa/qa/specs/features/repository/push_activity_spec.rb new file mode 100644 index 00000000000..08077b8a27e --- /dev/null +++ b/qa/qa/specs/features/repository/push_activity_spec.rb @@ -0,0 +1,32 @@ +module QA + feature 'push code to repository' do + context 'with regular account over http' do + scenario 'user can see their push in the project activity page' do + Page::Main::Entry.act { sign_in_using_credentials } + + Scenario::Gitlab::Project::Create.perform do |scenario| + scenario.name = 'project_with_code' + scenario.description = 'project with repository' + end + + push = Scenario::Gitlab::Repository::Push.perform do |scenario| + scenario.add_file('README.md', '# This is test project') + scenario.commit('Add README.md') + end + + Page::Project::Show.act do + wait_for_push + end + + Page::Project::Activity.act do + visit_activity_page + filter_by_push_events + end + + expect(page).to have_content('GitLab QA pushed to branch master') + expect(page).to have_content(push.last_commit(:short)) + expect(page).to have_content(push.commit_title) + end + end + end +end |