Commit 6bebe4db authored by Jennifer Louie's avatar Jennifer Louie Committed by Mark Lapierre

Use Flow::Login in Geo E2E tests

Update existing end-to-end Geo tests to use
the Flow::Login module methods when starting
browser sessions on either the primary or secondary node.
parent 2fa6929f
...@@ -5,33 +5,33 @@ module QA ...@@ -5,33 +5,33 @@ module QA
module Login module Login
module_function module_function
def while_signed_in(as: nil) def while_signed_in(as: nil, address: :gitlab)
Page::Main::Menu.perform(&:sign_out_if_signed_in) Page::Main::Menu.perform(&:sign_out_if_signed_in)
sign_in(as: as) sign_in(as: as, address: address)
yield yield
Page::Main::Menu.perform(&:sign_out) Page::Main::Menu.perform(&:sign_out)
end end
def while_signed_in_as_admin def while_signed_in_as_admin(address: :gitlab)
while_signed_in(as: Runtime::User.admin) do while_signed_in(as: Runtime::User.admin, address: address) do
yield yield
end end
end end
def sign_in(as: nil) def sign_in(as: nil, address: :gitlab)
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(address, Page::Main::Login)
Page::Main::Login.perform { |login| login.sign_in_using_credentials(user: as) } Page::Main::Login.perform { |login| login.sign_in_using_credentials(user: as) }
end end
def sign_in_as_admin def sign_in_as_admin(address: :gitlab)
sign_in(as: Runtime::User.admin) sign_in(as: Runtime::User.admin, address: address)
end end
def sign_in_unless_signed_in(as: nil) def sign_in_unless_signed_in(as: nil, address: :gitlab)
sign_in(as: as) unless Page::Main::Menu.perform(&:signed_in?) sign_in(as: as, address: address) unless Page::Main::Menu.perform(&:signed_in?)
end end
end end
end end
......
...@@ -6,9 +6,7 @@ module QA ...@@ -6,9 +6,7 @@ module QA
let(:file_to_attach) { File.absolute_path(File.join('spec', 'fixtures', 'banana_sample.gif')) } let(:file_to_attach) { File.absolute_path(File.join('spec', 'fixtures', 'banana_sample.gif')) }
it 'user uploads attachment to the primary node' do it 'user uploads attachment to the primary node' do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
@project = Resource::Project.fabricate! do |project| @project = Resource::Project.fabricate! do |project|
project.name = 'project-for-issues' project.name = 'project-for-issues'
project.description = 'project for adding issues' project.description = 'project for adding issues'
...@@ -26,9 +24,7 @@ module QA ...@@ -26,9 +24,7 @@ module QA
end end
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do |session| QA::Flow::Login.while_signed_in(address: :geo_secondary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -24,29 +24,28 @@ module QA ...@@ -24,29 +24,28 @@ module QA
end end
it 'replicates deletion of a project to secondary node' do it 'replicates deletion of a project to secondary node' do
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) QA::Flow::Login.while_signed_in(address: :geo_secondary) do
Page::Main::Login.perform(&:sign_in_using_credentials) EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
EE::Page::Main::Banner.perform do |banner| # Confirm replication of project to secondary node
expect(banner).to have_secondary_read_only_banner Page::Main::Menu.perform(&:go_to_projects)
end
# Confirm replication of project to secondary node
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
expect(dashboard.project_created?(deleted_project_name)).to be_truthy expect(dashboard.project_created?(deleted_project_name)).to be_truthy
end end
Page::Dashboard::Projects.perform(&:clear_project_filter) Page::Dashboard::Projects.perform(&:clear_project_filter)
# Delete project from primary node via API # Delete project from primary node via API
delete_response = delete_project_on_primary(deleted_project_id) delete_response = delete_project_on_primary(deleted_project_id)
expect(delete_response).to have_content('202 Accepted') expect(delete_response).to have_content('202 Accepted')
# Confirm deletion is replicated to secondary node # Confirm deletion is replicated to secondary node
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
expect(dashboard.project_deleted?(deleted_project_name)).to be_truthy expect(dashboard.project_deleted?(deleted_project_name)).to be_truthy
end
end end
end end
......
...@@ -10,10 +10,7 @@ module QA ...@@ -10,10 +10,7 @@ module QA
file_content = 'This is a Geo project! Commit from primary.' file_content = 'This is a Geo project! Commit from primary.'
project = nil project = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new Project # Create a new Project
project = Resource::Project.fabricate! do |project| project = Resource::Project.fabricate! do |project|
project.name = 'geo-project' project.name = 'geo-project'
...@@ -37,10 +34,7 @@ module QA ...@@ -37,10 +34,7 @@ module QA
end end
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -13,10 +13,7 @@ module QA ...@@ -13,10 +13,7 @@ module QA
file_name = 'README.md' file_name = 'README.md'
project = nil project = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new Project # Create a new Project
project = Resource::Project.fabricate! do |project| project = Resource::Project.fabricate! do |project|
project.name = 'geo-project' project.name = 'geo-project'
...@@ -36,10 +33,7 @@ module QA ...@@ -36,10 +33,7 @@ module QA
project.visit! project.visit!
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
...@@ -98,10 +92,7 @@ module QA ...@@ -98,10 +92,7 @@ module QA
file_name_secondary = 'README_MORE.md' file_name_secondary = 'README_MORE.md'
project = nil project = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new Project # Create a new Project
project = Resource::Project.fabricate! do |project| project = Resource::Project.fabricate! do |project|
project.name = 'geo-project' project.name = 'geo-project'
...@@ -121,10 +112,7 @@ module QA ...@@ -121,10 +112,7 @@ module QA
end end
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -5,9 +5,7 @@ module QA ...@@ -5,9 +5,7 @@ module QA
describe 'GitLab Geo project rename replication' do describe 'GitLab Geo project rename replication' do
it 'user renames project' do it 'user renames project' do
# create the project and push code # create the project and push code
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
project = Resource::Project.fabricate! do |project| project = Resource::Project.fabricate! do |project|
project.name = 'geo-before-rename' project.name = 'geo-before-rename'
project.description = 'Geo project to be renamed' project.description = 'Geo project to be renamed'
...@@ -44,9 +42,7 @@ module QA ...@@ -44,9 +42,7 @@ module QA
end end
# check renamed project exist on secondary node # check renamed project exist on secondary node
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -12,10 +12,7 @@ module QA ...@@ -12,10 +12,7 @@ module QA
project = nil project = nil
key = nil key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new SSH key for the user # Create a new SSH key for the user
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate! do |resource|
resource.title = key_title resource.title = key_title
...@@ -45,10 +42,7 @@ module QA ...@@ -45,10 +42,7 @@ module QA
end end
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
...@@ -85,10 +79,7 @@ module QA ...@@ -85,10 +79,7 @@ module QA
project = nil project = nil
key = nil key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new SSH key for the user # Create a new SSH key for the user
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate! do |resource|
resource.title = key_title resource.title = key_title
...@@ -122,10 +113,7 @@ module QA ...@@ -122,10 +113,7 @@ module QA
end end
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -13,10 +13,7 @@ module QA ...@@ -13,10 +13,7 @@ module QA
project = nil project = nil
key = nil key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new SSH key for the user # Create a new SSH key for the user
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate! do |resource|
resource.title = key_title resource.title = key_title
...@@ -42,10 +39,7 @@ module QA ...@@ -42,10 +39,7 @@ module QA
project.visit! project.visit!
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
...@@ -107,10 +101,7 @@ module QA ...@@ -107,10 +101,7 @@ module QA
project = nil project = nil
key = nil key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new SSH key for the user # Create a new SSH key for the user
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate! do |resource|
resource.title = key_title resource.title = key_title
...@@ -136,10 +127,7 @@ module QA ...@@ -136,10 +127,7 @@ module QA
end end
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -11,9 +11,7 @@ module QA ...@@ -11,9 +11,7 @@ module QA
project_name = "geo-wiki-project-#{SecureRandom.hex(8)}" project_name = "geo-wiki-project-#{SecureRandom.hex(8)}"
# Create new wiki and push wiki commit # Create new wiki and push wiki commit
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
project = Resource::Project.fabricate! do |project| project = Resource::Project.fabricate! do |project|
project.name = project_name project.name = project_name
project.description = 'Geo project for wiki repo test' project.description = 'Geo project for wiki repo test'
...@@ -40,9 +38,7 @@ module QA ...@@ -40,9 +38,7 @@ module QA
end end
# Validate that wiki is synced on secondary node # Validate that wiki is synced on secondary node
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -13,10 +13,7 @@ module QA ...@@ -13,10 +13,7 @@ module QA
wiki = nil wiki = nil
before do before do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new project and wiki # Create a new project and wiki
project = Resource::Project.fabricate_via_api! do |project| project = Resource::Project.fabricate_via_api! do |project|
project.name = project_name project.name = project_name
...@@ -45,9 +42,7 @@ module QA ...@@ -45,9 +42,7 @@ module QA
end end
it 'is redirected to the primary and ultimately replicated to the secondary' do it 'is redirected to the primary and ultimately replicated to the secondary' do
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -13,9 +13,7 @@ module QA ...@@ -13,9 +13,7 @@ module QA
project = nil project = nil
key = nil key = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new SSH key # Create a new SSH key
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate! do |resource|
resource.title = key_title resource.title = key_title
...@@ -49,9 +47,7 @@ module QA ...@@ -49,9 +47,7 @@ module QA
validate_content(push_content) validate_content(push_content)
end end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
...@@ -12,9 +12,7 @@ module QA ...@@ -12,9 +12,7 @@ module QA
key = nil key = nil
before do before do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_primary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new SSH key # Create a new SSH key
key = Resource::SSHKey.fabricate! do |resource| key = Resource::SSHKey.fabricate! do |resource|
resource.title = key_title resource.title = key_title
...@@ -38,9 +36,7 @@ module QA ...@@ -38,9 +36,7 @@ module QA
end end
it 'proxies wiki commit to primary node and ultmately replicates to secondary node' do it 'proxies wiki commit to primary node and ultmately replicates to secondary node' do
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do QA::Flow::Login.while_signed_in(address: :geo_secondary) do
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner| EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
......
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