diff options
Diffstat (limited to 'qa/qa')
-rw-r--r-- | qa/qa/page/base.rb | 8 | ||||
-rw-r--r-- | qa/qa/page/main/login.rb | 4 | ||||
-rw-r--r-- | qa/qa/page/mattermost/login.rb | 4 | ||||
-rw-r--r-- | qa/qa/runtime/browser.rb | 32 | ||||
-rw-r--r-- | qa/qa/specs/features/login/standard_spec.rb | 2 | ||||
-rw-r--r-- | qa/qa/specs/features/mattermost/group_create_spec.rb | 2 | ||||
-rw-r--r-- | qa/qa/specs/features/mattermost/login_spec.rb | 15 | ||||
-rw-r--r-- | qa/qa/specs/features/project/create_spec.rb | 2 | ||||
-rw-r--r-- | qa/qa/specs/features/repository/clone_spec.rb | 2 | ||||
-rw-r--r-- | qa/qa/specs/features/repository/push_spec.rb | 2 |
10 files changed, 40 insertions, 33 deletions
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index 1d4a5c54969..4e1a55337c9 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -22,10 +22,6 @@ module QA yield if block_given? end - def self.address - raise NotImplementedError - end - def scroll_to(selector, text: nil) page.execute_script <<~JS var elements = Array.from(document.querySelectorAll('#{selector}')); @@ -40,6 +36,10 @@ module QA page.within(selector) { yield } if block_given? end + + def self.path + raise NotImplementedError + end end end end diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb index 4c38f81bce7..f88325f408b 100644 --- a/qa/qa/page/main/login.rb +++ b/qa/qa/page/main/login.rb @@ -18,8 +18,8 @@ module QA click_button 'Sign in' end - def self.address - Runtime::Scenario.gitlab_address + '/users/sign_in' + def self.path + '/users/sign_in' end end end diff --git a/qa/qa/page/mattermost/login.rb b/qa/qa/page/mattermost/login.rb index 9eb43fdc1b2..8ffd4fdad13 100644 --- a/qa/qa/page/mattermost/login.rb +++ b/qa/qa/page/mattermost/login.rb @@ -10,8 +10,8 @@ module QA end end - def self.address - Runtime::Scenario.gitlab_address + '/login' + def self.path + '/login' end end end diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index 16fa3a1bd23..e05dd9612df 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -12,14 +12,25 @@ module QA self.class.configure! end - def visit(page, &block) - Browser::Session.new(page).tap do |session| + ## + # Visit a page that belongs to a GitLab instance under given address. + # + # Example: + # + # visit(:gitlab, Page::Main::Login) + # visit('http://gitlab.example/users/sign_in') + # + # In case of an address that is a symbol we will try to guess address + # based on `Runtime::Scenario#something_address`. + # + def visit(address, page, &block) + Browser::Session.new(address, page).tap do |session| session.perform(&block) end end - def self.visit(page, &block) - new.visit(page, &block) + def self.visit(address, page, &block) + new.visit(address, page, &block) end def self.configure! @@ -52,10 +63,17 @@ module QA class Session include Capybara::DSL - attr_reader :address + def initialize(instance, page = nil) + @instance = instance + @address = host + page&.path + end - def initialize(page) - @address = page.is_a?(String) ? page : page.address + def host + if @instance.is_a?(Symbol) + Runtime::Scenario.send("#{@instance}_address") + else + @instance.to_s + end end def perform(&block) diff --git a/qa/qa/specs/features/login/standard_spec.rb b/qa/qa/specs/features/login/standard_spec.rb index 7a501d3f873..9eaa2b772e6 100644 --- a/qa/qa/specs/features/login/standard_spec.rb +++ b/qa/qa/specs/features/login/standard_spec.rb @@ -1,7 +1,7 @@ module QA feature 'standard user login', :core do scenario 'user logs in using credentials' do - Runtime::Browser.visit(Page::Main::Login) + Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } # TODO, since `Signed in successfully` message was removed diff --git a/qa/qa/specs/features/mattermost/group_create_spec.rb b/qa/qa/specs/features/mattermost/group_create_spec.rb index 5156481c8e5..b3dbe44bf6e 100644 --- a/qa/qa/specs/features/mattermost/group_create_spec.rb +++ b/qa/qa/specs/features/mattermost/group_create_spec.rb @@ -1,7 +1,7 @@ module QA feature 'create a new group', :mattermost do scenario 'creating a group with a mattermost team' do - Runtime::Browser.visit(Page::Main::Login) + Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } Page::Main::Menu.act { go_to_groups } diff --git a/qa/qa/specs/features/mattermost/login_spec.rb b/qa/qa/specs/features/mattermost/login_spec.rb index 4b3987efcb3..637bbdd643a 100644 --- a/qa/qa/specs/features/mattermost/login_spec.rb +++ b/qa/qa/specs/features/mattermost/login_spec.rb @@ -1,10 +1,10 @@ module QA feature 'logging in to Mattermost', :mattermost do scenario 'can use gitlab oauth' do - Runtime::Browser.visit(Page::Main::Login) do + Runtime::Browser.visit(:gitlab, Page::Main::Login) do Page::Main::Login.act { sign_in_using_credentials } - Runtime::Browser.visit(Page::Mattermost::Login) do + Runtime::Browser.visit(:mattermost, Page::Mattermost::Login) do Page::Mattermost::Login.act { sign_in_using_oauth } Page::Mattermost::Main.perform do |page| @@ -13,16 +13,5 @@ module QA end end end - - ## - # TODO, temporary workaround for gitlab-org/gitlab-qa#102. - # - after do - visit Runtime::Scenario.mattermost_address - reset_session! - - visit Runtime::Scenario.gitlab_address - reset_session! - end end end diff --git a/qa/qa/specs/features/project/create_spec.rb b/qa/qa/specs/features/project/create_spec.rb index 46c805d8b25..0b3accb848d 100644 --- a/qa/qa/specs/features/project/create_spec.rb +++ b/qa/qa/specs/features/project/create_spec.rb @@ -1,7 +1,7 @@ module QA feature 'create a new project', :core do scenario 'user creates a new project' do - Runtime::Browser.visit(Page::Main::Login) + Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } Scenario::Gitlab::Project::Create.perform do |project| diff --git a/qa/qa/specs/features/repository/clone_spec.rb b/qa/qa/specs/features/repository/clone_spec.rb index 18972c918a6..c5c24622657 100644 --- a/qa/qa/specs/features/repository/clone_spec.rb +++ b/qa/qa/specs/features/repository/clone_spec.rb @@ -9,7 +9,7 @@ module QA end before do - Runtime::Browser.visit(Page::Main::Login) + Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } Scenario::Gitlab::Project::Create.perform do |scenario| diff --git a/qa/qa/specs/features/repository/push_spec.rb b/qa/qa/specs/features/repository/push_spec.rb index 9ef532fd4a5..3da6fad6f17 100644 --- a/qa/qa/specs/features/repository/push_spec.rb +++ b/qa/qa/specs/features/repository/push_spec.rb @@ -2,7 +2,7 @@ module QA feature 'push code to repository', :core do context 'with regular account over http' do scenario 'user pushes code to the repository' do - Runtime::Browser.visit(Page::Main::Login) + Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } Scenario::Gitlab::Project::Create.perform do |scenario| |