Commit 7f1ecd2e authored by Gabriel Mazetto's avatar Gabriel Mazetto

Fix Runtime::Browser.visit to allow omitting `page`

parent bdefb879
module QA
module Page
module Main
class Home < Page::Base
def self.path
'/'
end
end
end
end
end
...@@ -23,18 +23,14 @@ module QA ...@@ -23,18 +23,14 @@ module QA
# In case of an address that is a symbol we will try to guess address # In case of an address that is a symbol we will try to guess address
# based on `Runtime::Scenario#something_address`. # based on `Runtime::Scenario#something_address`.
# #
def visit(address, page, &block) def visit(address, page = nil, &block)
Browser::Session.new(address, page).perform(&block) Browser::Session.new(address, page).perform(&block)
end end
def self.visit(address, page, &block) def self.visit(address, page = nil, &block)
new.visit(address, page, &block) new.visit(address, page, &block)
end end
def self.url_for(instance, page)
Runtime::Scenario.send("#{instance}_address") + page&.path
end
def self.configure! def self.configure!
return if Capybara.drivers.include?(:chrome) return if Capybara.drivers.include?(:chrome)
......
...@@ -21,66 +21,67 @@ module QA ...@@ -21,66 +21,67 @@ module QA
end end
# check it exists on the other machine # check it exists on the other machine
visit(Runtime::Browser.url_for(:geo_secondary, QA::Page::Main::Login)) Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
Page::Main::OAuth.act do Page::Main::OAuth.act do
authorize! if needs_authorization? authorize! if needs_authorization?
end end
expect(page).to have_content 'You are on a secondary (read-only) Geo node' expect(page).to have_content 'You are on a secondary (read-only) Geo node'
Page::Menu::Main.perform do |menu| Page::Menu::Main.perform do |menu|
menu.go_to_projects menu.go_to_projects
expect(page).to have_content(geo_project_name) expect(page).to have_content(geo_project_name)
end end
sleep 10 # wait for repository replication sleep 10 # wait for repository replication
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.go_to_project(geo_project_name) dashboard.go_to_project(geo_project_name)
end end
Page::Project::Show.perform do Page::Project::Show.perform do
expect(page).to have_content 'README.md' expect(page).to have_content 'README.md'
expect(page).to have_content 'This is Geo project!' expect(page).to have_content 'This is Geo project!'
end end
# rename the project # rename the project
visit(Runtime::Browser.url_for(:geo_primary, QA::Page::Main::Home)) Runtime::Browser.visit(:geo_primary)
Page::Menu::Main.act { go_to_projects } Page::Menu::Main.act { go_to_projects }
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.go_to_project(geo_project_name) dashboard.go_to_project(geo_project_name)
end end
Page::Menu::Side.act { go_to_settings } Page::Menu::Side.act { go_to_settings }
geo_project_newname = "geo-after-rename-#{SecureRandom.hex(8)}" geo_project_newname = "geo-after-rename-#{SecureRandom.hex(8)}"
Page::Project::Settings::Main.perform do |page| Page::Project::Settings::Main.perform do |page|
page.expand_advanced_settings page.expand_advanced_settings
page.rename_to(geo_project_newname) page.rename_to(geo_project_newname)
end end
sleep 2 # wait for replication sleep 2 # wait for replication
# check renamed project exist on secondary node # check renamed project exist on secondary node
visit(Runtime::Browser.url_for(:geo_secondary, QA::Page::Main::Home)) Runtime::Browser.visit(:geo_secondary)
expect(page).to have_content 'You are on a secondary (read-only) Geo node' expect(page).to have_content 'You are on a secondary (read-only) Geo node'
Page::Menu::Main.perform do |menu| Page::Menu::Main.perform do |menu|
menu.go_to_projects menu.go_to_projects
expect(page).to have_content(geo_project_newname) expect(page).to have_content(geo_project_newname)
end end
Page::Dashboard::Projects.perform do |dashboard| Page::Dashboard::Projects.perform do |dashboard|
dashboard.go_to_project(geo_project_newname) dashboard.go_to_project(geo_project_newname)
end end
Page::Project::Show.perform do Page::Project::Show.perform do
expect(page).to have_content 'README.md' expect(page).to have_content 'README.md'
expect(page).to have_content 'This is Geo project!' expect(page).to have_content 'This is Geo project!'
end
end end
end end
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