diff options
Diffstat (limited to 'spec/support/helpers')
-rw-r--r-- | spec/support/helpers/board_helpers.rb | 17 | ||||
-rw-r--r-- | spec/support/helpers/dependency_proxy_helpers.rb | 3 | ||||
-rw-r--r-- | spec/support/helpers/features/invite_members_modal_helper.rb | 12 | ||||
-rw-r--r-- | spec/support/helpers/features/top_nav_spec_helpers.rb | 24 | ||||
-rw-r--r-- | spec/support/helpers/graphql_helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/login_helpers.rb | 10 | ||||
-rw-r--r-- | spec/support/helpers/migrations_helpers.rb | 17 | ||||
-rw-r--r-- | spec/support/helpers/test_env.rb | 15 | ||||
-rw-r--r-- | spec/support/helpers/tracking_helpers.rb | 7 | ||||
-rw-r--r-- | spec/support/helpers/x509_helpers.rb | 11 |
10 files changed, 85 insertions, 33 deletions
diff --git a/spec/support/helpers/board_helpers.rb b/spec/support/helpers/board_helpers.rb index c4e69d06f52..d7277ba9a20 100644 --- a/spec/support/helpers/board_helpers.rb +++ b/spec/support/helpers/board_helpers.rb @@ -23,4 +23,21 @@ module BoardHelpers wait_for_requests end end + + def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, perform_drop: true) + inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do + # ensure there is enough horizontal space for four board lists + resize_window(2000, 800) + + drag_to(selector: selector, + scrollable: '#board-app', + list_from_index: list_from_index, + from_index: from_index, + to_index: to_index, + list_to_index: list_to_index, + perform_drop: perform_drop) + end + + wait_for_requests + end end diff --git a/spec/support/helpers/dependency_proxy_helpers.rb b/spec/support/helpers/dependency_proxy_helpers.rb index 0d8f56906e3..9413cb93199 100644 --- a/spec/support/helpers/dependency_proxy_helpers.rb +++ b/spec/support/helpers/dependency_proxy_helpers.rb @@ -34,7 +34,8 @@ module DependencyProxyHelpers def build_jwt(user = nil, expire_time: nil) JSONWebToken::HMACToken.new(::Auth::DependencyProxyAuthenticationService.secret).tap do |jwt| - jwt['user_id'] = user.id if user + jwt['user_id'] = user.id if user.is_a?(User) + jwt['deploy_token'] = user.token if user.is_a?(DeployToken) jwt.expire_time = expire_time || jwt.issued_at + 1.minute end end diff --git a/spec/support/helpers/features/invite_members_modal_helper.rb b/spec/support/helpers/features/invite_members_modal_helper.rb index 7b8cd6963c0..69ba20c1ca4 100644 --- a/spec/support/helpers/features/invite_members_modal_helper.rb +++ b/spec/support/helpers/features/invite_members_modal_helper.rb @@ -5,7 +5,7 @@ module Spec module Helpers module Features module InviteMembersModalHelper - def invite_member(name, role: 'Guest', expires_at: nil) + def invite_member(name, role: 'Guest', expires_at: nil, area_of_focus: false) click_on 'Invite members' page.within '#invite-members-modal' do @@ -14,6 +14,7 @@ module Spec wait_for_requests click_button name choose_options(role, expires_at) + choose_area_of_focus if area_of_focus click_button 'Invite' @@ -41,7 +42,14 @@ module Spec click_button role end - fill_in 'YYYY-MM-DD', with: expires_at.try(:strftime, '%Y-%m-%d') + fill_in 'YYYY-MM-DD', with: expires_at.strftime('%Y-%m-%d') if expires_at + end + + def choose_area_of_focus + page.within '[data-testid="area-of-focus-checks"]' do + check 'Contribute to the codebase' + check 'Collaborate on open issues and merge requests' + end end end end diff --git a/spec/support/helpers/features/top_nav_spec_helpers.rb b/spec/support/helpers/features/top_nav_spec_helpers.rb index 87ed897ec74..de495eceabc 100644 --- a/spec/support/helpers/features/top_nav_spec_helpers.rb +++ b/spec/support/helpers/features/top_nav_spec_helpers.rb @@ -8,38 +8,24 @@ module Spec module Features module TopNavSpecHelpers def open_top_nav - return unless Feature.enabled?(:combined_menu, default_enabled: :yaml) - find('.js-top-nav-dropdown-toggle').click end def within_top_nav - if Feature.enabled?(:combined_menu, default_enabled: :yaml) - within('.js-top-nav-dropdown-menu') do - yield - end - else - within('.navbar-sub-nav') do - yield - end + within('.js-top-nav-dropdown-menu') do + yield end end def open_top_nav_projects - if Feature.enabled?(:combined_menu, default_enabled: :yaml) - open_top_nav + open_top_nav - within_top_nav do - click_button('Projects') - end - else - find('#nav-projects-dropdown').click + within_top_nav do + click_button('Projects') end end def open_top_nav_groups - return unless Feature.enabled?(:combined_menu, default_enabled: :yaml) - open_top_nav within_top_nav do diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index 38cf828ca5e..6f17d3cb496 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -654,7 +654,7 @@ module GraphqlHelpers Class.new(Types::BaseObject) do graphql_name 'TestType' - field :name, GraphQL::STRING_TYPE, null: true + field :name, GraphQL::Types::String, null: true yield(self) if block_given? end diff --git a/spec/support/helpers/login_helpers.rb b/spec/support/helpers/login_helpers.rb index cc88a3fc71e..d9157fa7485 100644 --- a/spec/support/helpers/login_helpers.rb +++ b/spec/support/helpers/login_helpers.rb @@ -88,9 +88,10 @@ module LoginHelpers # Private: Login as the specified user # - # user - User instance to login with + # user - User instance to login with # remember - Whether or not to check "Remember me" (default: false) - def gitlab_sign_in_with(user, remember: false) + # two_factor_auth - If two-factor authentication is enabled (default: false) + def gitlab_sign_in_with(user, remember: false, two_factor_auth: false) visit new_user_session_path fill_in "user_login", with: user.email @@ -98,6 +99,11 @@ module LoginHelpers check 'user_remember_me' if remember click_button "Sign in" + + if two_factor_auth + fill_in "user_otp_attempt", with: user.reload.current_otp + click_button "Verify code" + end end def login_via(provider, user, uid, remember_me: false, additional_info: {}) diff --git a/spec/support/helpers/migrations_helpers.rb b/spec/support/helpers/migrations_helpers.rb index fa50b234bd5..ef212938af5 100644 --- a/spec/support/helpers/migrations_helpers.rb +++ b/spec/support/helpers/migrations_helpers.rb @@ -16,6 +16,23 @@ module MigrationsHelpers end end + def partitioned_table(name, by: :created_at, strategy: :monthly) + klass = Class.new(active_record_base) do + include PartitionedTable + + self.table_name = name + self.primary_key = :id + + partitioned_by by, strategy: strategy + + def self.name + table_name.singularize.camelcase + end + end + + klass.tap { Gitlab::Database::Partitioning::PartitionManager.new.sync_partitions } + end + def migrations_paths ActiveRecord::Migrator.migrations_paths end diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb index 8814d260fb3..aa5fcf222f2 100644 --- a/spec/support/helpers/test_env.rb +++ b/spec/support/helpers/test_env.rb @@ -158,7 +158,7 @@ module TestEnv component_timed_setup('Gitaly', install_dir: gitaly_dir, version: Gitlab::GitalyClient.expected_server_version, - task: "gitlab:gitaly:install", + task: "gitlab:gitaly:test_install", task_args: [gitaly_dir, repos_path, gitaly_url].compact) do Gitlab::SetupHelper::Gitaly.create_configuration( gitaly_dir, @@ -263,8 +263,13 @@ module TestEnv # Feature specs are run through Workhorse def setup_workhorse + # Always rebuild the config file + if skip_compile_workhorse? + Gitlab::SetupHelper::Workhorse.create_configuration(workhorse_dir, nil, force: true) + return + end + start = Time.now - return if skip_compile_workhorse? FileUtils.rm_rf(workhorse_dir) Gitlab::SetupHelper::Workhorse.compile_into(workhorse_dir) @@ -305,12 +310,6 @@ module TestEnv config_path = Gitlab::SetupHelper::Workhorse.get_config_path(workhorse_dir, {}) - # This should be set up in setup_workhorse, but since - # component_needs_update? only checks that versions are consistent, - # we need to ensure the config file exists. This line can be removed - # later after a new Workhorse version is updated. - Gitlab::SetupHelper::Workhorse.create_configuration(workhorse_dir, nil) unless File.exist?(config_path) - workhorse_pid = spawn( { 'PATH' => "#{ENV['PATH']}:#{workhorse_dir}" }, File.join(workhorse_dir, 'gitlab-workhorse'), diff --git a/spec/support/helpers/tracking_helpers.rb b/spec/support/helpers/tracking_helpers.rb new file mode 100644 index 00000000000..c0374578531 --- /dev/null +++ b/spec/support/helpers/tracking_helpers.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module TrackingHelpers + def stub_do_not_track(value) + request.headers['DNT'] = value + end +end diff --git a/spec/support/helpers/x509_helpers.rb b/spec/support/helpers/x509_helpers.rb index ce0fa268ace..1dc8b1d4845 100644 --- a/spec/support/helpers/x509_helpers.rb +++ b/spec/support/helpers/x509_helpers.rb @@ -290,6 +290,17 @@ module X509Helpers SIGNEDDATA end + def unsigned_tag_base_data + <<~SIGNEDDATA + object 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 + type commit + tag v1.0.0 + tagger Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> 1393491299 +0200 + + Release + SIGNEDDATA + end + def certificate_crl 'http://ch.siemens.com/pki?ZZZZZZA2.crl' end |