Commit aa1d8bde authored by Mark Lapierre's avatar Mark Lapierre

Fix wait for project replication

Wait for the repository to finish replication after visiting the
project page.

Some code cleanup too.
parent 16a58239
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
module Show module Show
def wait_for_repository_replication(max_wait: Runtime::Geo.max_file_replication_time) def wait_for_repository_replication(max_wait: Runtime::Geo.max_file_replication_time)
wait_until_geo_max_replication_time(max_wait: max_wait) do wait_until_geo_max_replication_time(max_wait: max_wait) do
!page.has_text?(/No repository|The repository for this project is empty/) has_no_text?(/No repository|The repository for this project is empty/)
end end
end end
......
...@@ -112,6 +112,10 @@ module QA ...@@ -112,6 +112,10 @@ module QA
has_css?(element_selector_css(name)) has_css?(element_selector_css(name))
end end
def has_no_text?(text)
page.has_no_text? text
end
def within_element(name) def within_element(name)
page.within(element_selector_css(name)) do page.within(element_selector_css(name)) do
yield yield
......
...@@ -12,7 +12,7 @@ module QA ...@@ -12,7 +12,7 @@ module QA
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
Page::Main::Login.act { sign_in_using_credentials } 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|
...@@ -40,7 +40,7 @@ module QA ...@@ -40,7 +40,7 @@ module QA
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
Page::Main::Menu.perform { |menu| menu.go_to_projects } Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) dashboard.wait_for_project_replication(project.name)
...@@ -48,7 +48,10 @@ module QA ...@@ -48,7 +48,10 @@ module QA
end end
# Grab the HTTP URI for the secondary and store as 'location' # Grab the HTTP URI for the secondary and store as 'location'
location = Page::Project::Show.act { repository_clone_http_location } location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_http_location
end
# Perform a git push over HTTP at the secondary # Perform a git push over HTTP at the secondary
push = Resource::Repository::Push.fabricate! do |push| push = Resource::Repository::Push.fabricate! do |push|
...@@ -88,7 +91,7 @@ module QA ...@@ -88,7 +91,7 @@ module QA
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
Page::Main::Login.act { sign_in_using_credentials } 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|
...@@ -116,7 +119,7 @@ module QA ...@@ -116,7 +119,7 @@ module QA
expect(banner).to have_secondary_read_only_banner expect(banner).to have_secondary_read_only_banner
end end
Page::Main::Menu.perform { |menu| menu.go_to_projects } Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) dashboard.wait_for_project_replication(project.name)
...@@ -124,7 +127,10 @@ module QA ...@@ -124,7 +127,10 @@ module QA
end end
# Grab the HTTP URI for the secondary and store as 'location' # Grab the HTTP URI for the secondary and store as 'location'
location = Page::Project::Show.act { repository_clone_http_location } location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_http_location
end
# Perform a git push over HTTP at the secondary # Perform a git push over HTTP at the secondary
push = Resource::Repository::Push.fabricate! do |push| push = Resource::Repository::Push.fabricate! do |push|
......
...@@ -14,7 +14,7 @@ module QA ...@@ -14,7 +14,7 @@ module QA
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
Page::Main::Login.act { sign_in_using_credentials } 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|
...@@ -49,7 +49,7 @@ module QA ...@@ -49,7 +49,7 @@ module QA
end end
# Ensure the SSH key has replicated # Ensure the SSH key has replicated
Page::Main::Menu.act { go_to_profile_settings } Page::Main::Menu.perform(&:go_to_profile_settings)
Page::Profile::Menu.perform do |menu| Page::Profile::Menu.perform do |menu|
menu.click_ssh_keys menu.click_ssh_keys
menu.wait_for_key_to_replicate(key_title) menu.wait_for_key_to_replicate(key_title)
...@@ -59,14 +59,17 @@ module QA ...@@ -59,14 +59,17 @@ module QA
expect(page).to have_content(key.fingerprint) expect(page).to have_content(key.fingerprint)
# Ensure project has replicated # Ensure project has replicated
Page::Main::Menu.perform { |menu| menu.go_to_projects } Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name) dashboard.go_to_project(project.name)
end end
# Grab the SSH URI for the secondary and store as 'location' # Grab the SSH URI for the secondary and store as 'location'
location = Page::Project::Show.act { repository_clone_ssh_location } location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_ssh_location
end
# Perform a git push over SSH at the secondary # Perform a git push over SSH at the secondary
push = Resource::Repository::Push.fabricate! do |push| push = Resource::Repository::Push.fabricate! do |push|
...@@ -103,7 +106,7 @@ module QA ...@@ -103,7 +106,7 @@ module QA
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
Page::Main::Login.act { sign_in_using_credentials } 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|
...@@ -138,7 +141,7 @@ module QA ...@@ -138,7 +141,7 @@ module QA
end end
# Ensure the SSH key has replicated # Ensure the SSH key has replicated
Page::Main::Menu.act { go_to_profile_settings } Page::Main::Menu.perform(&:go_to_profile_settings)
Page::Profile::Menu.perform do |menu| Page::Profile::Menu.perform do |menu|
menu.click_ssh_keys menu.click_ssh_keys
menu.wait_for_key_to_replicate(key_title) menu.wait_for_key_to_replicate(key_title)
...@@ -148,14 +151,17 @@ module QA ...@@ -148,14 +151,17 @@ module QA
expect(page).to have_content(key.fingerprint) expect(page).to have_content(key.fingerprint)
# Ensure project has replicated # Ensure project has replicated
Page::Main::Menu.perform { |menu| menu.go_to_projects } Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project.name) dashboard.wait_for_project_replication(project.name)
dashboard.go_to_project(project.name) dashboard.go_to_project(project.name)
end end
# Grab the SSH URI for the secondary and store as 'location' # Grab the SSH URI for the secondary and store as 'location'
location = Page::Project::Show.act { repository_clone_ssh_location } location = Page::Project::Show.perform do |project_page|
project_page.wait_for_repository_replication
project_page.repository_clone_ssh_location
end
# Perform a git push over SSH at the secondary # Perform a git push over SSH at the secondary
push = Resource::Repository::Push.fabricate! do |push| push = Resource::Repository::Push.fabricate! do |push|
......
...@@ -85,6 +85,14 @@ module QA ...@@ -85,6 +85,14 @@ module QA
found found
end end
def has_no_text?(text)
found = super
log(%Q{has_no_text?('#{text}') returned #{found}})
found
end
def within_element(name) def within_element(name)
log("within element :#{name}") log("within element :#{name}")
......
...@@ -65,6 +65,13 @@ describe QA::Support::Page::Logging do ...@@ -65,6 +65,13 @@ describe QA::Support::Page::Logging do
.to output(/has_element\? :element returned true/).to_stdout_from_any_process .to output(/has_element\? :element returned true/).to_stdout_from_any_process
end end
it 'logs has_no_text?' do
allow(page).to receive(:has_no_text?).with('foo').and_return(true)
expect { subject.has_no_text? 'foo' }
.to output(/has_no_text\?\('foo'\) returned true/).to_stdout_from_any_process
end
it 'logs within_element' do it 'logs within_element' do
expect { subject.within_element(:element) } expect { subject.within_element(:element) }
.to output(/within element :element/).to_stdout_from_any_process .to output(/within element :element/).to_stdout_from_any_process
......
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