Commit 8a153abd authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-ml-validate-after-visit-in-block' into 'master'

[CE] Validate page after visit in block

See merge request gitlab-org/gitlab-ce!29524
parents 7c27155c 7886f44d
- form_field_classes = local_assigns[:admin_view] || !Feature.enabled?(:project_list_filter_bar) ? 'input-short js-projects-list-filter' : '' - form_field_classes = local_assigns[:admin_view] || !Feature.enabled?(:project_list_filter_bar) ? 'input-short js-projects-list-filter' : ''
- placeholder = local_assigns[:search_form_placeholder] ? search_form_placeholder : 'Filter by name...' - placeholder = local_assigns[:search_form_placeholder] ? search_form_placeholder : 'Filter by name...'
= form_tag filter_projects_path, method: :get, class: 'project-filter-form', id: 'project-filter-form' do |f| = form_tag filter_projects_path, method: :get, class: 'project-filter-form qa-project-filter-form', id: 'project-filter-form' do |f|
= search_field_tag :name, params[:name], = search_field_tag :name, params[:name],
placeholder: placeholder, placeholder: placeholder,
class: "project-filter-form-field form-control #{form_field_classes}", class: "project-filter-form-field form-control #{form_field_classes}",
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
module Dashboard module Dashboard
class Projects < Page::Base class Projects < Page::Base
view 'app/views/shared/projects/_search_form.html.haml' do view 'app/views/shared/projects/_search_form.html.haml' do
element :form_filter_by_name, /form_tag.+id: 'project-filter-form'/ # rubocop:disable QA/ElementWithPattern element :project_filter_form, required: true
end end
def go_to_project(name) def go_to_project(name)
...@@ -14,10 +14,14 @@ module QA ...@@ -14,10 +14,14 @@ module QA
find_link(text: name).click find_link(text: name).click
end end
def self.path
'/'
end
private private
def filter_by_name(name) def filter_by_name(name)
page.within('form#project-filter-form') do within_element(:project_filter_form) do
fill_in :name, with: name fill_in :name, with: name
end end
end end
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
class Address class Address
attr_reader :address attr_reader :address
def initialize(instance, page = nil) def initialize(instance, page)
@instance = instance @instance = instance
@address = host + (page.is_a?(String) ? page : page&.path) @address = host + (page.is_a?(String) ? page : page&.path)
end end
......
# frozen_string_literal: true # frozen_string_literal: true
require 'rspec/core' require 'rspec/core'
require 'rspec/expectations'
require 'capybara/rspec' require 'capybara/rspec'
require 'capybara-screenshot/rspec' require 'capybara-screenshot/rspec'
require 'selenium-webdriver' require 'selenium-webdriver'
...@@ -27,13 +28,12 @@ module QA ...@@ -27,13 +28,12 @@ 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 = nil, &block) def visit(address, page_class, &block)
Browser::Session.new(address, page).perform(&block) Browser::Session.new(address, page_class).perform(&block)
end end
def self.visit(address, page = nil, &block) def self.visit(address, page_class, &block)
new.visit(address, page, &block) new.visit(address, page_class, &block)
page.validate_elements_present!
end end
def self.configure! def self.configure!
...@@ -128,8 +128,11 @@ module QA ...@@ -128,8 +128,11 @@ module QA
class Session class Session
include Capybara::DSL include Capybara::DSL
def initialize(instance, page = nil) attr_reader :page_class
@session_address = Runtime::Address.new(instance, page)
def initialize(instance, page_class)
@session_address = Runtime::Address.new(instance, page_class)
@page_class = page_class
end end
def url def url
...@@ -139,6 +142,8 @@ module QA ...@@ -139,6 +142,8 @@ module QA
def perform(&block) def perform(&block)
visit(url) visit(url)
page_class.validate_elements_present!
if QA::Runtime::Env.qa_cookies if QA::Runtime::Env.qa_cookies
browser = Capybara.current_session.driver.browser browser = Capybara.current_session.driver.browser
QA::Runtime::Env.qa_cookies.each do |cookie| QA::Runtime::Env.qa_cookies.each do |cookie|
......
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