Commit b80dc884 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Decouple subject's address from page objects in QA

parent 86aa7ac1
......@@ -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
......@@ -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
......
......@@ -10,8 +10,8 @@ module QA
end
end
def self.address
Runtime::Scenario.gitlab_address + '/login'
def self.path
'/login'
end
end
end
......
......@@ -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)
......
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
......
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 }
......
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
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|
......
......@@ -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|
......
......@@ -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|
......
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