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