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'
gem 'gitlab-qa'
gem 'activesupport', '5.2.3' # This should stay in sync with the root's Gemfile
gem 'capybara', '~> 2.16.1'
gem 'capybara-screenshot', '~> 1.0.18'
gem 'capybara', '~> 3.29.0'
gem 'capybara-screenshot', '~> 1.0.23'
gem 'rake', '~> 12.3.0'
gem 'rspec', '~> 3.7'
gem 'selenium-webdriver', '~> 3.12'
......
......@@ -6,8 +6,8 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
airborne (0.2.13)
activesupport
rack
......@@ -15,15 +15,16 @@ GEM
rest-client (>= 1.7.3, < 3.0)
rspec (~> 3.1)
byebug (9.1.0)
capybara (2.16.1)
capybara (3.29.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-screenshot (1.0.18)
capybara (>= 1.0, < 3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
capybara-screenshot (1.0.23)
capybara (>= 1.0, < 4)
launchy
childprocess (3.0.0)
coderay (1.1.2)
......@@ -50,7 +51,7 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_mime (1.0.0)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
netrc (0.11.0)
......@@ -65,11 +66,12 @@ GEM
pry-byebug (3.5.1)
byebug (~> 9.1)
pry (~> 0.10)
public_suffix (3.0.1)
rack (2.0.6)
rack-test (0.8.2)
public_suffix (4.0.1)
rack (2.0.7)
rack-test (0.8.3)
rack (>= 1.0, < 3)
rake (12.3.3)
rake (12.3.0)
regexp_parser (1.6.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
......@@ -103,8 +105,8 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)
xpath (2.1.0)
nokogiri (~> 1.3)
xpath (3.2.0)
nokogiri (~> 1.8)
PLATFORMS
ruby
......@@ -112,8 +114,8 @@ PLATFORMS
DEPENDENCIES
activesupport (= 5.2.3)
airborne (~> 0.2.13)
capybara (~> 2.16.1)
capybara-screenshot (~> 1.0.18)
capybara (~> 3.29.0)
capybara-screenshot (~> 1.0.23)
debase (~> 0.2.4.1)
faker (~> 1.6, >= 1.6.6)
gitlab-qa
......
......@@ -141,6 +141,10 @@ module QA
page.has_no_text? text
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?
has_no_css?('.fa-spinner', wait: Capybara.default_max_wait_time)
end
......
......@@ -14,11 +14,7 @@ module QA::Page
def click_on_latest_pipeline
css = '.js-pipeline-url-link'
link = wait(reload: false) do
first(css)
end
link.click
first(css, wait: 60).click
end
def wait_for_latest_pipeline_success
......
......@@ -132,6 +132,10 @@ module QA
config.default_max_wait_time = CAPYBARA_MAX_WAIT_TIME
# https://github.com/mattheworiordan/capybara-screenshot/issues/164
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
......
......@@ -52,16 +52,16 @@ module QA
Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |form|
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(page).to have_content(template[:file_name])
expect(page).to have_content('Add new file')
expect(page).to have_content(content[0..100])
expect(form).to have_content('The file has been successfully created.')
expect(form).to have_content(template[:file_name])
expect(form).to have_content('Add new file')
expect(form).to have_normalized_ws_text(content[0..100])
end
end
end
end
......
......@@ -54,15 +54,15 @@ module QA
ide.create_new_file_from_template template[:file_name], template[:name]
expect(ide.has_file?(template[:file_name])).to be_truthy
end
expect(page).to have_button('Undo')
expect(page).to have_content(content[0..100])
expect(ide).to have_button('Undo')
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(page).to have_content(content[0..100])
expect(ide).to have_content(template[:file_name])
expect(ide).to have_normalized_ws_text(content[0..100])
end
end
end
end
......
......@@ -99,14 +99,14 @@ module QA
Page::File::Form.perform do |form|
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
expect(form).to have_content('The file has been successfully created.')
expect(form).to have_content(template[:type])
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
......
......@@ -5,14 +5,6 @@ module QA
describe 'GitLab Geo attachment replication' do
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
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
Page::Main::Login.perform(&:sign_in_using_credentials)
......
......@@ -6,14 +6,6 @@ module QA
deleted_project_name = 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
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
Page::Main::Login.perform(&:sign_in_using_credentials)
......
......@@ -5,17 +5,9 @@ module QA
describe 'GitLab HTTP push' do
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
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.'
project = nil
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
......
......@@ -5,16 +5,8 @@ module QA
let(:git_push_http_path_prefix) { '/-/push_from_secondary' }
describe 'GitLab Geo HTTP push secondary' do
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
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
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' }
context 'regular git commit' do
it 'is redirected to the primary and ultimately replicated to the secondary' do
......
......@@ -3,14 +3,6 @@
module QA
context 'Geo', :orchestrated, :geo 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
# create the project and push code
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
......
......@@ -5,18 +5,10 @@ module QA
describe 'GitLab SSH push' do
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
it "is replicated to the secondary" do
key_title = "key for ssh tests #{Time.now.to_f}"
file_content = 'This is a Geo project! Commit from primary.'
file_content = 'This is a Geo project! Commit from primary.'
project = nil
key = nil
......
......@@ -3,22 +3,13 @@
module QA
context 'Geo', :orchestrated, :geo do
describe 'GitLab SSH push to secondary' do
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
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
let(:file_content_primary) { 'This is a Geo project! Commit from primary.' }
let(:file_content_secondary) { 'This is a Geo project! Commit from secondary.' }
context 'regular git commit' do
it 'is proxied to the primary and ultimately replicated to the secondary' do
file_name = 'README.md'
key_title = "key for ssh tests #{Time.now.to_f}"
file_content = 'This is a Geo project! Commit from secondary.'
project = nil
key = nil
......@@ -100,9 +91,9 @@ module QA
# Validate git push worked and new content is visible
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
......
......@@ -3,14 +3,6 @@
module QA
context 'Geo', :orchestrated, :geo 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
it 'is replicated to the secondary node' do
wiki_title = 'Geo Replication Wiki'
......
......@@ -12,13 +12,6 @@ module QA
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
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login
......
......@@ -11,14 +11,6 @@ module QA
wiki = 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
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
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