From 3fc9a8e6957ddf75576dc63069c4c0249514499f Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 15 Nov 2019 12:06:12 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- qa/qa/page/admin/overview/users/show.rb | 10 ++++++++++ qa/qa/page/group/show.rb | 10 ++++++++++ qa/qa/resource/base.rb | 5 ++--- qa/qa/resource/members.rb | 4 ++++ qa/qa/resource/sandbox.rb | 2 ++ qa/qa/runtime/browser.rb | 14 +++++++------- qa/qa/runtime/feature.rb | 22 ++++++++++++++++++++++ .../login/login_via_instance_wide_saml_sso_spec.rb | 4 +++- qa/qa/vendor/saml_idp/page/login.rb | 16 ++++++++++------ qa/spec/spec_helper.rb | 2 +- 10 files changed, 71 insertions(+), 18 deletions(-) (limited to 'qa') diff --git a/qa/qa/page/admin/overview/users/show.rb b/qa/qa/page/admin/overview/users/show.rb index 11ea7bcabc8..f15ef0492fc 100644 --- a/qa/qa/page/admin/overview/users/show.rb +++ b/qa/qa/page/admin/overview/users/show.rb @@ -10,9 +10,19 @@ module QA element :impersonate_user_link end + view 'app/views/admin/users/show.html.haml' do + element :confirm_user_button + end + def click_impersonate_user click_element(:impersonate_user_link) end + + def confirm_user + accept_confirm do + click_element :confirm_user_button + end + end end end end diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb index d4c4be0d6ca..e1f319da134 100644 --- a/qa/qa/page/group/show.rb +++ b/qa/qa/page/group/show.rb @@ -18,6 +18,10 @@ module QA element :no_result_text, 'No groups or projects matched your search' # rubocop:disable QA/ElementWithPattern end + view 'app/views/shared/members/_access_request_links.html.haml' do + element :leave_group_link + end + def click_subgroup(name) click_link name end @@ -42,6 +46,12 @@ module QA click_element :new_in_group_button end + def leave_group + accept_alert do + click_element :leave_group_link + end + end + private def select_kind(kind) diff --git a/qa/qa/resource/base.rb b/qa/qa/resource/base.rb index 86de421ba3f..ae20ca1a98e 100644 --- a/qa/qa/resource/base.rb +++ b/qa/qa/resource/base.rb @@ -64,12 +64,11 @@ module QA end def visit! - Runtime::Logger.debug("Visiting #{web_url}") + Runtime::Logger.debug(%Q[Visiting #{self.class.name} at "#{web_url}"]) if Runtime::Env.debug? Support::Retrier.retry_until do visit(web_url) - - wait { current_url == web_url } + wait { current_url.include?(URI.parse(web_url).path.split('/').last || web_url) } end end diff --git a/qa/qa/resource/members.rb b/qa/qa/resource/members.rb index d70a2907523..c738a91a77f 100644 --- a/qa/qa/resource/members.rb +++ b/qa/qa/resource/members.rb @@ -11,6 +11,10 @@ module QA post Runtime::API::Request.new(api_client, api_members_path).url, { user_id: user.id, access_level: access_level } end + def list_members + JSON.parse(get(Runtime::API::Request.new(api_client, api_members_path).url).body) + end + def api_members_path "#{api_get_path}/members" end diff --git a/qa/qa/resource/sandbox.rb b/qa/qa/resource/sandbox.rb index 6ee3dcf350f..6c87fcb377a 100644 --- a/qa/qa/resource/sandbox.rb +++ b/qa/qa/resource/sandbox.rb @@ -7,6 +7,8 @@ module QA # creating it if it doesn't yet exist. # class Sandbox < Base + include Members + attr_accessor :path attribute :id diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index c914526002c..7e45e5e86ea 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -57,13 +57,13 @@ module QA Capybara.register_driver QA::Runtime::Env.browser do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.send(QA::Runtime::Env.browser, - # This enables access to logs with `page.driver.manage.get_log(:browser)` - loggingPrefs: { - browser: "ALL", - client: "ALL", - driver: "ALL", - server: "ALL" - }) + # This enables access to logs with `page.driver.manage.get_log(:browser)` + loggingPrefs: { + browser: "ALL", + client: "ALL", + driver: "ALL", + server: "ALL" + }) if QA::Runtime::Env.accept_insecure_certs? capabilities['acceptInsecureCerts'] = true diff --git a/qa/qa/runtime/feature.rb b/qa/qa/runtime/feature.rb index 75cb9eded55..8c19436ee12 100644 --- a/qa/qa/runtime/feature.rb +++ b/qa/qa/runtime/feature.rb @@ -19,6 +19,28 @@ module QA set_feature(key, false) end + def remove(key) + request = Runtime::API::Request.new(api_client, "/features/#{key}") + response = delete(request.url) + unless response.code == QA::Support::Api::HTTP_STATUS_NO_CONTENT + raise SetFeatureError, "Deleting feature flag #{key} failed with `#{response}`." + end + end + + def enable_and_verify(key) + Support::Retrier.retry_on_exception(sleep_interval: 2) do + enable(key) + + is_enabled = false + + QA::Support::Waiter.wait(interval: 1) do + is_enabled = enabled?(key) + end + + raise SetFeatureError, "#{key} was not enabled!" unless is_enabled + end + end + def enabled?(key) feature = JSON.parse(get_features).find { |flag| flag["name"] == key } feature && feature["state"] == "on" diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb index 101143399f6..ad67f02eaca 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb @@ -8,7 +8,9 @@ module QA Page::Main::Login.perform(&:sign_in_with_saml) - Vendor::SAMLIdp::Page::Login.perform(&:login) + Vendor::SAMLIdp::Page::Login.perform do |login_page| + login_page.login('user1', 'user1pass') + end expect(page).to have_content('Welcome to GitLab') end diff --git a/qa/qa/vendor/saml_idp/page/login.rb b/qa/qa/vendor/saml_idp/page/login.rb index 1b8c926532a..9ebcabe15fc 100644 --- a/qa/qa/vendor/saml_idp/page/login.rb +++ b/qa/qa/vendor/saml_idp/page/login.rb @@ -7,18 +7,22 @@ module QA module SAMLIdp module Page class Login < Page::Base - def login - fill_in 'username', with: 'user1' - fill_in 'password', with: 'user1pass' + def login(username, password) + QA::Runtime::Logger.debug("Logging into SAMLIdp with username: #{username} and password:#{password}") if QA::Runtime::Env.debug? + + fill_in 'username', with: username + fill_in 'password', with: password click_on 'Login' end - def login_if_required - login if login_required? + def login_if_required(username, password) + login(username, password) if login_required? end def login_required? - page.has_text?('Enter your username and password') + login_required = page.has_text?('Enter your username and password') + QA::Runtime::Logger.debug("login_required: #{login_required}") if QA::Runtime::Env.debug? + login_required end end end diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb index ed29bfa41dd..42f1e6f292a 100644 --- a/qa/spec/spec_helper.rb +++ b/qa/spec/spec_helper.rb @@ -20,7 +20,7 @@ RSpec.configure do |config| QA::Specs::Helpers::Quarantine.configure_rspec config.before do |example| - QA::Runtime::Logger.debug("Starting test: #{example.full_description}") if QA::Runtime::Env.debug? + QA::Runtime::Logger.debug("\nStarting test: #{example.full_description}\n") if QA::Runtime::Env.debug? end config.after(:context) do -- cgit v1.2.1