Commit b3cd6fd5 authored by Walmyr Lima e Silva Filho's avatar Walmyr Lima e Silva Filho

Merge branch 'ml-qa-update-capybara' into 'master'

Update Capybara to the latest version

See merge request gitlab-org/gitlab!18927
parents 7572b7e0 bdd5ca28
...@@ -2,8 +2,8 @@ source 'https://rubygems.org' ...@@ -2,8 +2,8 @@ source 'https://rubygems.org'
gem 'gitlab-qa' gem 'gitlab-qa'
gem 'activesupport', '5.2.3' # This should stay in sync with the root's Gemfile gem 'activesupport', '5.2.3' # This should stay in sync with the root's Gemfile
gem 'capybara', '~> 2.16.1' gem 'capybara', '~> 3.29.0'
gem 'capybara-screenshot', '~> 1.0.18' gem 'capybara-screenshot', '~> 1.0.23'
gem 'rake', '~> 12.3.0' gem 'rake', '~> 12.3.0'
gem 'rspec', '~> 3.7' gem 'rspec', '~> 3.7'
gem 'selenium-webdriver', '~> 3.12' gem 'selenium-webdriver', '~> 3.12'
......
...@@ -6,8 +6,8 @@ GEM ...@@ -6,8 +6,8 @@ GEM
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.2) addressable (2.7.0)
public_suffix (>= 2.0.2, < 4.0) public_suffix (>= 2.0.2, < 5.0)
airborne (0.2.13) airborne (0.2.13)
activesupport activesupport
rack rack
...@@ -15,15 +15,16 @@ GEM ...@@ -15,15 +15,16 @@ GEM
rest-client (>= 1.7.3, < 3.0) rest-client (>= 1.7.3, < 3.0)
rspec (~> 3.1) rspec (~> 3.1)
byebug (9.1.0) byebug (9.1.0)
capybara (2.16.1) capybara (3.29.0)
addressable addressable
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3) nokogiri (~> 1.8)
rack (>= 1.0.0) rack (>= 1.6.0)
rack-test (>= 0.5.4) rack-test (>= 0.6.3)
xpath (~> 2.0) regexp_parser (~> 1.5)
capybara-screenshot (1.0.18) xpath (~> 3.2)
capybara (>= 1.0, < 3) capybara-screenshot (1.0.23)
capybara (>= 1.0, < 4)
launchy launchy
childprocess (3.0.0) childprocess (3.0.0)
coderay (1.1.2) coderay (1.1.2)
...@@ -50,7 +51,7 @@ GEM ...@@ -50,7 +51,7 @@ GEM
mime-types (3.1) mime-types (3.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521) mime-types-data (3.2016.0521)
mini_mime (1.0.0) mini_mime (1.0.2)
mini_portile2 (2.4.0) mini_portile2 (2.4.0)
minitest (5.11.3) minitest (5.11.3)
netrc (0.11.0) netrc (0.11.0)
...@@ -65,11 +66,12 @@ GEM ...@@ -65,11 +66,12 @@ GEM
pry-byebug (3.5.1) pry-byebug (3.5.1)
byebug (~> 9.1) byebug (~> 9.1)
pry (~> 0.10) pry (~> 0.10)
public_suffix (3.0.1) public_suffix (4.0.1)
rack (2.0.6) rack (2.0.7)
rack-test (0.8.2) rack-test (0.8.3)
rack (>= 1.0, < 3) rack (>= 1.0, < 3)
rake (12.3.3) rake (12.3.0)
regexp_parser (1.6.0)
rest-client (2.0.2) rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0) mime-types (>= 1.16, < 4.0)
...@@ -103,8 +105,8 @@ GEM ...@@ -103,8 +105,8 @@ GEM
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.7.4) unf_ext (0.0.7.4)
xpath (2.1.0) xpath (3.2.0)
nokogiri (~> 1.3) nokogiri (~> 1.8)
PLATFORMS PLATFORMS
ruby ruby
...@@ -112,8 +114,8 @@ PLATFORMS ...@@ -112,8 +114,8 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
activesupport (= 5.2.3) activesupport (= 5.2.3)
airborne (~> 0.2.13) airborne (~> 0.2.13)
capybara (~> 2.16.1) capybara (~> 3.29.0)
capybara-screenshot (~> 1.0.18) capybara-screenshot (~> 1.0.23)
debase (~> 0.2.4.1) debase (~> 0.2.4.1)
faker (~> 1.6, >= 1.6.6) faker (~> 1.6, >= 1.6.6)
gitlab-qa gitlab-qa
......
...@@ -141,6 +141,10 @@ module QA ...@@ -141,6 +141,10 @@ module QA
page.has_no_text? text page.has_no_text? text
end end
def has_normalized_ws_text?(text, wait: Capybara.default_max_wait_time)
page.has_text?(text.gsub(/\s+/, " "), wait: wait)
end
def finished_loading? def finished_loading?
has_no_css?('.fa-spinner', wait: Capybara.default_max_wait_time) has_no_css?('.fa-spinner', wait: Capybara.default_max_wait_time)
end end
......
...@@ -14,11 +14,7 @@ module QA::Page ...@@ -14,11 +14,7 @@ module QA::Page
def click_on_latest_pipeline def click_on_latest_pipeline
css = '.js-pipeline-url-link' css = '.js-pipeline-url-link'
link = wait(reload: false) do first(css, wait: 60).click
first(css)
end
link.click
end end
def wait_for_latest_pipeline_success def wait_for_latest_pipeline_success
......
...@@ -132,6 +132,10 @@ module QA ...@@ -132,6 +132,10 @@ module QA
config.default_max_wait_time = CAPYBARA_MAX_WAIT_TIME config.default_max_wait_time = CAPYBARA_MAX_WAIT_TIME
# https://github.com/mattheworiordan/capybara-screenshot/issues/164 # https://github.com/mattheworiordan/capybara-screenshot/issues/164
config.save_path = ::File.expand_path('../../tmp', __dir__) config.save_path = ::File.expand_path('../../tmp', __dir__)
# Cabybara 3 does not normalize text by default, so older tests
# fail because of unexpected line breaks and other white space
config.default_normalize_ws = true
end end
end end
......
...@@ -52,16 +52,16 @@ module QA ...@@ -52,16 +52,16 @@ module QA
Page::Project::Show.perform(&:create_new_file!) Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |form| Page::File::Form.perform do |form|
form.select_template template[:file_name], template[:name] form.select_template template[:file_name], template[:name]
end
expect(page).to have_content(content[0..100]) expect(form).to have_normalized_ws_text(content[0..100])
Page::File::Form.perform(&:commit_changes) form.commit_changes
expect(page).to have_content('The file has been successfully created.') expect(form).to have_content('The file has been successfully created.')
expect(page).to have_content(template[:file_name]) expect(form).to have_content(template[:file_name])
expect(page).to have_content('Add new file') expect(form).to have_content('Add new file')
expect(page).to have_content(content[0..100]) expect(form).to have_normalized_ws_text(content[0..100])
end
end end
end end
end end
......
...@@ -54,15 +54,15 @@ module QA ...@@ -54,15 +54,15 @@ module QA
ide.create_new_file_from_template template[:file_name], template[:name] ide.create_new_file_from_template template[:file_name], template[:name]
expect(ide.has_file?(template[:file_name])).to be_truthy expect(ide.has_file?(template[:file_name])).to be_truthy
end
expect(page).to have_button('Undo') expect(ide).to have_button('Undo')
expect(page).to have_content(content[0..100]) expect(ide).to have_normalized_ws_text(content[0..100])
Page::Project::WebIDE::Edit.perform(&:commit_changes) ide.commit_changes
expect(page).to have_content(template[:file_name]) expect(ide).to have_content(template[:file_name])
expect(page).to have_content(content[0..100]) expect(ide).to have_normalized_ws_text(content[0..100])
end
end end
end end
end end
......
...@@ -99,14 +99,14 @@ module QA ...@@ -99,14 +99,14 @@ module QA
Page::File::Form.perform do |form| Page::File::Form.perform do |form|
form.select_template template[:type], template[:template] form.select_template template[:type], template[:template]
expect(form).to have_content(template[:content]) expect(form).to have_normalized_ws_text(template[:content])
form.commit_changes form.commit_changes
expect(form).to have_content('The file has been successfully created.') expect(form).to have_content('The file has been successfully created.')
expect(form).to have_content(template[:type]) expect(form).to have_content(template[:type])
expect(form).to have_content('Add new file') expect(form).to have_content('Add new file')
expect(form).to have_content(template[:content]) expect(form).to have_normalized_ws_text(template[:content].chomp)
end end
end end
end end
......
...@@ -5,14 +5,6 @@ module QA ...@@ -5,14 +5,6 @@ module QA
describe 'GitLab Geo attachment replication' do describe 'GitLab Geo attachment replication' do
let(:file_to_attach) { File.absolute_path(File.join('spec', 'fixtures', 'banana_sample.gif')) } let(:file_to_attach) { File.absolute_path(File.join('spec', 'fixtures', 'banana_sample.gif')) }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
it 'user uploads attachment to the primary node' do it 'user uploads attachment to the primary node' do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
Page::Main::Login.perform(&:sign_in_using_credentials) Page::Main::Login.perform(&:sign_in_using_credentials)
......
...@@ -6,14 +6,6 @@ module QA ...@@ -6,14 +6,6 @@ module QA
deleted_project_name = nil deleted_project_name = nil
deleted_project_id = nil deleted_project_id = nil
# Log out so subsequent tests can start unauthenticated
after do
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
before do before do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
Page::Main::Login.perform(&:sign_in_using_credentials) Page::Main::Login.perform(&:sign_in_using_credentials)
......
...@@ -5,14 +5,6 @@ module QA ...@@ -5,14 +5,6 @@ module QA
describe 'GitLab HTTP push' do describe 'GitLab HTTP push' do
let(:file_name) { 'README.md' } let(:file_name) { 'README.md' }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'regular git commit' do context 'regular git commit' do
it 'is replicated to the secondary' do it 'is replicated to the secondary' do
file_content = 'This is a Geo project! Commit from primary.' file_content = 'This is a Geo project! Commit from primary.'
......
...@@ -8,14 +8,6 @@ module QA ...@@ -8,14 +8,6 @@ module QA
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' } let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' } let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'regular git commit' do context 'regular git commit' do
it 'is redirected to the primary and ultimately replicated to the secondary' do it 'is redirected to the primary and ultimately replicated to the secondary' do
file_name = 'README.md' file_name = 'README.md'
......
...@@ -3,14 +3,6 @@ ...@@ -3,14 +3,6 @@
module QA module QA
context 'Geo', :orchestrated, :geo do context 'Geo', :orchestrated, :geo do
describe 'GitLab Geo project rename replication' do describe 'GitLab Geo project rename replication' do
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
it 'user renames project' do it 'user renames project' do
# create the project and push code # create the project and push code
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
......
...@@ -5,14 +5,6 @@ module QA ...@@ -5,14 +5,6 @@ module QA
describe 'GitLab SSH push' do describe 'GitLab SSH push' do
let(:file_name) { 'README.md' } let(:file_name) { 'README.md' }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'regular git commit' do context 'regular git commit' do
it "is replicated to the secondary" do it "is replicated to the secondary" do
key_title = "key for ssh tests #{Time.now.to_f}" key_title = "key for ssh tests #{Time.now.to_f}"
......
...@@ -6,19 +6,10 @@ module QA ...@@ -6,19 +6,10 @@ module QA
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' } let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' } let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' }
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'regular git commit' do context 'regular git commit' do
it 'is proxied to the primary and ultimately replicated to the secondary' do it 'is proxied to the primary and ultimately replicated to the secondary' do
file_name = 'README.md' file_name = 'README.md'
key_title = "key for ssh tests #{Time.now.to_f}" key_title = "key for ssh tests #{Time.now.to_f}"
file_content = 'This is a Geo project! Commit from secondary.'
project = nil project = nil
key = nil key = nil
...@@ -100,9 +91,9 @@ module QA ...@@ -100,9 +91,9 @@ module QA
# Validate git push worked and new content is visible # Validate git push worked and new content is visible
Page::Project::Show.perform do |show| Page::Project::Show.perform do |show|
show.wait_for_repository_replication_with(file_content) show.wait_for_repository_replication_with(file_content_secondary)
expect(page).to have_content(file_content) expect(page).to have_content(file_content_secondary)
end end
end end
end end
......
...@@ -3,14 +3,6 @@ ...@@ -3,14 +3,6 @@
module QA module QA
context 'Geo', :orchestrated, :geo do context 'Geo', :orchestrated, :geo do
describe 'GitLab wiki HTTP push' do describe 'GitLab wiki HTTP push' do
after do
# Log out so subsequent tests can start unauthenticated
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
context 'wiki commit' do context 'wiki commit' do
it 'is replicated to the secondary node' do it 'is replicated to the secondary node' do
wiki_title = 'Geo Replication Wiki' wiki_title = 'Geo Replication Wiki'
......
...@@ -12,13 +12,6 @@ module QA ...@@ -12,13 +12,6 @@ module QA
wiki = nil wiki = nil
after do
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
before do before do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login # Visit the primary node and login
......
...@@ -11,14 +11,6 @@ module QA ...@@ -11,14 +11,6 @@ module QA
wiki = nil wiki = nil
key = nil key = nil
after do
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects) do
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
end
before do before do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
Page::Main::Login.perform(&:sign_in_using_credentials) Page::Main::Login.perform(&:sign_in_using_credentials)
......
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