Commit 3acfa7cb authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'refactor-many-tests-to-use-login-flow' into 'master'

Refactor many tests to use the login flow

See merge request gitlab-org/gitlab!21044
parents c7144fa3 356645b7
......@@ -4,8 +4,7 @@ module QA
context 'Configure', :orchestrated, :mattermost do
describe 'Mattermost support' do
it 'user creates a group with a mattermost team' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
Page::Main::Menu.perform(&:go_to_groups)
Page::Dashboard::Groups.perform do |groups|
......
......@@ -4,8 +4,7 @@ module QA
context 'Manage' do
describe 'Project transfer between groups' do
it 'user transfers a project between groups' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
source_group = Resource::Group.fabricate_via_api! do |group|
group.path = 'source-group'
......
......@@ -4,8 +4,7 @@ module QA
context 'Manage', :smoke do
describe 'basic user login' do
it 'user logs in using basic credentials and logs out' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
Page::Main::Menu.perform do |menu|
expect(menu).to have_personal_area
......
......@@ -4,8 +4,7 @@ module QA
context 'Manage', :orchestrated, :ldap_no_tls, :ldap_tls do
describe 'LDAP login' do
it 'user logs into GitLab using LDAP credentials' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
Page::Main::Menu.perform do |menu|
expect(menu).to have_personal_area
......
......@@ -4,8 +4,7 @@ module QA
context 'Manage', :orchestrated, :mattermost do
describe 'Mattermost login' do
it 'user logs into Mattermost using GitLab OAuth' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
Support::Retrier.retry_on_exception do
Runtime::Browser.visit(:mattermost, Page::Mattermost::Login)
......
......@@ -4,8 +4,7 @@ module QA
context 'Manage' do
describe 'Add project member' do
it 'user adds project member' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
user = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
......
......@@ -4,8 +4,7 @@ module QA
context 'Manage', :smoke do
describe 'Project creation' do
it 'user creates a new project' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
created_project = Resource::Project.fabricate_via_browser_ui! do |project|
project.name = 'awesome-project'
......
......@@ -23,8 +23,7 @@ module QA
end
it 'user imports a GitHub repo' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
imported_project # import the project
......
......@@ -4,8 +4,7 @@ module QA
context 'Manage' do
describe 'Project activity' do
it 'user creates an event in the activity page upon Git push' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
project_push = Resource::Repository::ProjectPush.fabricate! do |push|
push.file_name = 'README.md'
......
......@@ -4,8 +4,7 @@ module QA
context 'Create' do
describe 'Create a new merge request' do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@project = Resource::Project.fabricate_via_api! do |project|
project.name = 'project'
......
......@@ -4,8 +4,7 @@ module QA
context 'Create' do
describe 'Merge request creation from fork' do
it 'user forks a project, submits a merge request and maintainer merges it' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
merge_request = Resource::MergeRequestFromFork.fabricate! do |merge_request|
merge_request.fork_branch = 'feature-branch'
......
......@@ -5,8 +5,7 @@ module QA
context 'Create', :quarantine do
describe 'Merge request rebasing' do
it 'user rebases source branch of merge request' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
project = Resource::Project.fabricate! do |project|
project.name = "only-fast-forward"
......
......@@ -4,8 +4,7 @@ module QA
context 'Create' do
describe 'Merge request squashing' do
it 'user squashes commits while merging' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
project = Resource::Project.fabricate! do |project|
project.name = "squash-before-merge"
......
......@@ -16,8 +16,7 @@ module QA
commit_message_of_third_branch = "Add #{file_third_branch}"
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
project = Resource::Project.fabricate! do |proj|
proj.name = 'project-qa-test'
......
......@@ -6,8 +6,7 @@ module QA
let(:key_title) { "key for ssh tests #{Time.now.to_f}" }
it 'user adds and then removes an SSH key', :smoke do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
key = Resource::SSHKey.fabricate! do |resource|
resource.title = key_title
......
......@@ -6,8 +6,7 @@ module QA
context 'Create', :quarantine do
describe 'Push over HTTP using Git protocol version 2', :requires_git_protocol_v2 do
it 'user pushes to the repository' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
# Create a project to push to
project = Resource::Project.fabricate! do |project|
......
......@@ -17,20 +17,15 @@ module QA
end
end
def login
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
end
around do |example|
# Create an SSH key to be used with Git
login
Flow::Login.sign_in
ssh_key
example.run
# Remove the SSH key
login
Flow::Login.sign_in
Page::Main::Menu.perform(&:click_settings_link)
Page::Profile::Menu.perform(&:click_ssh_keys)
Page::Profile::SSHKeys.perform do |ssh_keys|
......
......@@ -4,8 +4,7 @@ module QA
context 'Create' do
describe 'Git push over HTTP', :ldap_no_tls do
it 'user using a personal access token pushes code to the repository' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
access_token = Resource::PersonalAccessToken.fabricate!.access_token
......
......@@ -4,8 +4,7 @@ module QA
context 'Create' do
describe 'Git push over HTTP', :ldap_no_tls do
it 'user pushes code to the repository' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
project_push = Resource::Repository::ProjectPush.fabricate! do |push|
push.file_name = 'README.md'
......
......@@ -9,8 +9,7 @@ module QA
let(:key_title) { "key for ssh tests #{Time.now.to_f}" }
it 'user adds an ssh key and pushes code to the repository' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
key = Resource::SSHKey.fabricate! do |resource|
resource.title = key_title
......
......@@ -4,8 +4,7 @@ module QA
context 'Create', :smoke do
describe 'Snippet creation' do
it 'User creates a snippet' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
Page::Main::Menu.perform(&:go_to_snippets)
......
......@@ -4,8 +4,7 @@ module QA
context 'Create' do
describe 'Wiki management' do
it 'user creates, edits, clones, and pushes to the wiki' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
wiki = Resource::Wiki.fabricate! do |resource|
resource.title = 'Home'
......
......@@ -4,8 +4,7 @@ module QA
context 'Release' do
describe 'Deploy key creation' do
it 'user adds a deploy key' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
key = Runtime::Key::RSA.new
deploy_key_title = 'deploy key title'
......
......@@ -10,8 +10,7 @@ module QA
@job_log_json_flag_enabled = Runtime::Feature.enabled?('job_log_json')
Runtime::Feature.disable('job_log_json') if @job_log_json_flag_enabled
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@runner_name = "qa-runner-#{Time.now.to_i}"
......
......@@ -4,8 +4,7 @@ module QA
context 'Release' do
describe 'Deploy token creation' do
it 'user adds a deploy token' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
deploy_token_name = 'deploy token name'
one_week_from_now = Date.today + 7
......
......@@ -26,8 +26,7 @@ module QA
menu.sign_out if menu.has_personal_area?(wait: 0)
end
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
end
context 'when restricted by another ip address' do
......
......@@ -119,8 +119,7 @@ module QA
def sign_in
unless Page::Main::Menu.perform { |p| p.has_personal_area?(wait: 0) }
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
end
end
end
......
......@@ -37,8 +37,7 @@ module QA
context 'built-in', :requires_admin do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Flow::Login.sign_in_as_admin
@group = Resource::Group.fabricate_via_api!
end
......@@ -68,8 +67,7 @@ module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/61
context 'instance level', :quarantine, :requires_admin do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Flow::Login.sign_in_as_admin
Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_template_settings)
......@@ -111,8 +109,7 @@ module QA
context 'group level' do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
Page::Main::Menu.perform(&:go_to_groups)
Page::Dashboard::Groups.perform { |groups| groups.click_group(Runtime::Namespace.sandbox_name) }
......
......@@ -9,8 +9,7 @@ module QA
let(:annotation) { "This design is great!" }
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
end
it 'user adds a design and annotation' do
......
......@@ -10,8 +10,7 @@ module QA
@project_file_name = 'elasticsearch.rb'
@project_file_content = 'elasticsearch: true'
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
QA::EE::Resource::Settings::Elasticsearch.fabricate_via_browser_ui!
......
......@@ -105,8 +105,7 @@ module QA
end
def login_to_gitlab
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
end
def patch_host_name(host_name, container_name)
......@@ -131,8 +130,7 @@ module QA
def allow_requests_to_local_networks
Page::Main::Menu.perform(&:sign_out_if_signed_in)
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Flow::Login.sign_in_as_admin
Page::Main::Menu.perform(&:go_to_admin_area)
Page::Admin::Menu.perform(&:go_to_network_settings)
......
......@@ -17,8 +17,7 @@ module QA
end
it 'user submits, discards batch comments' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
merge_request.visit!
......
......@@ -19,8 +19,7 @@ module QA
project.add_member(approver, Resource::Members::AccessLevel::DEVELOPER)
project.add_member(non_approver, Resource::Members::AccessLevel::DEVELOPER)
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
project.visit!
end
......
......@@ -18,8 +18,7 @@ module QA
before do
# Add two new users to a project as members
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@user = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
@user2 = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2)
......
......@@ -4,8 +4,7 @@ module QA
context 'Create' do
describe 'File Locking' do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@user_one = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
@user_two = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2)
......
......@@ -6,8 +6,7 @@ module QA
# See https://gitlab.com/gitlab-org/gitlab/issues/13769
describe 'Pull mirror a repository over HTTP', :requires_admin do
it 'configures and syncs a (pull) mirrored repository with password auth' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials)
Flow::Login.sign_in_as_admin
source = Resource::Repository::ProjectPush.fabricate! do |project_push|
project_push.project_name = 'pull-mirror-source-project'
......
......@@ -20,8 +20,7 @@ module QA
end
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
target_project.visit!
end
......
......@@ -161,8 +161,7 @@ module QA
end
def prepare
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@project = Resource::Project.fabricate_via_api! do |project|
project.name = 'push_rules'
......
......@@ -42,8 +42,7 @@ module QA
END
end
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
project.visit!
end
......
......@@ -10,8 +10,7 @@ module QA
let(:package_name) { "#{group_id}/#{artifact_id}".tr('.', '/') }
let(:auth_token) do
unless Page::Main::Menu.perform(&:signed_in?)
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
end
Resource::PersonalAccessToken.fabricate!.access_token
......
......@@ -9,8 +9,7 @@ module QA
let(:package_name) { "@#{registry_scope}/#{project.name}" }
let(:auth_token) do
unless Page::Main::Menu.perform(&:signed_in?)
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
end
Resource::PersonalAccessToken.fabricate!.access_token
......
......@@ -61,8 +61,7 @@ module QA
CI
end
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = upstream_project
......
......@@ -30,8 +30,7 @@ module QA
end
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@project.visit!
......
......@@ -28,8 +28,7 @@ module QA
@job_log_json_flag_enabled = Runtime::Feature.enabled?('job_log_json')
Runtime::Feature.disable('job_log_json') if @job_log_json_flag_enabled
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@project = Resource::Project.fabricate_via_api! do |p|
p.name = Runtime::Env.auto_devops_project_name || 'project-with-secure'
......
......@@ -9,8 +9,7 @@ module QA
describe 'License Compliance settings page' do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@project = Resource::Project.fabricate_via_api! do |project|
project.name = Runtime::Env.auto_devops_project_name || 'project-with-secure'
......@@ -53,8 +52,7 @@ module QA
@job_log_json_flag_enabled = Runtime::Feature.enabled?('job_log_json')
Runtime::Feature.disable('job_log_json') if @job_log_json_flag_enabled
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Flow::Login.sign_in
@project = Resource::Project.fabricate_via_api! do |project|
project.name = Runtime::Env.auto_devops_project_name || 'project-with-secure'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment