summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
Diffstat (limited to 'qa')
-rw-r--r--qa/qa.rb4
-rw-r--r--qa/qa/factory/resource/project.rb4
-rw-r--r--qa/qa/factory/resource/project_imported_from_github.rb42
-rw-r--r--qa/qa/page/menu/side.rb8
-rw-r--r--qa/qa/page/project/github_import.rb52
-rw-r--r--qa/qa/page/project/import.rb15
-rw-r--r--qa/qa/page/project/new.rb8
-rw-r--r--qa/qa/page/project/show.rb14
-rw-r--r--qa/qa/runtime/env.rb5
-rw-r--r--qa/qa/scenario/test/integration/github.rb18
-rw-r--r--qa/qa/specs/features/project/import_from_github_spec.rb104
11 files changed, 272 insertions, 2 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 41fca37c8f2..f40e927cb88 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -40,6 +40,7 @@ module QA
autoload :Issue, 'qa/factory/resource/issue'
autoload :Project, 'qa/factory/resource/project'
autoload :MergeRequest, 'qa/factory/resource/merge_request'
+ autoload :ProjectImportedFromGithub, 'qa/factory/resource/project_imported_from_github'
autoload :DeployKey, 'qa/factory/resource/deploy_key'
autoload :Branch, 'qa/factory/resource/branch'
autoload :SecretVariable, 'qa/factory/resource/secret_variable'
@@ -79,6 +80,7 @@ module QA
autoload :Instance, 'qa/scenario/test/instance'
module Integration
+ autoload :Github, 'qa/scenario/test/integration/github'
autoload :LDAP, 'qa/scenario/test/integration/ldap'
autoload :Kubernetes, 'qa/scenario/test/integration/kubernetes'
autoload :Mattermost, 'qa/scenario/test/integration/mattermost'
@@ -131,6 +133,8 @@ module QA
autoload :New, 'qa/page/project/new'
autoload :Show, 'qa/page/project/show'
autoload :Activity, 'qa/page/project/activity'
+ autoload :Import, 'qa/page/project/import'
+ autoload :GithubImport, 'qa/page/project/github_import'
module Pipeline
autoload :Index, 'qa/page/project/pipeline/index'
diff --git a/qa/qa/factory/resource/project.rb b/qa/qa/factory/resource/project.rb
index cda1b35ba6a..9f0f12f8cfb 100644
--- a/qa/qa/factory/resource/project.rb
+++ b/qa/qa/factory/resource/project.rb
@@ -8,8 +8,8 @@ module QA
dependency Factory::Resource::Group, as: :group
- def name=(name)
- @name = "#{name}-#{SecureRandom.hex(8)}"
+ def name=(raw_name)
+ @name = "#{raw_name}-#{SecureRandom.hex(8)}"
@description = 'My awesome project'
end
diff --git a/qa/qa/factory/resource/project_imported_from_github.rb b/qa/qa/factory/resource/project_imported_from_github.rb
new file mode 100644
index 00000000000..d1d1533fba9
--- /dev/null
+++ b/qa/qa/factory/resource/project_imported_from_github.rb
@@ -0,0 +1,42 @@
+require 'securerandom'
+
+module QA
+ module Factory
+ module Resource
+ class ProjectImportedFromGithub < Factory::Base
+ attr_writer :personal_access_token, :github_repo_path
+ attr_reader :name
+
+ dependency Factory::Resource::Group, as: :group
+
+ def name=(raw_name)
+ @name = "#{raw_name}-#{SecureRandom.hex(8)}"
+ end
+
+ product :name do |factory|
+ factory.name
+ end
+
+ def fabricate!
+ group.visit!
+
+ Page::Group::Show.act { go_to_new_project }
+
+ Page::Project::New.perform do |page|
+ page.go_to_import_project
+ end
+
+ Page::Project::Import.perform do |page|
+ page.go_to_github_import
+ end
+
+ Page::Project::GithubImport.perform do |page|
+ page.add_personal_access_token(@personal_access_token)
+ page.list_repos
+ page.import(@github_repo_path, @name)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/menu/side.rb b/qa/qa/page/menu/side.rb
index 6bf4825cf00..333d871c51a 100644
--- a/qa/qa/page/menu/side.rb
+++ b/qa/qa/page/menu/side.rb
@@ -10,6 +10,8 @@ module QA
element :operations_kubernetes_link, "title: _('Kubernetes')"
element :issues_link, /link_to.*shortcuts-issues/
element :issues_link_text, "Issues"
+ element :merge_requests_link, /link_to.*shortcuts-merge_requests/
+ element :merge_requests_link_text, "Merge Requests"
element :top_level_items, '.sidebar-top-level-items'
element :operations_section, "class: 'shortcuts-operations'"
element :activity_link, "title: 'Activity'"
@@ -62,6 +64,12 @@ module QA
end
end
+ def click_merge_requests
+ within_sidebar do
+ click_link('Merge Requests')
+ end
+ end
+
def click_wiki
within_sidebar do
click_link('Wiki')
diff --git a/qa/qa/page/project/github_import.rb b/qa/qa/page/project/github_import.rb
new file mode 100644
index 00000000000..5451ac5d5c4
--- /dev/null
+++ b/qa/qa/page/project/github_import.rb
@@ -0,0 +1,52 @@
+module QA
+ module Page
+ module Project
+ class GithubImport < Page::Base
+ view 'app/views/import/github/new.html.haml' do
+ element :personal_access_token_field, 'text_field_tag :personal_access_token'
+ element :list_repos_button, "submit_tag _('List your GitHub repositories')"
+ end
+
+ view 'app/views/import/_githubish_status.html.haml' do
+ element :project_import_row, 'data: { qa: { repo_path: repo.full_name } }'
+ element :project_namespace_select
+ element :project_namespace_field, 'select_tag :namespace_id'
+ element :project_path_field, 'text_field_tag :path, repo.name'
+ element :import_button, "_('Import')"
+ end
+
+ def add_personal_access_token(personal_access_token)
+ fill_in 'personal_access_token', with: personal_access_token
+ end
+
+ def list_repos
+ click_button 'List your GitHub repositories'
+ end
+
+ def import(full_path, name)
+ choose_test_namespace(full_path)
+ within_repo_path(full_path) do
+ fill_in 'path', with: name
+ click_button 'Import'
+ end
+ end
+
+ private
+
+ def within_repo_path(full_path)
+ page.within(%Q(tr[data-qa-repo-path="#{full_path}"])) do
+ yield
+ end
+ end
+
+ def choose_test_namespace(full_path)
+ within_repo_path(full_path) do
+ click_element :project_namespace_select
+ end
+
+ find('ul.select2-result-sub > li', text: Runtime::Namespace.path).click
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/project/import.rb b/qa/qa/page/project/import.rb
new file mode 100644
index 00000000000..5f58b4c2d22
--- /dev/null
+++ b/qa/qa/page/project/import.rb
@@ -0,0 +1,15 @@
+module QA
+ module Page
+ module Project
+ class Import < Page::Base
+ view 'app/views/projects/_import_project_pane.html.haml' do
+ element :import_github, "icon('github', text: 'GitHub')"
+ end
+
+ def go_to_github_import
+ click_link 'GitHub'
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/project/new.rb b/qa/qa/page/project/new.rb
index 186a4724326..13b29321022 100644
--- a/qa/qa/page/project/new.rb
+++ b/qa/qa/page/project/new.rb
@@ -2,6 +2,10 @@ module QA
module Page
module Project
class New < Page::Base
+ view 'app/views/projects/new.html.haml' do
+ element :import_project_tab, "Import project"
+ end
+
view 'app/views/projects/_new_project_fields.html.haml' do
element :project_namespace_select
element :project_namespace_field, /select :namespace_id.*class: 'select2/
@@ -16,6 +20,10 @@ module QA
find('ul.select2-result-sub > li', text: Runtime::Namespace.path).click
end
+ def go_to_import_project
+ click_on 'Import project'
+ end
+
def choose_name(name)
fill_in 'project_path', with: name
end
diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb
index 1406edece17..ff11e81f5e1 100644
--- a/qa/qa/page/project/show.rb
+++ b/qa/qa/page/project/show.rb
@@ -22,6 +22,14 @@ module QA
element :branches_dropdown
end
+ view 'app/views/projects/_files.html.haml' do
+ element :tree_holder, '.tree-holder'
+ end
+
+ def repository_location
+ Git::Location.new(find('#project_clone').value)
+ end
+
def project_name
find('.qa-project-name').text
end
@@ -46,6 +54,12 @@ module QA
click_element :create_merge_request
end
+ def wait_for_import
+ wait(reload: true) do
+ has_css?('.tree-holder')
+ end
+ end
+
def go_to_new_issue
click_element :new_menu_toggle
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb
index 2126ce6b234..ae1d90d8200 100644
--- a/qa/qa/runtime/env.rb
+++ b/qa/qa/runtime/env.rb
@@ -62,6 +62,11 @@ module QA
def gcloud_zone
ENV.fetch('GCLOUD_ZONE')
end
+
+ # Specifies the token that can be used for the GitHub API
+ def github_personal_access_token
+ ENV.fetch('GITHUB_PERSONAL_ACCESS_TOKEN')
+ end
end
end
end
diff --git a/qa/qa/scenario/test/integration/github.rb b/qa/qa/scenario/test/integration/github.rb
new file mode 100644
index 00000000000..f639711b895
--- /dev/null
+++ b/qa/qa/scenario/test/integration/github.rb
@@ -0,0 +1,18 @@
+module QA
+ module Scenario
+ module Test
+ module Integration
+ class Github < Test::Instance
+ tags :github
+
+ def perform(address, *rspec_options)
+ # This test suite requires a GitHub personal access token
+ Runtime::Env.github_personal_access_token
+
+ super
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/specs/features/project/import_from_github_spec.rb b/qa/qa/specs/features/project/import_from_github_spec.rb
new file mode 100644
index 00000000000..a22680a083f
--- /dev/null
+++ b/qa/qa/specs/features/project/import_from_github_spec.rb
@@ -0,0 +1,104 @@
+module QA
+ feature 'user imports a GitHub repo', :core, :github do
+ after do
+ # We need to delete the imported project because it's impossible to import
+ # the same GitHub project twice for a given user.
+ if @imported_project
+ api_client = Runtime::API::Client.new(:gitlab)
+ delete_project_request = Runtime::API::Request.new(api_client, "/projects/#{CGI.escape("#{Runtime::Namespace.path}/#{@imported_project.name}")}")
+ delete delete_project_request.url
+
+ expect_status(202)
+ end
+ end
+
+ scenario 'user imports a GitHub repo' do
+ Runtime::Browser.visit(:gitlab, Page::Main::Login)
+ Page::Main::Login.act { sign_in_using_credentials }
+
+ @imported_project = Factory::Resource::ProjectImportedFromGithub.fabricate! do |project|
+ project.name = 'imported-project'
+ project.personal_access_token = Runtime::Env.github_personal_access_token
+ project.github_repo_path = 'gitlab-qa/test-project'
+ end
+
+ Page::Menu::Main.act { go_to_projects }
+ Page::Dashboard::Projects.perform do |dashboard|
+ dashboard.go_to_project(@imported_project.name)
+ end
+
+ Page::Project::Show.act { wait_for_import }
+
+ verify_repository_import
+ verify_issues_import
+ verify_merge_requests_import
+ verify_labels_import
+ verify_milestones_import
+ verify_wiki_import
+ end
+
+ def verify_repository_import
+ expect(page).to have_content('This test project is used for automated GitHub import by GitLab QA.')
+ expect(page).to have_content(@imported_project.name)
+ end
+
+ def verify_issues_import
+ Page::Menu::Side.act { click_issues }
+ expect(page).to have_content('This is a sample issue')
+
+ click_link 'This is a sample issue'
+
+ expect(page).to have_content('We should populate this project with issues, pull requests and wiki pages.')
+
+ # Comments
+ expect(page).to have_content('This is a comment from @rymai.')
+
+ Page::Issuable::Show.perform do |issuable|
+ expect(issuable).to have_label('enhancement')
+ expect(issuable).to have_label('help wanted')
+ expect(issuable).to have_label('good first issue')
+ end
+ end
+
+ def verify_merge_requests_import
+ Page::Menu::Side.act { click_merge_requests }
+ expect(page).to have_content('Improve README.md')
+
+ click_link 'Improve README.md'
+
+ expect(page).to have_content('This improves the README file a bit.')
+
+ # Review comment are not supported yet
+ expect(page).not_to have_content('Really nice change.')
+
+ # Comments
+ expect(page).to have_content('Nice work! This is a comment from @rymai.')
+
+ # Diff comments
+ expect(page).to have_content('[Review comment] I like that!')
+ expect(page).to have_content('[Review comment] Nice blank line.')
+ expect(page).to have_content('[Single diff comment] Much better without this line!')
+
+ Page::Issuable::Show.perform do |issuable|
+ expect(issuable).to have_label('bug')
+ expect(issuable).to have_label('enhancement')
+ end
+ end
+
+ def verify_labels_import
+ # TODO: Waiting on https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/19228
+ # to build upon it.
+ end
+
+ def verify_milestones_import
+ # TODO: Waiting on https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18727
+ # to build upon it.
+ end
+
+ def verify_wiki_import
+ Page::Menu::Side.act { click_wiki }
+
+ expect(page).to have_content('Welcome to the test-project wiki!')
+ end
+ end
+end