Commit dbfeef25 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use QA browser to navigate to pages and handle sessions

[ci skip]
parent 67c572ba
......@@ -38,6 +38,25 @@ module QA
yield if block_given?
end
##
# If you want to use specific page class as an entrypoint
# for Runtime::Browser.session, you need to implement this
# method in a subclass.
#
def self.address
raise NotImplementedError
end
## TODO
# When we navigate through pages, we want to check if we are on a
# valid page everytime we instantiate a new Page object.
#
# See gitlab-org/gitlab-qa#111
#
# def self.pattern
# raise NotImplementedError
# end
end
end
end
......@@ -2,11 +2,7 @@ module QA
module Page
module Main
class Entry < Page::Base
def visit_login_page
wait(time: 500) do
visit("#{Runtime::Scenario.gitlab_address}/users/sign_in")
end
end
# TODO remove this class
end
end
end
......
......@@ -2,6 +2,14 @@ module QA
module Page
module Main
class Login < Page::Base
def self.address
Runtime::Scenario.gitlab_address + '/users/sign_in'
end
def initialize
wait('.application', time: 500)
end
def sign_in_using_credentials
if page.has_content?('Change your password')
fill_in :user_password, with: Runtime::User.password
......
......@@ -2,8 +2,8 @@ module QA
module Page
module Mattermost
class Login < Page::Base
def initialize
visit(Runtime::Scenario.mattermost_address + '/login')
def self.address
Runtime::Scenario.mattermost_address + '/login'
end
def sign_in_using_oauth
......
......@@ -8,14 +8,18 @@ module QA
module Browser
extend self
def session(address, &block)
def visit(entry, &block)
address = entry.is_a?(String) ? entry : entry.address
configure!
page.visit(address)
block.call(page)
if block_given?
block.call(page)
page.visit(address)
reset_domain_session!
page.visit(address)
reset_domain_session!
end
rescue
# RSpec examples will take care of screenshots on their own
#
......@@ -26,6 +30,10 @@ module QA
raise
end
##
# Current session, when Capybara::DSL is included `page` method is
# mixed in as well.
#
def page
Capybara.current_session
end
......
module QA
feature 'standard user login', :core do
scenario 'user logs in using credentials' do
Page::Main::Entry.act { visit_login_page }
Runtime::Browser.visit(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
Page::Main::Entry.act { visit_login_page }
Runtime::Browser.visit(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.session(Page::Gitlab::Login) do
Runtime::Browser.visit(Page::Gitlab::Login) do
Page::Main::Login.act { sign_in_using_credentials }
Runtime::Browser.session(Page::Mattermost::Login) do
Runtime::Browser.visit(Page::Mattermost::Login) do
Page::Mattermost::Login.act { sign_in_using_oauth }
Page::Mattermost::Main.perform do |page|
......
module QA
feature 'create a new project', :core do
scenario 'user creates a new project' do
Page::Main::Entry.act { visit_login_page }
Runtime::Browser.visit(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
Page::Main::Entry.act { visit_login_page }
Runtime::Browser.visit(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
Page::Main::Entry.act { visit_login_page }
Runtime::Browser.visit(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