diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-21 18:13:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-21 18:13:54 +0300 |
commit | 48fc1ad8991a96ef2eaa927bb6df3bfab2c78e46 (patch) | |
tree | 12d1587e82af71bb32db890fe865e18269d5edd7 | |
parent | cb6f08be88608936fbeafa535cf725e1eaa3ffeb (diff) |
Add latest changes from gitlab-org/gitlab@master
129 files changed, 600 insertions, 505 deletions
diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 154c5f58c35..b1e0573abdf 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -7cd8ef212eccee3ffd388f1b88ccdeca15971435 +639d1a25d4de3e2a60cf10e8c3afc0121c27c317 diff --git a/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue b/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue index bb2bac531a7..e6575e55a1c 100644 --- a/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue +++ b/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue @@ -99,7 +99,10 @@ export default { allRunnersCount: { ...runnersCountSmartQuery, variables() { - return this.countVariables; + return { + ...this.countVariables, + type: null, + }; }, }, instanceRunnersCount: { diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb index 16657612050..63ae34f5ed3 100644 --- a/app/controllers/admin/runners_controller.rb +++ b/app/controllers/admin/runners_controller.rb @@ -85,7 +85,11 @@ class Admin::RunnersController < Admin::ApplicationController # rubocop: disable CodeReuse/ActiveRecord def assign_builds_and_projects - @builds = runner.builds.order('id DESC').preload_project_and_pipeline_project.first(30) + @builds = runner + .builds + .order_id_desc + .preload_project_and_pipeline_project.first(30) + @projects = if params[:search].present? ::Project.search(params[:search]) @@ -93,12 +97,10 @@ class Admin::RunnersController < Admin::ApplicationController Project.all end - ::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') do - @projects = @projects.where.not(id: runner.projects.select(:id)) if runner.projects.any? - @projects = @projects.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') - @projects = @projects.inc_routes - @projects = @projects.page(params[:page]).per(30).without_count - end + runner_projects_ids = runner.runner_projects.pluck(:project_id) + @projects = @projects.where.not(id: runner_projects_ids) if runner_projects_ids.any? + @projects = @projects.inc_routes + @projects = @projects.page(params[:page]).per(30).without_count end # rubocop: enable CodeReuse/ActiveRecord end diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 58a6433fe47..87733833b7e 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -67,7 +67,7 @@ module Ci has_many :builds has_many :runner_projects, inverse_of: :runner, autosave: true, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent - has_many :projects, through: :runner_projects + has_many :projects, through: :runner_projects, disable_joins: -> { ::Feature.enabled?(:ci_runner_projects_disable_joins, default_enabled: :yaml) } has_many :runner_namespaces, inverse_of: :runner, autosave: true has_many :groups, through: :runner_namespaces, disable_joins: true @@ -378,9 +378,7 @@ module Ci end def only_for?(project) - ::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') do - projects == [project] - end + !runner_projects.where.not(project_id: project.id).exists? end def short_sha diff --git a/app/services/concerns/rate_limited_service.rb b/app/services/concerns/rate_limited_service.rb index 87cba7814fe..c8dc60355cf 100644 --- a/app/services/concerns/rate_limited_service.rb +++ b/app/services/concerns/rate_limited_service.rb @@ -17,7 +17,7 @@ module RateLimitedService end def log_request(request, current_user) - rate_limiter.class.log_request(request, "#{key}_request_limit".to_sym, current_user) + rate_limiter.log_request(request, "#{key}_request_limit".to_sym, current_user) end private @@ -26,20 +26,19 @@ module RateLimitedService end class RateLimiterScopedAndKeyed - attr_reader :key, :opts, :rate_limiter_klass + attr_reader :key, :opts, :rate_limiter - def initialize(key:, opts:, rate_limiter_klass:) + def initialize(key:, opts:, rate_limiter:) @key = key @opts = opts - @rate_limiter_klass = rate_limiter_klass + @rate_limiter = rate_limiter end def rate_limit!(service) evaluated_scope = evaluated_scope_for(service) return if feature_flag_disabled?(evaluated_scope[:project]) - rate_limiter = new_rate_limiter(evaluated_scope) - if rate_limiter.throttled? + if rate_limiter.throttled?(key, **opts.merge(scope: evaluated_scope.values, users_allowlist: users_allowlist)) raise RateLimitedError.new(key: key, rate_limiter: rate_limiter), _('This endpoint has been requested too many times. Try again later.') end end @@ -59,20 +58,16 @@ module RateLimitedService def feature_flag_disabled?(project) Feature.disabled?("rate_limited_service_#{key}", project, default_enabled: :yaml) end - - def new_rate_limiter(evaluated_scope) - rate_limiter_klass.new(key, **opts.merge(scope: evaluated_scope.values, users_allowlist: users_allowlist)) - end end prepended do attr_accessor :rate_limiter_bypassed cattr_accessor :rate_limiter_scoped_and_keyed - def self.rate_limit(key:, opts:, rate_limiter_klass: ::Gitlab::ApplicationRateLimiter) + def self.rate_limit(key:, opts:, rate_limiter: ::Gitlab::ApplicationRateLimiter) self.rate_limiter_scoped_and_keyed = RateLimiterScopedAndKeyed.new(key: key, opts: opts, - rate_limiter_klass: rate_limiter_klass) + rate_limiter: rate_limiter) end end diff --git a/config/feature_flags/development/ci_runner_projects_disable_joins.yml b/config/feature_flags/development/ci_runner_projects_disable_joins.yml new file mode 100644 index 00000000000..4200a4a55b9 --- /dev/null +++ b/config/feature_flags/development/ci_runner_projects_disable_joins.yml @@ -0,0 +1,8 @@ +--- +name: ci_runner_projects_disable_joins +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/78372 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/350538 +milestone: '14.8' +type: development +group: group::pipeline execution +default_enabled: false diff --git a/config/feature_flags/development/gitlab_shell_upload_pack_sidechannel.yml b/config/feature_flags/development/gitlab_shell_upload_pack_sidechannel.yml new file mode 100644 index 00000000000..e329959d36f --- /dev/null +++ b/config/feature_flags/development/gitlab_shell_upload_pack_sidechannel.yml @@ -0,0 +1,8 @@ +--- +name: gitlab_shell_upload_pack_sidechannel +introduced_by_url: +rollout_issue_url: +milestone: '14.8' +type: development +group: group::scalability +default_enabled: false diff --git a/config/initializers/google_api_client.rb b/config/initializers/google_api_client.rb index 49a35e5bd7c..ab469e5b0a1 100644 --- a/config/initializers/google_api_client.rb +++ b/config/initializers/google_api_client.rb @@ -10,3 +10,14 @@ require 'signet/errors' # enabling retries is strongly encouraged but disabled by default. Large uploads # that may hit timeouts will mainly benefit from this. Google::Apis::RequestOptions.default.retries = 3 if Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_GOOGLE_API_RETRIES', true)) + +# By default, httpclient will set a send timeout of 120 seconds (https://github.com/nahi/httpclient/blob/82929c4baae14c2319c3f9aba49488c6f6def875/lib/httpclient/session.rb#L147), +# which causes any request to be interrupted every 2 minutes (https://github.com/nahi/httpclient/blob/82929c4baae14c2319c3f9aba49488c6f6def875/lib/httpclient/session.rb#L515). +# +# The Google API client uses resumable uploads so that if a transfer +# request is interrupted, it can retry where it left off. The client +# will retry at most N + 1 times, which means transfers can only last as +# long as this (N + 1) * send timeout. We raise this timeout to an hour +# since otherwise transfers can only last 8 minutes (4 * 2 min) before +# being interrupted. +Google::Apis::ClientOptions.default.send_timeout_sec = 3600 diff --git a/config/initializers/google_api_client_patch.rb b/config/initializers/google_api_client_patch.rb new file mode 100644 index 00000000000..1408dcb0501 --- /dev/null +++ b/config/initializers/google_api_client_patch.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'google/apis/core/http_command' + +raise 'This patch is only tested with google-api-client-ruby v0.50.0' unless Google::Apis::VERSION == "0.50.0" + +# The google-api-ruby-client does not have a way to increase or disable +# the maximum allowed time for a request to be retried. By default, it +# is using the Retriable gem's 15-minute timeout, which appears to be +# too low for uploads over 10 GB. This patches the gem with the upstream +# changes: +# https://github.com/googleapis/google-api-ruby-client/pull/8106 +module Google + module Apis + module Core + # Command for HTTP request/response. + class HttpCommand + MAX_ELAPSED_TIME = 3600 + + # Execute the command, retrying as necessary + # + # @param [HTTPClient] client + # HTTP client + # @yield [result, err] Result or error if block supplied + # @return [Object] + # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried + # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification + # @raise [Google::Apis::AuthorizationError] Authorization is required + def execute(client) + prepare! + opencensus_begin_span + begin + Retriable.retriable tries: options.retries + 1, + max_elapsed_time: MAX_ELAPSED_TIME, + base_interval: 1, + multiplier: 2, + on: RETRIABLE_ERRORS do |try| + # This 2nd level retriable only catches auth errors, and supports 1 retry, which allows + # auth to be re-attempted without having to retry all sorts of other failures like + # NotFound, etc + auth_tries = (try == 1 && authorization_refreshable? ? 2 : 1) + Retriable.retriable tries: auth_tries, + on: [Google::Apis::AuthorizationError, Signet::AuthorizationError, Signet::RemoteServerError, Signet::UnexpectedStatusError], + on_retry: proc { |*| refresh_authorization } do + execute_once(client).tap do |result| + if block_given? + yield result, nil + end + end + end + end + rescue => e # rubocop:disable Style/RescueStandardError + if block_given? + yield nil, e + else + raise e + end + end + ensure + opencensus_end_span + @http_res = nil + release! + end + end + end + end +end diff --git a/db/migrate/20220120085655_add_ci_runner_project_index_to_runner_id_and_project_id.rb b/db/migrate/20220120085655_add_ci_runner_project_index_to_runner_id_and_project_id.rb new file mode 100644 index 00000000000..bcf32d2abd0 --- /dev/null +++ b/db/migrate/20220120085655_add_ci_runner_project_index_to_runner_id_and_project_id.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddCiRunnerProjectIndexToRunnerIdAndProjectId < Gitlab::Database::Migration[1.0] + disable_ddl_transaction! + + OLD_INDEX_NAME = 'index_ci_runner_projects_on_runner_id' + NEW_INDEX_NAME = 'index_ci_runner_projects_on_runner_id_and_project_id' + TABLE_NAME = :ci_runner_projects + + def up + add_concurrent_index(TABLE_NAME, [:runner_id, :project_id], name: NEW_INDEX_NAME) + remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME) + end + + def down + add_concurrent_index(TABLE_NAME, :runner_id, name: OLD_INDEX_NAME) + remove_concurrent_index_by_name(TABLE_NAME, NEW_INDEX_NAME) + end +end diff --git a/db/post_migrate/20220119203119_remove_ci_pipelines_vulnerability_occurrence_pipelines_pipeline_id_fk.rb b/db/post_migrate/20220119203119_remove_ci_pipelines_vulnerability_occurrence_pipelines_pipeline_id_fk.rb new file mode 100644 index 00000000000..b6397486dd0 --- /dev/null +++ b/db/post_migrate/20220119203119_remove_ci_pipelines_vulnerability_occurrence_pipelines_pipeline_id_fk.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class RemoveCiPipelinesVulnerabilityOccurrencePipelinesPipelineIdFk < Gitlab::Database::Migration[1.0] + disable_ddl_transaction! + + def up + with_lock_retries do + execute('LOCK ci_pipelines, vulnerability_occurrence_pipelines IN ACCESS EXCLUSIVE MODE') + + remove_foreign_key_if_exists(:vulnerability_occurrence_pipelines, :ci_pipelines, name: "fk_rails_6421e35d7d") + end + end + + def down + add_concurrent_foreign_key(:vulnerability_occurrence_pipelines, :ci_pipelines, name: "fk_rails_6421e35d7d", column: :pipeline_id, target_column: :id, on_delete: :cascade) + end +end diff --git a/db/schema_migrations/20220119203119 b/db/schema_migrations/20220119203119 new file mode 100644 index 00000000000..43bdb5b0391 --- /dev/null +++ b/db/schema_migrations/20220119203119 @@ -0,0 +1 @@ +c0f29fd7f960ffd92a65a00e8dce123b91a604f4d89b7cf0bc419fa80495e2e5
\ No newline at end of file diff --git a/db/schema_migrations/20220120085655 b/db/schema_migrations/20220120085655 new file mode 100644 index 00000000000..534108786ec --- /dev/null +++ b/db/schema_migrations/20220120085655 @@ -0,0 +1 @@ +966c42749e9d200f2b7295fdbb86e596c33510f0abbf431d40b09629e5e4a6aa
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 19503280498..6db27149186 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -25707,7 +25707,7 @@ CREATE UNIQUE INDEX index_ci_runner_namespaces_on_runner_id_and_namespace_id ON CREATE INDEX index_ci_runner_projects_on_project_id ON ci_runner_projects USING btree (project_id); -CREATE INDEX index_ci_runner_projects_on_runner_id ON ci_runner_projects USING btree (runner_id); +CREATE INDEX index_ci_runner_projects_on_runner_id_and_project_id ON ci_runner_projects USING btree (runner_id, project_id); CREATE INDEX index_ci_runners_on_active ON ci_runners USING btree (active, id); @@ -30631,9 +30631,6 @@ ALTER TABLE ONLY evidences ALTER TABLE ONLY jira_imports ADD CONSTRAINT fk_rails_63cbe52ada FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; -ALTER TABLE ONLY vulnerability_occurrence_pipelines - ADD CONSTRAINT fk_rails_6421e35d7d FOREIGN KEY (pipeline_id) REFERENCES ci_pipelines(id) ON DELETE CASCADE; - ALTER TABLE ONLY group_deploy_tokens ADD CONSTRAINT fk_rails_6477b01f6b FOREIGN KEY (deploy_token_id) REFERENCES deploy_tokens(id) ON DELETE CASCADE; diff --git a/doc/development/testing_guide/review_apps.md b/doc/development/testing_guide/review_apps.md index 5ae6b9e5a59..a674c08dc9e 100644 --- a/doc/development/testing_guide/review_apps.md +++ b/doc/development/testing_guide/review_apps.md @@ -30,7 +30,7 @@ You can also manually start the `review-qa-all`: it runs the full QA suite. After the end-to-end test runs have finished, [Allure reports](https://github.com/allure-framework/allure2) are generated and published by the `allure-report-qa-smoke`, `allure-report-qa-reliable`, and `allure-report-qa-all` jobs. A comment with links to the reports are added to the merge request. -Errors can be found in the `gitlab-review-apps` Sentry project and [filterable by Review App URL](https://sentry.gitlab.net/gitlab/gitlab-review-apps/?query=url%3A%22https%3A%2F%2Fgitlab-review-require-ve-u92nn2.gitlab-review.app%2F%22). +Errors can be found in the `gitlab-review-apps` Sentry project and [filterable by Review App URL](https://sentry.gitlab.net/gitlab/gitlab-review-apps/?query=url%3A%22https%3A%2F%2Fgitlab-review-require-ve-u92nn2.gitlab-review.app%2F%22) or [commit SHA](https://sentry.gitlab.net/gitlab/gitlab-review-apps/releases/6095b501da7/all-events/). ## Performance Metrics diff --git a/doc/user/permissions.md b/doc/user/permissions.md index 5efb31868e6..ea79a026aa9 100644 --- a/doc/user/permissions.md +++ b/doc/user/permissions.md @@ -97,13 +97,13 @@ The following table lists project permissions available for each role: | [Incident Management](../operations/incident_management/index.md):<br>Manage [escalation policies](../operations/incident_management/escalation_policies.md) | | | | ✓ | ✓ | | [Issues](project/issues/index.md):<br>Add Labels | ✓ (*16*) | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>Assign | ✓ (*16*) | ✓ | ✓ | ✓ | ✓ | -| [Issues](project/issues/index.md):<br>Create | ✓ | ✓ | ✓ | ✓ | ✓ | +| [Issues](project/issues/index.md):<br>Create (*19*) | ✓ | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>Create [confidential issues](project/issues/confidential_issues.md) | ✓ | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>View [Design Management](project/issues/design_management.md) pages | ✓ | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>View related issues | ✓ | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>Set weight | ✓ (*16*) | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>View [confidential issues](project/issues/confidential_issues.md) | (*2*) | ✓ | ✓ | ✓ | ✓ | -| [Issues](project/issues/index.md):<br>Close / reopen | | ✓ | ✓ | ✓ | ✓ | +| [Issues](project/issues/index.md):<br>Close / reopen (*20*) | | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>Lock threads | | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>Manage related issues | | ✓ | ✓ | ✓ | ✓ | | [Issues](project/issues/index.md):<br>Manage tracker | | ✓ | ✓ | ✓ | ✓ | @@ -234,7 +234,10 @@ The following table lists project permissions available for each role: 1. Guest users can only set metadata (for example, labels, assignees, or milestones) when creating an issue. They cannot change the metadata on existing issues. 1. In GitLab 14.5 or later, Guests are not allowed to [create incidents](../operations/incident_management/incidents.md#incident-creation). + A guest who created an incident when they had the Reporter role or who is assigned to the incident can modify the title, description and metrics. They can also close and reopen the incident. 1. In projects that accept contributions from external members, users can create, edit, and close their own merge requests. +1. Authors and assignees of issues can modify the title and description even if they don't have the Reporter role. +1. Authors and assignees can close and reopen issues even if they don't have the Reporter role. ## Project features permissions diff --git a/doc/user/project/issues/managing_issues.md b/doc/user/project/issues/managing_issues.md index d120df82dbf..03286ff3617 100644 --- a/doc/user/project/issues/managing_issues.md +++ b/doc/user/project/issues/managing_issues.md @@ -224,7 +224,7 @@ You can edit an issue's title and description. Prerequisites: -- You must have at least the [Reporter role](../../permissions.md) for the project. +- You must have at least the [Reporter role](../../permissions.md) for the project, be the author of the issue, or be assigned to the issue. To edit an issue: @@ -351,7 +351,7 @@ The issue is marked as closed but is not deleted. Prerequisites: -- You must have at least the [Reporter role](../../permissions.md) for the project. +- You must have at least the [Reporter role](../../permissions.md) for the project, be the author of the issue, or be assigned to the issue. To close an issue, you can do the following: @@ -364,7 +364,7 @@ To close an issue, you can do the following: Prerequisites: -- You must have at least the [Reporter role](../../permissions.md) for the project. +- You must have at least the [Reporter role](../../permissions.md) for the project, be the author of the issue, or be assigned to the issue. To reopen a closed issue, at the top of the issue, select **Reopen issue**. A reopened issue is no different from any other open issue. @@ -476,7 +476,7 @@ of your installation. Prerequisites: -- You must be the issue author or have at least the [Reporter role](../../permissions.md) for the project. +- You must be the issue author or have at least the [Reporter role](../../permissions.md) for the project, be the author of the issue, or be assigned to the issue. To change issue type: diff --git a/lib/api/entities/ci/runner_details.rb b/lib/api/entities/ci/runner_details.rb index 6ded1296f2a..9b1decca274 100644 --- a/lib/api/entities/ci/runner_details.rb +++ b/lib/api/entities/ci/runner_details.rb @@ -15,18 +15,18 @@ module API # rubocop: disable CodeReuse/ActiveRecord expose :projects, with: Entities::BasicProjectDetails do |runner, options| if options[:current_user].admin? # rubocop: disable Cop/UserAdmin - runner.projects.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') + runner.projects else - options[:current_user].authorized_projects.where(id: runner.projects).allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') + options[:current_user].authorized_projects.where(id: runner.runner_projects.pluck(:project_id)) end end # rubocop: enable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord expose :groups, with: Entities::BasicGroupDetails do |runner, options| if options[:current_user].admin? # rubocop: disable Cop/UserAdmin - runner.groups.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') + runner.groups else - options[:current_user].authorized_groups.where(id: runner.groups).allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338659') + options[:current_user].authorized_groups.where(id: runner.runner_namespaces.pluck(:namespace_id)) end end # rubocop: enable CodeReuse/ActiveRecord diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb index e03f029a6ef..46685df0989 100644 --- a/lib/api/helpers/internal_helpers.rb +++ b/lib/api/helpers/internal_helpers.rb @@ -124,7 +124,8 @@ module API repository: repository.gitaly_repository.to_h, address: Gitlab::GitalyClient.address(repository.shard), token: Gitlab::GitalyClient.token(repository.shard), - features: Feature::Gitaly.server_feature_flags(repository.project) + features: Feature::Gitaly.server_feature_flags(repository.project), + use_sidechannel: Feature.enabled?(:gitlab_shell_upload_pack_sidechannel, repository.project, default_enabled: :yaml) } end end diff --git a/lib/api/helpers/rate_limiter.rb b/lib/api/helpers/rate_limiter.rb index 0ad4f089907..03f3cd649b1 100644 --- a/lib/api/helpers/rate_limiter.rb +++ b/lib/api/helpers/rate_limiter.rb @@ -5,7 +5,7 @@ module API # == RateLimiter # # Helper that checks if the rate limit for a given endpoint is throttled by calling the - # Gitlab::ApplicationRateLimiter class. If the action is throttled for the current user, the request + # Gitlab::ApplicationRateLimiter module. If the action is throttled for the current user, the request # will be logged and an error message will be rendered with a Too Many Requests response status. # See app/controllers/concerns/check_rate_limit.rb for Rails controllers version module RateLimiter diff --git a/lib/gitlab/application_rate_limiter.rb b/lib/gitlab/application_rate_limiter.rb index 12f1b15f820..eba1980f832 100644 --- a/lib/gitlab/application_rate_limiter.rb +++ b/lib/gitlab/application_rate_limiter.rb @@ -1,30 +1,13 @@ # frozen_string_literal: true module Gitlab - # This class implements a simple rate limiter that can be used to throttle + # This module implements a simple rate limiter that can be used to throttle # certain actions. Unlike Rack Attack and Rack::Throttle, which operate at # the middleware level, this can be used at the controller or API level. # See CheckRateLimit concern for usage. - class ApplicationRateLimiter + module ApplicationRateLimiter InvalidKeyError = Class.new(StandardError) - def initialize(key, **options) - @key = key - @options = options - end - - def throttled? - self.class.throttled?(key, **options) - end - - def threshold_value - options[:threshold] || self.class.threshold(key) - end - - def interval_value - self.class.interval(key) - end - class << self # Application rate limits # @@ -201,9 +184,5 @@ module Gitlab scoped_user.username.downcase.in?(users_allowlist) end end - - private - - attr_reader :key, :options end end diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb index 8a2a382ac45..7a9ad3a852d 100644 --- a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb +++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_issue_spec.rb @@ -40,13 +40,13 @@ module QA testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347608' ) do expect_import_finished + expect(imported_issues.count).to eq(1) aggregate_failures do - expect(imported_issues.count).to eq(1) expect(imported_issue).to eq(source_issue.reload!) expect(imported_comments.count).to eq(1) - expect(imported_comments.first[:body]).to include(source_comment[:body]) + expect(imported_comments.first&.fetch(:body)).to include(source_comment[:body]) end end end diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb index 9dce9bff3c1..34e56f31f7f 100644 --- a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb +++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_mr_spec.rb @@ -52,9 +52,9 @@ module QA testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348478' ) do expect_import_finished + expect(imported_mrs.count).to eq(1) aggregate_failures do - expect(imported_mrs.count).to eq(1) # TODO: remove custom comparison after member migration is implemented # https://gitlab.com/gitlab-org/gitlab/-/issues/341886 expect(imported_mr.comparable.except(:author)).to eq(source_mr.reload!.comparable.except(:author)) diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 37aa1433994..76d6fded531 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -254,6 +254,18 @@ RSpec.describe "Admin Runners" do expect(page).not_to have_content 'runner-group' end + it 'show the same counts after selecting another tab' do + visit admin_runners_path + + page.within('[data-testid="runner-type-tabs"]') do + click_on('Project') + + expect(page).to have_link('All 2') + expect(page).to have_link('Group 1') + expect(page).to have_link('Project 1') + end + end + it 'shows no runner when type does not match' do visit admin_runners_path diff --git a/spec/frontend/add_context_commits_modal/components/add_context_commits_modal_spec.js b/spec/frontend/add_context_commits_modal/components/add_context_commits_modal_spec.js index e7a20ae114c..1918d5c5611 100644 --- a/spec/frontend/add_context_commits_modal/components/add_context_commits_modal_spec.js +++ b/spec/frontend/add_context_commits_modal/components/add_context_commits_modal_spec.js @@ -1,5 +1,6 @@ import { GlModal, GlSearchBoxByType } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import getDiffWithCommit from 'test_fixtures/merge_request_diffs/with_commit.json'; import AddReviewItemsModal from '~/add_context_commits_modal/components/add_context_commits_modal_wrapper.vue'; @@ -8,8 +9,7 @@ import * as actions from '~/add_context_commits_modal/store/actions'; import mutations from '~/add_context_commits_modal/store/mutations'; import defaultState from '~/add_context_commits_modal/store/state'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('AddContextCommitsModal', () => { let wrapper; @@ -36,7 +36,6 @@ describe('AddContextCommitsModal', () => { }); wrapper = shallowMount(AddReviewItemsModal, { - localVue, store, propsData: { contextCommitsPath: '', diff --git a/spec/frontend/badges/components/badge_settings_spec.js b/spec/frontend/badges/components/badge_settings_spec.js index 0c29379763e..8ac5d2c72d9 100644 --- a/spec/frontend/badges/components/badge_settings_spec.js +++ b/spec/frontend/badges/components/badge_settings_spec.js @@ -1,5 +1,6 @@ import { GlModal } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import BadgeList from '~/badges/components/badge_list.vue'; import BadgeListRow from '~/badges/components/badge_list_row.vue'; @@ -7,8 +8,7 @@ import BadgeSettings from '~/badges/components/badge_settings.vue'; import store from '~/badges/store'; import { createDummyBadge } from '../dummy_badge'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('BadgeSettings component', () => { let wrapper; @@ -21,7 +21,6 @@ describe('BadgeSettings component', () => { wrapper = shallowMount(BadgeSettings, { store, - localVue, stubs: { 'badge-list': BadgeList, 'badge-list-row': BadgeListRow, diff --git a/spec/frontend/batch_comments/components/diff_file_drafts_spec.js b/spec/frontend/batch_comments/components/diff_file_drafts_spec.js index dcb68b1804f..8805f6bf204 100644 --- a/spec/frontend/batch_comments/components/diff_file_drafts_spec.js +++ b/spec/frontend/batch_comments/components/diff_file_drafts_spec.js @@ -1,11 +1,10 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import DiffFileDrafts from '~/batch_comments/components/diff_file_drafts.vue'; import DraftNote from '~/batch_comments/components/draft_note.vue'; -const localVue = createLocalVue(); - -localVue.use(Vuex); +Vue.use(Vuex); describe('Batch comments diff file drafts component', () => { let vm; @@ -22,9 +21,8 @@ describe('Batch comments diff file drafts component', () => { }, }); - vm = shallowMount(localVue.extend(DiffFileDrafts), { + vm = shallowMount(DiffFileDrafts, { store, - localVue, propsData: { fileHash: 'filehash' }, }); } diff --git a/spec/frontend/batch_comments/components/draft_note_spec.js b/spec/frontend/batch_comments/components/draft_note_spec.js index 5d22823e974..9c0d59c4443 100644 --- a/spec/frontend/batch_comments/components/draft_note_spec.js +++ b/spec/frontend/batch_comments/components/draft_note_spec.js @@ -1,5 +1,5 @@ import { getByRole } from '@testing-library/dom'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import { stubComponent } from 'helpers/stub_component'; import DraftNote from '~/batch_comments/components/draft_note.vue'; import { createStore } from '~/batch_comments/stores'; @@ -7,8 +7,6 @@ import NoteableNote from '~/notes/components/noteable_note.vue'; import '~/behaviors/markdown/render_gfm'; import { createDraft } from '../mock_data'; -const localVue = createLocalVue(); - const NoteableNoteStub = stubComponent(NoteableNote, { template: ` <div> @@ -31,10 +29,9 @@ describe('Batch comments draft note component', () => { const getList = () => getByRole(wrapper.element, 'list'); const createComponent = (propsData = { draft }) => { - wrapper = shallowMount(localVue.extend(DraftNote), { + wrapper = shallowMount(DraftNote, { store, propsData, - localVue, stubs: { NoteableNote: NoteableNoteStub, }, diff --git a/spec/frontend/batch_comments/components/publish_dropdown_spec.js b/spec/frontend/batch_comments/components/publish_dropdown_spec.js index bd8091c20e0..a3168931f1f 100644 --- a/spec/frontend/batch_comments/components/publish_dropdown_spec.js +++ b/spec/frontend/batch_comments/components/publish_dropdown_spec.js @@ -1,13 +1,13 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import PreviewDropdown from '~/batch_comments/components/preview_dropdown.vue'; import { createStore } from '~/mr_notes/stores'; import '~/behaviors/markdown/render_gfm'; import { createDraft } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Batch comments publish dropdown component', () => { let wrapper; diff --git a/spec/frontend/boards/components/board_new_issue_spec.js b/spec/frontend/boards/components/board_new_issue_spec.js index 57ccebf3676..12bee842c85 100644 --- a/spec/frontend/boards/components/board_new_issue_spec.js +++ b/spec/frontend/boards/components/board_new_issue_spec.js @@ -1,4 +1,5 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import BoardNewIssue from '~/boards/components/board_new_issue.vue'; import BoardNewItem from '~/boards/components/board_new_item.vue'; @@ -7,9 +8,7 @@ import eventHub from '~/boards/eventhub'; import { mockList, mockGroupProjects } from '../mock_data'; -const localVue = createLocalVue(); - -localVue.use(Vuex); +Vue.use(Vuex); const addListNewIssuesSpy = jest.fn().mockResolvedValue(); const mockActions = { addListNewIssue: addListNewIssuesSpy }; @@ -20,7 +19,6 @@ const createComponent = ({ getters = { isGroupBoard: () => true, isProjectBoard: () => false }, } = {}) => shallowMount(BoardNewIssue, { - localVue, store: new Vuex.Store({ state, actions, diff --git a/spec/frontend/ci_variable_list/components/ci_environments_dropdown_spec.js b/spec/frontend/ci_variable_list/components/ci_environments_dropdown_spec.js index 5c5ea102f12..f4a0eef1129 100644 --- a/spec/frontend/ci_variable_list/components/ci_environments_dropdown_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_environments_dropdown_spec.js @@ -1,10 +1,10 @@ import { GlDropdown, GlDropdownItem, GlIcon } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import CiEnvironmentsDropdown from '~/ci_variable_list/components/ci_environments_dropdown.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Ci environments dropdown', () => { let wrapper; @@ -22,7 +22,6 @@ describe('Ci environments dropdown', () => { wrapper = mount(CiEnvironmentsDropdown, { store, - localVue, propsData: { value: term, }, diff --git a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js index 7c4ff67feb3..085ab1c0c30 100644 --- a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js @@ -1,5 +1,6 @@ import { GlButton, GlFormInput } from '@gitlab/ui'; -import { createLocalVue, shallowMount, mount } from '@vue/test-utils'; +import { shallowMount, mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { mockTracking } from 'helpers/tracking_helper'; import CiEnvironmentsDropdown from '~/ci_variable_list/components/ci_environments_dropdown.vue'; @@ -9,8 +10,7 @@ import createStore from '~/ci_variable_list/store'; import mockData from '../services/mock_data'; import ModalStub from '../stubs'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Ci variable modal', () => { let wrapper; @@ -26,7 +26,6 @@ describe('Ci variable modal', () => { stubs: { GlModal: ModalStub, }, - localVue, store, ...options, }); diff --git a/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js index 03f90f72d87..13e417940a8 100644 --- a/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js @@ -1,10 +1,10 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import CiVariableSettings from '~/ci_variable_list/components/ci_variable_settings.vue'; import createStore from '~/ci_variable_list/store'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Ci variable table', () => { let wrapper; @@ -16,7 +16,6 @@ describe('Ci variable table', () => { store.state.isGroup = groupState; jest.spyOn(store, 'dispatch').mockImplementation(); wrapper = shallowMount(CiVariableSettings, { - localVue, store, }); }; diff --git a/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js index 8367c3f6bb8..2469569b436 100644 --- a/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js @@ -1,11 +1,11 @@ -import { createLocalVue, mount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import CiVariableTable from '~/ci_variable_list/components/ci_variable_table.vue'; import createStore from '~/ci_variable_list/store'; import mockData from '../services/mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Ci variable table', () => { let wrapper; @@ -16,7 +16,6 @@ describe('Ci variable table', () => { jest.spyOn(store, 'dispatch').mockImplementation(); wrapper = mount(CiVariableTable, { attachTo: document.body, - localVue, store, }); }; diff --git a/spec/frontend/clusters/forms/components/integration_form_spec.js b/spec/frontend/clusters/forms/components/integration_form_spec.js index d041cd1e164..a9fb5c205fd 100644 --- a/spec/frontend/clusters/forms/components/integration_form_spec.js +++ b/spec/frontend/clusters/forms/components/integration_form_spec.js @@ -1,11 +1,11 @@ import { GlToggle, GlButton } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import IntegrationForm from '~/clusters/forms/components/integration_form.vue'; import { createStore } from '~/clusters/forms/stores/index'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ClusterIntegrationForm', () => { let wrapper; @@ -19,7 +19,6 @@ describe('ClusterIntegrationForm', () => { const createWrapper = (storeValues = defaultStoreValues) => { wrapper = shallowMount(IntegrationForm, { - localVue, store: createStore(storeValues), provide: { autoDevopsHelpPath: 'topics/autodevops/index', diff --git a/spec/frontend/clusters_list/components/clusters_view_all_spec.js b/spec/frontend/clusters_list/components/clusters_view_all_spec.js index 6ef56beddee..81084443889 100644 --- a/spec/frontend/clusters_list/components/clusters_view_all_spec.js +++ b/spec/frontend/clusters_list/components/clusters_view_all_spec.js @@ -1,5 +1,5 @@ import { GlCard, GlLoadingIcon, GlButton, GlSprintf, GlBadge } from '@gitlab/ui'; -import { createLocalVue } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import ClustersViewAll from '~/clusters_list/components/clusters_view_all.vue'; @@ -16,8 +16,7 @@ import { } from '~/clusters_list/constants'; import { sprintf } from '~/locale'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const addClusterPath = '/path/to/add/cluster'; const defaultBranchName = 'default-branch'; @@ -59,7 +58,6 @@ describe('ClustersViewAllComponent', () => { const createWrapper = ({ initialState }) => { wrapper = shallowMountExtended(ClustersViewAll, { - localVue, store: createStore(initialState), propsData, provide: provideData, diff --git a/spec/frontend/code_navigation/components/app_spec.js b/spec/frontend/code_navigation/components/app_spec.js index 798f3bc0ee2..9306c15e676 100644 --- a/spec/frontend/code_navigation/components/app_spec.js +++ b/spec/frontend/code_navigation/components/app_spec.js @@ -1,15 +1,15 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import App from '~/code_navigation/components/app.vue'; import Popover from '~/code_navigation/components/popover.vue'; import createState from '~/code_navigation/store/state'; -const localVue = createLocalVue(); const fetchData = jest.fn(); const showDefinition = jest.fn(); let wrapper; -localVue.use(Vuex); +Vue.use(Vuex); function factory(initialState = {}) { const store = new Vuex.Store({ @@ -24,7 +24,7 @@ function factory(initialState = {}) { }, }); - wrapper = shallowMount(App, { store, localVue }); + wrapper = shallowMount(App, { store }); } describe('Code navigation app component', () => { diff --git a/spec/frontend/create_cluster/eks_cluster/components/create_eks_cluster_spec.js b/spec/frontend/create_cluster/eks_cluster/components/create_eks_cluster_spec.js index 95810e882a1..c8020cf8308 100644 --- a/spec/frontend/create_cluster/eks_cluster/components/create_eks_cluster_spec.js +++ b/spec/frontend/create_cluster/eks_cluster/components/create_eks_cluster_spec.js @@ -1,12 +1,12 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import CreateEksCluster from '~/create_cluster/eks_cluster/components/create_eks_cluster.vue'; import EksClusterConfigurationForm from '~/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue'; import ServiceCredentialsForm from '~/create_cluster/eks_cluster/components/service_credentials_form.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('CreateEksCluster', () => { let vm; @@ -33,7 +33,6 @@ describe('CreateEksCluster', () => { externalLinkIcon, kubernetesIntegrationHelpPath, }, - localVue, store, }); }); diff --git a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js b/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js index 53a6f12c381..8b8791a6b2b 100644 --- a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js +++ b/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js @@ -1,5 +1,5 @@ import { GlFormCheckbox } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; @@ -7,8 +7,7 @@ import EksClusterConfigurationForm from '~/create_cluster/eks_cluster/components import eksClusterFormState from '~/create_cluster/eks_cluster/store/state'; import clusterDropdownStoreState from '~/create_cluster/store/cluster_dropdown/state'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('EksClusterConfigurationForm', () => { let store; @@ -151,7 +150,6 @@ describe('EksClusterConfigurationForm', () => { const buildWrapper = () => { vm = shallowMount(EksClusterConfigurationForm, { - localVue, store, propsData: { gitlabManagedClusterHelpPath: '', diff --git a/spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js b/spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js index a0510d46794..a5ac7d5187b 100644 --- a/spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js +++ b/spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js @@ -1,11 +1,11 @@ import { GlButton } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import ServiceCredentialsForm from '~/create_cluster/eks_cluster/components/service_credentials_form.vue'; import eksClusterState from '~/create_cluster/eks_cluster/store/state'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ServiceCredentialsForm', () => { let vm; @@ -33,7 +33,6 @@ describe('ServiceCredentialsForm', () => { createRoleArnHelpPath: '', externalLinkIcon: '', }, - localVue, store, }); }); diff --git a/spec/frontend/create_cluster/gke_cluster/components/gke_machine_type_dropdown_spec.js b/spec/frontend/create_cluster/gke_cluster/components/gke_machine_type_dropdown_spec.js index 2b6f2134553..c2cd2104551 100644 --- a/spec/frontend/create_cluster/gke_cluster/components/gke_machine_type_dropdown_spec.js +++ b/spec/frontend/create_cluster/gke_cluster/components/gke_machine_type_dropdown_spec.js @@ -1,4 +1,5 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import GkeMachineTypeDropdown from '~/create_cluster/gke_cluster/components/gke_machine_type_dropdown.vue'; import createState from '~/create_cluster/gke_cluster/store/state'; @@ -19,15 +20,12 @@ const LABELS = { DEFAULT: 'Select machine type', }; -const localVue = createLocalVue(); - -localVue.use(Vuex); +Vue.use(Vuex); const createComponent = (store, propsData = componentConfig) => shallowMount(GkeMachineTypeDropdown, { propsData, store, - localVue, }); const createStore = (initialState = {}, getters = {}) => diff --git a/spec/frontend/create_cluster/gke_cluster/components/gke_network_dropdown_spec.js b/spec/frontend/create_cluster/gke_cluster/components/gke_network_dropdown_spec.js index 23a56766037..addb0ef72a0 100644 --- a/spec/frontend/create_cluster/gke_cluster/components/gke_network_dropdown_spec.js +++ b/spec/frontend/create_cluster/gke_cluster/components/gke_network_dropdown_spec.js @@ -1,12 +1,11 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import ClusterFormDropdown from '~/create_cluster/components/cluster_form_dropdown.vue'; import GkeNetworkDropdown from '~/create_cluster/gke_cluster/components/gke_network_dropdown.vue'; import createClusterDropdownState from '~/create_cluster/store/cluster_dropdown/state'; -const localVue = createLocalVue(); - -localVue.use(Vuex); +Vue.use(Vuex); describe('GkeNetworkDropdown', () => { let wrapper; @@ -54,7 +53,6 @@ describe('GkeNetworkDropdown', () => { shallowMount(GkeNetworkDropdown, { propsData, store, - localVue, }); afterEach(() => { diff --git a/spec/frontend/create_cluster/gke_cluster/components/gke_project_id_dropdown_spec.js b/spec/frontend/create_cluster/gke_cluster/components/gke_project_id_dropdown_spec.js index 2b0acc8cf5d..84ae263f2c5 100644 --- a/spec/frontend/create_cluster/gke_cluster/components/gke_project_id_dropdown_spec.js +++ b/spec/frontend/create_cluster/gke_cluster/components/gke_project_id_dropdown_spec.js @@ -1,4 +1,5 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import GkeProjectIdDropdown from '~/create_cluster/gke_cluster/components/gke_project_id_dropdown.vue'; import createState from '~/create_cluster/gke_cluster/store/state'; @@ -19,9 +20,7 @@ const LABELS = { EMPTY: 'No projects found', }; -const localVue = createLocalVue(); - -localVue.use(Vuex); +Vue.use(Vuex); describe('GkeProjectIdDropdown', () => { let wrapper; @@ -52,7 +51,6 @@ describe('GkeProjectIdDropdown', () => { shallowMount(GkeProjectIdDropdown, { propsData, store, - localVue, }); const bootstrap = (initialState, getters) => { diff --git a/spec/frontend/create_cluster/gke_cluster/components/gke_submit_button_spec.js b/spec/frontend/create_cluster/gke_cluster/components/gke_submit_button_spec.js index 014ed6013bd..2bf9158628c 100644 --- a/spec/frontend/create_cluster/gke_cluster/components/gke_submit_button_spec.js +++ b/spec/frontend/create_cluster/gke_cluster/components/gke_submit_button_spec.js @@ -1,10 +1,9 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import GkeSubmitButton from '~/create_cluster/gke_cluster/components/gke_submit_button.vue'; -const localVue = createLocalVue(); - -localVue.use(Vuex); +Vue.use(Vuex); describe('GkeSubmitButton', () => { let wrapper; @@ -21,7 +20,6 @@ describe('GkeSubmitButton', () => { const buildWrapper = () => shallowMount(GkeSubmitButton, { store, - localVue, }); const bootstrap = () => { diff --git a/spec/frontend/create_cluster/gke_cluster/components/gke_subnetwork_dropdown_spec.js b/spec/frontend/create_cluster/gke_cluster/components/gke_subnetwork_dropdown_spec.js index cfa8a678a9b..9df680d94b5 100644 --- a/spec/frontend/create_cluster/gke_cluster/components/gke_subnetwork_dropdown_spec.js +++ b/spec/frontend/create_cluster/gke_cluster/components/gke_subnetwork_dropdown_spec.js @@ -1,12 +1,11 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import ClusterFormDropdown from '~/create_cluster/components/cluster_form_dropdown.vue'; import GkeSubnetworkDropdown from '~/create_cluster/gke_cluster/components/gke_subnetwork_dropdown.vue'; import createClusterDropdownState from '~/create_cluster/store/cluster_dropdown/state'; -const localVue = createLocalVue(); - -localVue.use(Vuex); +Vue.use(Vuex); describe('GkeSubnetworkDropdown', () => { let wrapper; @@ -41,7 +40,6 @@ describe('GkeSubnetworkDropdown', () => { shallowMount(GkeSubnetworkDropdown, { propsData, store, - localVue, }); afterEach(() => { diff --git a/spec/frontend/cycle_analytics/filter_bar_spec.js b/spec/frontend/cycle_analytics/filter_bar_spec.js index 407f21bd956..5112b038e7c 100644 --- a/spec/frontend/cycle_analytics/filter_bar_spec.js +++ b/spec/frontend/cycle_analytics/filter_bar_spec.js @@ -1,4 +1,5 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import Vuex from 'vuex'; @@ -15,8 +16,7 @@ import * as utils from '~/vue_shared/components/filtered_search_bar/filtered_sea import initialFiltersState from '~/vue_shared/components/filtered_search_bar/store/modules/filters/state'; import UrlSync from '~/vue_shared/components/url_sync.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const milestoneTokenType = 'milestone'; const labelsTokenType = 'labels'; @@ -77,7 +77,6 @@ describe('Filter bar', () => { const createComponent = (initialStore) => { return shallowMount(FilterBar, { - localVue, store: initialStore, propsData: { groupPath: 'foo', diff --git a/spec/frontend/deploy_freeze/components/deploy_freeze_settings_spec.js b/spec/frontend/deploy_freeze/components/deploy_freeze_settings_spec.js index 392652292cf..cc044800e5e 100644 --- a/spec/frontend/deploy_freeze/components/deploy_freeze_settings_spec.js +++ b/spec/frontend/deploy_freeze/components/deploy_freeze_settings_spec.js @@ -1,4 +1,5 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import DeployFreezeModal from '~/deploy_freeze/components/deploy_freeze_modal.vue'; import DeployFreezeSettings from '~/deploy_freeze/components/deploy_freeze_settings.vue'; @@ -6,8 +7,7 @@ import DeployFreezeTable from '~/deploy_freeze/components/deploy_freeze_table.vu import createStore from '~/deploy_freeze/store'; import { timezoneDataFixture } from '../helpers'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Deploy freeze settings', () => { let wrapper; @@ -20,7 +20,6 @@ describe('Deploy freeze settings', () => { }); jest.spyOn(store, 'dispatch').mockImplementation(); wrapper = shallowMount(DeployFreezeSettings, { - localVue, store, }); }); diff --git a/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js b/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js index 403d0dce3fc..ada819b7e64 100644 --- a/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js +++ b/spec/frontend/deploy_freeze/components/deploy_freeze_table_spec.js @@ -1,13 +1,13 @@ import { GlModal } from '@gitlab/ui'; -import { createLocalVue, mount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import DeployFreezeTable from '~/deploy_freeze/components/deploy_freeze_table.vue'; import createStore from '~/deploy_freeze/store'; import { RECEIVE_FREEZE_PERIODS_SUCCESS } from '~/deploy_freeze/store/mutation_types'; import { freezePeriodsFixture, timezoneDataFixture } from '../helpers'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Deploy freeze table', () => { let wrapper; @@ -21,7 +21,6 @@ describe('Deploy freeze table', () => { jest.spyOn(store, 'dispatch').mockImplementation(); wrapper = mount(DeployFreezeTable, { attachTo: document.body, - localVue, store, }); }; diff --git a/spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js b/spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js index 5f4d4071f29..aea81daecef 100644 --- a/spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js +++ b/spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js @@ -1,12 +1,12 @@ import { GlDropdownItem, GlDropdown } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import createStore from '~/deploy_freeze/store'; import TimezoneDropdown from '~/vue_shared/components/timezone_dropdown.vue'; import { findTzByName, formatTz, timezoneDataFixture } from '../helpers'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Deploy freeze timezone dropdown', () => { let wrapper; @@ -19,7 +19,6 @@ describe('Deploy freeze timezone dropdown', () => { }); wrapper = shallowMount(TimezoneDropdown, { store, - localVue, propsData: { value: selectedTimezone, timezoneData: timezoneDataFixture, diff --git a/spec/frontend/design_management/components/list/item_spec.js b/spec/frontend/design_management/components/list/item_spec.js index ed105b112be..92cb35bd8d6 100644 --- a/spec/frontend/design_management/components/list/item_spec.js +++ b/spec/frontend/design_management/components/list/item_spec.js @@ -1,11 +1,11 @@ import { GlIcon, GlLoadingIcon, GlIntersectionObserver } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import VueRouter from 'vue-router'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import Item from '~/design_management/components/list/item.vue'; -const localVue = createLocalVue(); -localVue.use(VueRouter); +Vue.use(VueRouter); const router = new VueRouter(); // Referenced from: gitlab_schema.graphql:DesignVersionEvent @@ -34,7 +34,6 @@ describe('Design management list item component', () => { } = {}) { wrapper = extendedWrapper( shallowMount(Item, { - localVue, router, propsData: { id: imgId, diff --git a/spec/frontend/design_management/components/toolbar/index_spec.js b/spec/frontend/design_management/components/toolbar/index_spec.js index cf872046f53..804b55bda38 100644 --- a/spec/frontend/design_management/components/toolbar/index_spec.js +++ b/spec/frontend/design_management/components/toolbar/index_spec.js @@ -1,12 +1,12 @@ import { GlButton } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import VueRouter from 'vue-router'; import DeleteButton from '~/design_management/components/delete_button.vue'; import Toolbar from '~/design_management/components/toolbar/index.vue'; import { DESIGNS_ROUTE_NAME } from '~/design_management/router/constants'; -const localVue = createLocalVue(); -localVue.use(VueRouter); +Vue.use(VueRouter); const router = new VueRouter(); const RouterLinkStub = { @@ -28,7 +28,6 @@ describe('Design management toolbar component', () => { updatedAt.setHours(updatedAt.getHours() - 1); wrapper = shallowMount(Toolbar, { - localVue, router, propsData: { id: '1', diff --git a/spec/frontend/design_management/pages/design/index_spec.js b/spec/frontend/design_management/pages/design/index_spec.js index 98e2313e9f2..4477bf4b8e6 100644 --- a/spec/frontend/design_management/pages/design/index_spec.js +++ b/spec/frontend/design_management/pages/design/index_spec.js @@ -1,5 +1,6 @@ import { GlAlert } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import { ApolloMutation } from 'vue-apollo'; import VueRouter from 'vue-router'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; @@ -78,8 +79,7 @@ const createDiscussionMutationVariables = { }, }; -const localVue = createLocalVue(); -localVue.use(VueRouter); +Vue.use(VueRouter); describe('Design management design index page', () => { let wrapper; @@ -128,7 +128,6 @@ describe('Design management design index page', () => { ...data, }; }, - localVue, router, }); } diff --git a/spec/frontend/design_management/router_spec.js b/spec/frontend/design_management/router_spec.js index ac5e6895408..03ab79712a4 100644 --- a/spec/frontend/design_management/router_spec.js +++ b/spec/frontend/design_management/router_spec.js @@ -1,5 +1,5 @@ -import { mount, createLocalVue } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { mount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import VueRouter from 'vue-router'; import App from '~/design_management/components/app.vue'; import DesignDetail from '~/design_management/pages/design/index.vue'; @@ -9,8 +9,7 @@ import { DESIGNS_ROUTE_NAME, DESIGN_ROUTE_NAME } from '~/design_management/route import '~/commons/bootstrap'; function factory(routeArg) { - const localVue = createLocalVue(); - localVue.use(VueRouter); + Vue.use(VueRouter); window.gon = { sprite_icons: '' }; @@ -20,7 +19,6 @@ function factory(routeArg) { } return mount(App, { - localVue, router, mocks: { $apollo: { diff --git a/spec/frontend/diffs/components/collapsed_files_warning_spec.js b/spec/frontend/diffs/components/collapsed_files_warning_spec.js index 46caeb01132..050d32413ad 100644 --- a/spec/frontend/diffs/components/collapsed_files_warning_spec.js +++ b/spec/frontend/diffs/components/collapsed_files_warning_spec.js @@ -1,5 +1,5 @@ -import { shallowMount, mount, createLocalVue } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { shallowMount, mount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import CollapsedFilesWarning from '~/diffs/components/collapsed_files_warning.vue'; import { CENTERED_LIMITED_CONTAINER_CLASSES, EVT_EXPAND_ALL_FILES } from '~/diffs/constants'; @@ -23,11 +23,10 @@ async function files(store, count) { } describe('CollapsedFilesWarning', () => { - const localVue = createLocalVue(); let store; let wrapper; - localVue.use(Vuex); + Vue.use(Vuex); const getAlertActionButton = () => wrapper.find(CollapsedFilesWarning).find('button.gl-alert-action:first-child'); @@ -43,7 +42,6 @@ describe('CollapsedFilesWarning', () => { wrapper = mounter(CollapsedFilesWarning, { propsData: { ...propsData, ...props }, - localVue, store, }); }; diff --git a/spec/frontend/diffs/components/compare_versions_spec.js b/spec/frontend/diffs/components/compare_versions_spec.js index c48935bc4f0..1ef927f5e9e 100644 --- a/spec/frontend/diffs/components/compare_versions_spec.js +++ b/spec/frontend/diffs/components/compare_versions_spec.js @@ -1,4 +1,5 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import getDiffWithCommit from 'test_fixtures/merge_request_diffs/with_commit.json'; import setWindowLocation from 'helpers/set_window_location_helper'; @@ -8,8 +9,7 @@ import CompareVersionsComponent from '~/diffs/components/compare_versions.vue'; import { createStore } from '~/mr_notes/stores'; import diffsMockData from '../mock_data/merge_request_diffs'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const NEXT_COMMIT_URL = `${TEST_HOST}/?commit_id=next`; const PREV_COMMIT_URL = `${TEST_HOST}/?commit_id=prev`; @@ -30,7 +30,6 @@ describe('CompareVersions', () => { } wrapper = mount(CompareVersionsComponent, { - localVue, store, propsData: { mergeRequestDiffs: diffsMockData, diff --git a/spec/frontend/diffs/components/diff_content_spec.js b/spec/frontend/diffs/components/diff_content_spec.js index 0a7dfc02c65..7d2afe105a5 100644 --- a/spec/frontend/diffs/components/diff_content_spec.js +++ b/spec/frontend/diffs/components/diff_content_spec.js @@ -1,5 +1,6 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import DiffContentComponent from '~/diffs/components/diff_content.vue'; import DiffDiscussions from '~/diffs/components/diff_discussions.vue'; @@ -11,8 +12,7 @@ import NoPreviewViewer from '~/vue_shared/components/diff_viewer/viewers/no_prev import NotDiffableViewer from '~/vue_shared/components/diff_viewer/viewers/not_diffable.vue'; import diffFileMockData from '../mock_data/diff_file'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('DiffContent', () => { let wrapper; @@ -88,7 +88,6 @@ describe('DiffContent', () => { ...defaultProps, ...props, }, - localVue, store: fakeStore, provide: { glFeatures }, }); diff --git a/spec/frontend/diffs/components/diff_discussion_reply_spec.js b/spec/frontend/diffs/components/diff_discussion_reply_spec.js index 9443a441ec2..f03c0357a0e 100644 --- a/spec/frontend/diffs/components/diff_discussion_reply_spec.js +++ b/spec/frontend/diffs/components/diff_discussion_reply_spec.js @@ -1,11 +1,11 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import DiffDiscussionReply from '~/diffs/components/diff_discussion_reply.vue'; import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue'; import NoteSignedOutWidget from '~/notes/components/note_signed_out_widget.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('DiffDiscussionReply', () => { let wrapper; @@ -15,7 +15,6 @@ describe('DiffDiscussionReply', () => { const createComponent = (props = {}, slots = {}) => { wrapper = shallowMount(DiffDiscussionReply, { store, - localVue, propsData: { ...props, }, diff --git a/spec/frontend/diffs/components/diff_discussions_spec.js b/spec/frontend/diffs/components/diff_discussions_spec.js index bd6f4cd2545..8d0c9b01188 100644 --- a/spec/frontend/diffs/components/diff_discussions_spec.js +++ b/spec/frontend/diffs/components/diff_discussions_spec.js @@ -1,5 +1,5 @@ import { GlIcon } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import DiffDiscussions from '~/diffs/components/diff_discussions.vue'; import { createStore } from '~/mr_notes/stores'; import DiscussionNotes from '~/notes/components/discussion_notes.vue'; @@ -8,8 +8,6 @@ import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item import '~/behaviors/markdown/render_gfm'; import discussionsMockData from '../mock_data/diff_discussions'; -const localVue = createLocalVue(); - describe('DiffDiscussions', () => { let store; let wrapper; @@ -17,13 +15,12 @@ describe('DiffDiscussions', () => { const createComponent = (props) => { store = createStore(); - wrapper = mount(localVue.extend(DiffDiscussions), { + wrapper = mount(DiffDiscussions, { store, propsData: { discussions: getDiscussionsMockData(), ...props, }, - localVue, }); }; diff --git a/spec/frontend/diffs/components/diff_file_header_spec.js b/spec/frontend/diffs/components/diff_file_header_spec.js index 342b4bfcc50..1beaae6e16d 100644 --- a/spec/frontend/diffs/components/diff_file_header_spec.js +++ b/spec/frontend/diffs/components/diff_file_header_spec.js @@ -1,4 +1,5 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import { cloneDeep } from 'lodash'; import Vuex from 'vuex'; @@ -37,8 +38,7 @@ const diffFile = Object.freeze( }), ); -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('DiffFileHeader component', () => { let wrapper; @@ -103,7 +103,6 @@ describe('DiffFileHeader component', () => { ...props, }, ...options, - localVue, store, }); }; diff --git a/spec/frontend/diffs/components/diff_file_spec.js b/spec/frontend/diffs/components/diff_file_spec.js index dc0ed621a64..e185b817fca 100644 --- a/spec/frontend/diffs/components/diff_file_spec.js +++ b/spec/frontend/diffs/components/diff_file_spec.js @@ -1,6 +1,6 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; -import { nextTick } from 'vue'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import DiffContentComponent from 'jh_else_ce/diffs/components/diff_content.vue'; @@ -70,9 +70,7 @@ function markFileToBeRendered(store, index = 0) { } function createComponent({ file, first = false, last = false, options = {}, props = {} }) { - const localVue = createLocalVue(); - - localVue.use(Vuex); + Vue.use(Vuex); const store = new Vuex.Store({ ...createNotesStore(), @@ -85,7 +83,6 @@ function createComponent({ file, first = false, last = false, options = {}, prop const wrapper = shallowMount(DiffFileComponent, { store, - localVue, propsData: { file, canCurrentUserFork: false, @@ -98,7 +95,6 @@ function createComponent({ file, first = false, last = false, options = {}, prop }); return { - localVue, wrapper, store, }; diff --git a/spec/frontend/diffs/components/no_changes_spec.js b/spec/frontend/diffs/components/no_changes_spec.js index 164c58dc8e4..6903b844e5e 100644 --- a/spec/frontend/diffs/components/no_changes_spec.js +++ b/spec/frontend/diffs/components/no_changes_spec.js @@ -1,12 +1,12 @@ import { GlButton } from '@gitlab/ui'; -import { createLocalVue, shallowMount, mount } from '@vue/test-utils'; +import { shallowMount, mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import NoChanges from '~/diffs/components/no_changes.vue'; import { createStore } from '~/mr_notes/stores'; import diffsMockData from '../mock_data/merge_request_diffs'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const TEST_TARGET_BRANCH = 'foo'; const TEST_SOURCE_BRANCH = 'dev/update'; @@ -17,7 +17,6 @@ describe('Diff no changes empty state', () => { function createComponent(mountFn = shallowMount) { wrapper = mountFn(NoChanges, { - localVue, store, propsData: { changesEmptyStateIllustration: '', diff --git a/spec/frontend/diffs/components/tree_list_spec.js b/spec/frontend/diffs/components/tree_list_spec.js index 31044b0818c..f03792295df 100644 --- a/spec/frontend/diffs/components/tree_list_spec.js +++ b/spec/frontend/diffs/components/tree_list_spec.js @@ -1,4 +1,5 @@ -import { shallowMount, mount, createLocalVue } from '@vue/test-utils'; +import { shallowMount, mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import TreeList from '~/diffs/components/tree_list.vue'; import createStore from '~/diffs/store/modules'; @@ -8,13 +9,11 @@ describe('Diffs tree list component', () => { let wrapper; let store; const getFileRows = () => wrapper.findAll('.file-row'); - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); const createComponent = (mountFn = mount) => { wrapper = mountFn(TreeList, { store, - localVue, propsData: { hideFileStats: false }, }); }; diff --git a/spec/frontend/error_tracking/components/error_details_spec.js b/spec/frontend/error_tracking/components/error_details_spec.js index 77f51193258..02baa31289e 100644 --- a/spec/frontend/error_tracking/components/error_details_spec.js +++ b/spec/frontend/error_tracking/components/error_details_spec.js @@ -7,7 +7,8 @@ import { GlAlert, GlSprintf, } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { severityLevel, @@ -27,8 +28,7 @@ import Tracking from '~/tracking'; jest.mock('~/flash'); -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ErrorDetails', () => { let store; @@ -53,7 +53,6 @@ describe('ErrorDetails', () => { function mountComponent() { wrapper = shallowMount(ErrorDetails, { stubs: { GlButton, GlSprintf }, - localVue, store, mocks, propsData: { diff --git a/spec/frontend/error_tracking/components/error_tracking_list_spec.js b/spec/frontend/error_tracking/components/error_tracking_list_spec.js index 74d5731bbea..fc89e778127 100644 --- a/spec/frontend/error_tracking/components/error_tracking_list_spec.js +++ b/spec/frontend/error_tracking/components/error_tracking_list_spec.js @@ -1,5 +1,6 @@ import { GlEmptyState, GlLoadingIcon, GlFormInput, GlPagination, GlDropdown } from '@gitlab/ui'; -import { createLocalVue, mount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import stubChildren from 'helpers/stub_children'; import ErrorTrackingActions from '~/error_tracking/components/error_tracking_actions.vue'; @@ -8,8 +9,7 @@ import { trackErrorListViewsOptions, trackErrorStatusUpdateOptions } from '~/err import Tracking from '~/tracking'; import errorsList from './list_mock.json'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ErrorTrackingList', () => { let store; @@ -32,7 +32,6 @@ describe('ErrorTrackingList', () => { stubs = {}, } = {}) { wrapper = mount(ErrorTrackingList, { - localVue, store, propsData: { indexPath: '/path', diff --git a/spec/frontend/error_tracking_settings/components/app_spec.js b/spec/frontend/error_tracking_settings/components/app_spec.js index 844faff64a1..a67e927910e 100644 --- a/spec/frontend/error_tracking_settings/components/app_spec.js +++ b/spec/frontend/error_tracking_settings/components/app_spec.js @@ -1,6 +1,6 @@ import { GlFormRadioGroup, GlFormRadio, GlFormInputGroup } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { shallowMount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import ClipboardButton from '~/vue_shared/components/clipboard_button.vue'; import { TEST_HOST } from 'helpers/test_constants'; @@ -10,8 +10,7 @@ import ErrorTrackingForm from '~/error_tracking_settings/components/error_tracki import ProjectDropdown from '~/error_tracking_settings/components/project_dropdown.vue'; import createStore from '~/error_tracking_settings/store'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const TEST_GITLAB_DSN = 'https://gitlab.example.com/123456'; @@ -22,7 +21,6 @@ describe('error tracking settings app', () => { function mountComponent() { wrapper = extendedWrapper( shallowMount(ErrorTrackingSettings, { - localVue, store, // Override the imported store propsData: { initialEnabled: 'true', diff --git a/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js b/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js index 2e8a42dbfe6..69d684faec2 100644 --- a/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js +++ b/spec/frontend/error_tracking_settings/components/error_tracking_form_spec.js @@ -1,12 +1,12 @@ import { GlFormInput, GlButton } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import ErrorTrackingForm from '~/error_tracking_settings/components/error_tracking_form.vue'; import createStore from '~/error_tracking_settings/store'; import { defaultProps } from '../mock'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('error tracking settings form', () => { let wrapper; @@ -14,7 +14,6 @@ describe('error tracking settings form', () => { function mountComponent() { wrapper = shallowMount(ErrorTrackingForm, { - localVue, store, propsData: defaultProps, }); diff --git a/spec/frontend/error_tracking_settings/components/project_dropdown_spec.js b/spec/frontend/error_tracking_settings/components/project_dropdown_spec.js index 79518a487d4..bf33d76d834 100644 --- a/spec/frontend/error_tracking_settings/components/project_dropdown_spec.js +++ b/spec/frontend/error_tracking_settings/components/project_dropdown_spec.js @@ -1,19 +1,18 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import { pick, clone } from 'lodash'; import Vuex from 'vuex'; import ProjectDropdown from '~/error_tracking_settings/components/project_dropdown.vue'; import { defaultProps, projectList, staleProject } from '../mock'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('error tracking settings project dropdown', () => { let wrapper; function mountComponent() { wrapper = shallowMount(ProjectDropdown, { - localVue, propsData: { ...pick( defaultProps, diff --git a/spec/frontend/feature_flags/components/feature_flags_spec.js b/spec/frontend/feature_flags/components/feature_flags_spec.js index db4bdc736de..141db7c0eb3 100644 --- a/spec/frontend/feature_flags/components/feature_flags_spec.js +++ b/spec/frontend/feature_flags/components/feature_flags_spec.js @@ -1,5 +1,6 @@ import { GlAlert, GlEmptyState, GlLoadingIcon } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import Vuex from 'vuex'; import waitForPromises from 'helpers/wait_for_promises'; @@ -13,8 +14,7 @@ import axios from '~/lib/utils/axios_utils'; import TablePagination from '~/vue_shared/components/pagination/table_pagination.vue'; import { getRequestData } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Feature flags', () => { const mockData = { @@ -45,7 +45,6 @@ describe('Feature flags', () => { const factory = (provide = mockData, fn = mount) => { store = createStore(mockState); wrapper = fn(FeatureFlagsComponent, { - localVue, store, provide, stubs: { diff --git a/spec/frontend/feature_flags/components/new_feature_flag_spec.js b/spec/frontend/feature_flags/components/new_feature_flag_spec.js index fe98b6421d4..f14c674353b 100644 --- a/spec/frontend/feature_flags/components/new_feature_flag_spec.js +++ b/spec/frontend/feature_flags/components/new_feature_flag_spec.js @@ -1,5 +1,6 @@ import { GlAlert } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { TEST_HOST } from 'spec/test_constants'; import Form from '~/feature_flags/components/form.vue'; @@ -10,8 +11,7 @@ import { allUsersStrategy } from '../mock_data'; const userCalloutId = 'feature_flags_new_version'; const userCalloutsPath = `${TEST_HOST}/user_callouts`; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('New feature flag form', () => { let wrapper; @@ -27,7 +27,6 @@ describe('New feature flag form', () => { wrapper = null; } wrapper = shallowMount(NewFeatureFlag, { - localVue, store, provide: { showUserCallout: true, diff --git a/spec/frontend/feature_flags/components/strategies/gitlab_user_list_spec.js b/spec/frontend/feature_flags/components/strategies/gitlab_user_list_spec.js index 6188672b23b..ebfcba6316b 100644 --- a/spec/frontend/feature_flags/components/strategies/gitlab_user_list_spec.js +++ b/spec/frontend/feature_flags/components/strategies/gitlab_user_list_spec.js @@ -1,5 +1,6 @@ import { GlDropdown, GlDropdownItem, GlSearchBoxByType, GlLoadingIcon } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import Api from '~/api'; import GitlabUserList from '~/feature_flags/components/strategies/gitlab_user_list.vue'; @@ -12,15 +13,13 @@ const DEFAULT_PROPS = { strategy: userListStrategy, }; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('~/feature_flags/components/strategies/gitlab_user_list.vue', () => { let wrapper; const factory = (props = {}) => mount(GitlabUserList, { - localVue, store: createStore({ projectId: '1' }), propsData: { ...DEFAULT_PROPS, ...props }, }); diff --git a/spec/frontend/feature_flags/components/strategy_spec.js b/spec/frontend/feature_flags/components/strategy_spec.js index 4fdf436bfc4..2464583b636 100644 --- a/spec/frontend/feature_flags/components/strategy_spec.js +++ b/spec/frontend/feature_flags/components/strategy_spec.js @@ -1,5 +1,6 @@ import { GlAlert, GlFormSelect, GlLink, GlToken, GlButton } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import { last } from 'lodash'; import Vuex from 'vuex'; import Api from '~/api'; @@ -26,8 +27,7 @@ const provide = { environmentsEndpoint: '', }; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Feature flags strategy', () => { let wrapper; @@ -48,7 +48,7 @@ describe('Feature flags strategy', () => { wrapper.destroy(); wrapper = null; } - wrapper = mount(Strategy, { localVue, store: createStore({ projectId: '1' }), ...opts }); + wrapper = mount(Strategy, { store: createStore({ projectId: '1' }), ...opts }); }; beforeEach(() => { diff --git a/spec/frontend/frequent_items/components/frequent_items_list_item_spec.js b/spec/frontend/frequent_items/components/frequent_items_list_item_spec.js index 5a05265afdc..8220ea16342 100644 --- a/spec/frontend/frequent_items/components/frequent_items_list_item_spec.js +++ b/spec/frontend/frequent_items/components/frequent_items_list_item_spec.js @@ -1,5 +1,6 @@ import { GlButton } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { trimText } from 'helpers/text_helper'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; @@ -8,8 +9,7 @@ import { createStore } from '~/frequent_items/store'; import ProjectAvatar from '~/vue_shared/components/project_avatar.vue'; import { mockProject } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('FrequentItemsListItemComponent', () => { let wrapper; @@ -40,7 +40,6 @@ describe('FrequentItemsListItemComponent', () => { provide: { vuexModule: 'frequentProjects', }, - localVue, }); }; diff --git a/spec/frontend/frequent_items/components/frequent_items_list_spec.js b/spec/frontend/frequent_items/components/frequent_items_list_spec.js index c015914c991..5d09a588b1d 100644 --- a/spec/frontend/frequent_items/components/frequent_items_list_spec.js +++ b/spec/frontend/frequent_items/components/frequent_items_list_spec.js @@ -1,12 +1,12 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import frequentItemsListComponent from '~/frequent_items/components/frequent_items_list.vue'; import frequentItemsListItemComponent from '~/frequent_items/components/frequent_items_list_item.vue'; import { createStore } from '~/frequent_items/store'; import { mockFrequentProjects } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('FrequentItemsListComponent', () => { let wrapper; @@ -22,7 +22,6 @@ describe('FrequentItemsListComponent', () => { matcher: 'lab', ...props, }, - localVue, provide: { vuexModule: 'frequentProjects', }, diff --git a/spec/frontend/frequent_items/components/frequent_items_search_input_spec.js b/spec/frontend/frequent_items/components/frequent_items_search_input_spec.js index c9b7e0f3d13..e1e2a42d330 100644 --- a/spec/frontend/frequent_items/components/frequent_items_search_input_spec.js +++ b/spec/frontend/frequent_items/components/frequent_items_search_input_spec.js @@ -1,12 +1,12 @@ import { GlSearchBoxByType } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import searchComponent from '~/frequent_items/components/frequent_items_search_input.vue'; import { createStore } from '~/frequent_items/store'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('FrequentItemsSearchInputComponent', () => { let wrapper; @@ -18,7 +18,6 @@ describe('FrequentItemsSearchInputComponent', () => { shallowMount(searchComponent, { store, propsData: { namespace }, - localVue, provide: { vuexModule: 'frequentProjects', }, diff --git a/spec/frontend/ide/components/branches/search_list_spec.js b/spec/frontend/ide/components/branches/search_list_spec.js index 0efa7af2c6c..35e006a26ce 100644 --- a/spec/frontend/ide/components/branches/search_list_spec.js +++ b/spec/frontend/ide/components/branches/search_list_spec.js @@ -1,13 +1,13 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import Item from '~/ide/components/branches/item.vue'; import List from '~/ide/components/branches/search_list.vue'; import { __ } from '~/locale'; import { branches } from '../../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IDE branches search list', () => { let wrapper; @@ -31,7 +31,6 @@ describe('IDE branches search list', () => { }); wrapper = shallowMount(List, { - localVue, store: fakeStore, }); }; diff --git a/spec/frontend/ide/components/commit_sidebar/editor_header_spec.js b/spec/frontend/ide/components/commit_sidebar/editor_header_spec.js index 50635ffe894..6e4c66cb780 100644 --- a/spec/frontend/ide/components/commit_sidebar/editor_header_spec.js +++ b/spec/frontend/ide/components/commit_sidebar/editor_header_spec.js @@ -1,11 +1,11 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import EditorHeader from '~/ide/components/commit_sidebar/editor_header.vue'; import { createStore } from '~/ide/stores'; import { file } from '../../helpers'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const TEST_FILE_PATH = 'test/file/path'; @@ -16,7 +16,6 @@ describe('IDE commit editor header', () => { const createComponent = (fileProps = {}) => { wrapper = mount(EditorHeader, { store, - localVue, propsData: { activeFile: { ...file(TEST_FILE_PATH), diff --git a/spec/frontend/ide/components/error_message_spec.js b/spec/frontend/ide/components/error_message_spec.js index 2de3fa863a8..28278aa656f 100644 --- a/spec/frontend/ide/components/error_message_spec.js +++ b/spec/frontend/ide/components/error_message_spec.js @@ -1,10 +1,10 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import ErrorMessage from '~/ide/components/error_message.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IDE error message component', () => { let wrapper; @@ -25,7 +25,6 @@ describe('IDE error message component', () => { }, }, store: fakeStore, - localVue, }); }; diff --git a/spec/frontend/ide/components/file_templates/dropdown_spec.js b/spec/frontend/ide/components/file_templates/dropdown_spec.js index 44ac9aa954d..426a65dd918 100644 --- a/spec/frontend/ide/components/file_templates/dropdown_spec.js +++ b/spec/frontend/ide/components/file_templates/dropdown_spec.js @@ -1,11 +1,11 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import $ from 'jquery'; import Vuex from 'vuex'; import Dropdown from '~/ide/components/file_templates/dropdown.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IDE file templates dropdown component', () => { let wrapper; @@ -44,7 +44,6 @@ describe('IDE file templates dropdown component', () => { ...props, }, store: fakeStore, - localVue, }); ({ element } = wrapper); diff --git a/spec/frontend/ide/components/ide_file_row_spec.js b/spec/frontend/ide/components/ide_file_row_spec.js index 20c105460f2..5f287078aa1 100644 --- a/spec/frontend/ide/components/ide_file_row_spec.js +++ b/spec/frontend/ide/components/ide_file_row_spec.js @@ -1,12 +1,12 @@ -import { createLocalVue, mount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import FileRowExtra from '~/ide/components/file_row_extra.vue'; import IdeFileRow from '~/ide/components/ide_file_row.vue'; import { createStore } from '~/ide/stores'; import FileRow from '~/vue_shared/components/file_row.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const TEST_EXTRA_PROPS = { testattribute: 'abc', @@ -30,7 +30,6 @@ describe('Ide File Row component', () => { ...props, }, store: createStore(), - localVue, ...options, }); }; diff --git a/spec/frontend/ide/components/ide_review_spec.js b/spec/frontend/ide/components/ide_review_spec.js index 7a92f59641f..47270b6e1e9 100644 --- a/spec/frontend/ide/components/ide_review_spec.js +++ b/spec/frontend/ide/components/ide_review_spec.js @@ -1,4 +1,4 @@ -import { createLocalVue, mount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; import { keepAlive } from 'helpers/keep_alive_component_helper'; @@ -9,8 +9,7 @@ import { createStore } from '~/ide/stores'; import { file } from '../helpers'; import { projectData } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IDE review mode', () => { let wrapper; @@ -28,7 +27,6 @@ describe('IDE review mode', () => { wrapper = mount(keepAlive(IdeReview), { store, - localVue, }); }); diff --git a/spec/frontend/ide/components/ide_side_bar_spec.js b/spec/frontend/ide/components/ide_side_bar_spec.js index c683612b142..af8f6b79c7f 100644 --- a/spec/frontend/ide/components/ide_side_bar_spec.js +++ b/spec/frontend/ide/components/ide_side_bar_spec.js @@ -1,5 +1,6 @@ import { GlSkeletonLoading } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import waitForPromises from 'helpers/wait_for_promises'; import IdeReview from '~/ide/components/ide_review.vue'; @@ -10,8 +11,7 @@ import { leftSidebarViews } from '~/ide/constants'; import { createStore } from '~/ide/stores'; import { projectData } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IdeSidebar', () => { let wrapper; @@ -26,7 +26,6 @@ describe('IdeSidebar', () => { return mount(IdeSidebar, { store, - localVue, }); } diff --git a/spec/frontend/ide/components/ide_spec.js b/spec/frontend/ide/components/ide_spec.js index f8d29fc7b47..37b42001a80 100644 --- a/spec/frontend/ide/components/ide_spec.js +++ b/spec/frontend/ide/components/ide_spec.js @@ -1,4 +1,5 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import waitForPromises from 'helpers/wait_for_promises'; import CannotPushCodeAlert from '~/ide/components/cannot_push_code_alert.vue'; @@ -9,8 +10,7 @@ import { createStore } from '~/ide/stores'; import { file } from '../helpers'; import { projectData } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const TEST_FORK_IDE_PATH = '/test/ide/path'; @@ -34,7 +34,6 @@ describe('WebIDE', () => { wrapper = shallowMount(Ide, { store, - localVue, }); }; diff --git a/spec/frontend/ide/components/ide_status_list_spec.js b/spec/frontend/ide/components/ide_status_list_spec.js index 036edfb3ec1..371fbc6becd 100644 --- a/spec/frontend/ide/components/ide_status_list_spec.js +++ b/spec/frontend/ide/components/ide_status_list_spec.js @@ -1,5 +1,6 @@ import { GlLink } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import IdeStatusList from '~/ide/components/ide_status_list.vue'; import TerminalSyncStatusSafe from '~/ide/components/terminal_sync/terminal_sync_status_safe.vue'; @@ -16,8 +17,7 @@ const TEST_FILE_EDITOR = { }; const TEST_EDITOR_POSITION = `${TEST_FILE_EDITOR.editorRow}:${TEST_FILE_EDITOR.editorColumn}`; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ide/components/ide_status_list', () => { let activeFileEditor; @@ -42,7 +42,6 @@ describe('ide/components/ide_status_list', () => { }); wrapper = shallowMount(IdeStatusList, { - localVue, store, ...options, }); diff --git a/spec/frontend/ide/components/ide_tree_spec.js b/spec/frontend/ide/components/ide_tree_spec.js index 0792b88aeb6..8465ef9f5f3 100644 --- a/spec/frontend/ide/components/ide_tree_spec.js +++ b/spec/frontend/ide/components/ide_tree_spec.js @@ -1,4 +1,4 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; import { keepAlive } from 'helpers/keep_alive_component_helper'; @@ -7,8 +7,7 @@ import { createStore } from '~/ide/stores'; import { file } from '../helpers'; import { projectData } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IdeTree', () => { let store; @@ -27,7 +26,6 @@ describe('IdeTree', () => { wrapper = mount(keepAlive(IdeTree), { store, - localVue, }); }); diff --git a/spec/frontend/ide/components/jobs/list_spec.js b/spec/frontend/ide/components/jobs/list_spec.js index 8797e07aef1..cb2c9f8f04f 100644 --- a/spec/frontend/ide/components/jobs/list_spec.js +++ b/spec/frontend/ide/components/jobs/list_spec.js @@ -1,11 +1,11 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount, mount, createLocalVue } from '@vue/test-utils'; +import { shallowMount, mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import StageList from '~/ide/components/jobs/list.vue'; import Stage from '~/ide/components/jobs/stage.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const storeActions = { fetchJobs: jest.fn(), toggleStageCollapsed: jest.fn(), @@ -42,7 +42,6 @@ describe('IDE stages list', () => { ...defaultProps, ...props, }, - localVue, store, }); }; @@ -92,7 +91,6 @@ describe('IDE stages list', () => { wrapper = mount(StageList, { propsData: { ...defaultProps, stages }, store, - localVue, }); }); diff --git a/spec/frontend/ide/components/merge_requests/item_spec.js b/spec/frontend/ide/components/merge_requests/item_spec.js index f0a97a0b10a..d6cf8127b53 100644 --- a/spec/frontend/ide/components/merge_requests/item_spec.js +++ b/spec/frontend/ide/components/merge_requests/item_spec.js @@ -1,4 +1,5 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import Item from '~/ide/components/merge_requests/item.vue'; import { createRouter } from '~/ide/ide_router'; @@ -11,8 +12,7 @@ const TEST_ITEM = { }; describe('IDE merge request item', () => { - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); let wrapper; let store; @@ -28,7 +28,6 @@ describe('IDE merge request item', () => { currentProjectId: TEST_ITEM.projectPathWithNamespace, ...props, }, - localVue, router, store, }); diff --git a/spec/frontend/ide/components/merge_requests/list_spec.js b/spec/frontend/ide/components/merge_requests/list_spec.js index 610e20d5868..81c7321b22c 100644 --- a/spec/frontend/ide/components/merge_requests/list_spec.js +++ b/spec/frontend/ide/components/merge_requests/list_spec.js @@ -1,13 +1,13 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import Item from '~/ide/components/merge_requests/item.vue'; import List from '~/ide/components/merge_requests/list.vue'; import TokenedInput from '~/ide/components/shared/tokened_input.vue'; import { mergeRequests as mergeRequestsMock } from '../../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IDE merge requests list', () => { let wrapper; @@ -41,7 +41,6 @@ describe('IDE merge requests list', () => { wrapper = shallowMount(List, { store: fakeStore, - localVue, }); }; diff --git a/spec/frontend/ide/components/panes/collapsible_sidebar_spec.js b/spec/frontend/ide/components/panes/collapsible_sidebar_spec.js index 7216f50b05c..7f2ee0fe7d9 100644 --- a/spec/frontend/ide/components/panes/collapsible_sidebar_spec.js +++ b/spec/frontend/ide/components/panes/collapsible_sidebar_spec.js @@ -1,12 +1,12 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import IdeSidebarNav from '~/ide/components/ide_sidebar_nav.vue'; import CollapsibleSidebar from '~/ide/components/panes/collapsible_sidebar.vue'; import { createStore } from '~/ide/stores'; import paneModule from '~/ide/stores/modules/pane'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ide/components/panes/collapsible_sidebar.vue', () => { let wrapper; @@ -17,7 +17,6 @@ describe('ide/components/panes/collapsible_sidebar.vue', () => { const createComponent = (props) => { wrapper = shallowMount(CollapsibleSidebar, { - localVue, store, propsData: { extensionTabs: [], @@ -46,7 +45,7 @@ describe('ide/components/panes/collapsible_sidebar.vue', () => { let extensionTabs; beforeEach(() => { - const FakeComponent = localVue.component(fakeComponentName, { + const FakeComponent = Vue.component(fakeComponentName, { render: () => null, }); diff --git a/spec/frontend/ide/components/panes/right_spec.js b/spec/frontend/ide/components/panes/right_spec.js index c6231d129ff..da9f0286cfb 100644 --- a/spec/frontend/ide/components/panes/right_spec.js +++ b/spec/frontend/ide/components/panes/right_spec.js @@ -1,4 +1,4 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; import CollapsibleSidebar from '~/ide/components/panes/collapsible_sidebar.vue'; @@ -7,8 +7,7 @@ import { rightSidebarViews } from '~/ide/constants'; import { createStore } from '~/ide/stores'; import extendStore from '~/ide/stores/extend'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ide/components/panes/right.vue', () => { let wrapper; @@ -18,7 +17,6 @@ describe('ide/components/panes/right.vue', () => { extendStore(store, document.createElement('div')); wrapper = shallowMount(RightPane, { - localVue, store, propsData: { ...props, diff --git a/spec/frontend/ide/components/preview/clientside_spec.js b/spec/frontend/ide/components/preview/clientside_spec.js index b168eec0f16..08e9a069cf6 100644 --- a/spec/frontend/ide/components/preview/clientside_spec.js +++ b/spec/frontend/ide/components/preview/clientside_spec.js @@ -1,5 +1,6 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import smooshpack from 'smooshpack'; import Vuex from 'vuex'; import Clientside from '~/ide/components/preview/clientside.vue'; @@ -9,8 +10,7 @@ jest.mock('smooshpack', () => ({ Manager: jest.fn(), })); -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const dummyPackageJson = () => ({ raw: JSON.stringify({ @@ -67,7 +67,6 @@ describe('IDE clientside preview', () => { wrapper = shallowMount(Clientside, { store, - localVue, }); }; diff --git a/spec/frontend/ide/components/repo_tab_spec.js b/spec/frontend/ide/components/repo_tab_spec.js index 95d52e8f7a9..b16fd8f80ba 100644 --- a/spec/frontend/ide/components/repo_tab_spec.js +++ b/spec/frontend/ide/components/repo_tab_spec.js @@ -1,5 +1,6 @@ import { GlTab } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { stubComponent } from 'helpers/stub_component'; import RepoTab from '~/ide/components/repo_tab.vue'; @@ -7,8 +8,7 @@ import { createRouter } from '~/ide/ide_router'; import { createStore } from '~/ide/stores'; import { file } from '../helpers'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); const GlTabStub = stubComponent(GlTab, { template: '<li><slot name="title" /></li>', @@ -23,7 +23,6 @@ describe('RepoTab', () => { function createComponent(propsData) { wrapper = mount(RepoTab, { - localVue, store, propsData, stubs: { diff --git a/spec/frontend/ide/components/repo_tabs_spec.js b/spec/frontend/ide/components/repo_tabs_spec.js index 6ee73b0a437..843c00d9943 100644 --- a/spec/frontend/ide/components/repo_tabs_spec.js +++ b/spec/frontend/ide/components/repo_tabs_spec.js @@ -1,11 +1,11 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import RepoTabs from '~/ide/components/repo_tabs.vue'; import { createStore } from '~/ide/stores'; import { file } from '../helpers'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('RepoTabs', () => { let wrapper; @@ -22,7 +22,6 @@ describe('RepoTabs', () => { activeFile: file('activeFile'), }, store, - localVue, }); }); diff --git a/spec/frontend/ide/components/resizable_panel_spec.js b/spec/frontend/ide/components/resizable_panel_spec.js index 6a5af52ea35..cdd089c5588 100644 --- a/spec/frontend/ide/components/resizable_panel_spec.js +++ b/spec/frontend/ide/components/resizable_panel_spec.js @@ -1,4 +1,5 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import ResizablePanel from '~/ide/components/resizable_panel.vue'; import { SIDE_LEFT, SIDE_RIGHT } from '~/ide/constants'; @@ -8,8 +9,7 @@ const TEST_WIDTH = 500; const TEST_MIN_WIDTH = 400; describe('~/ide/components/resizable_panel', () => { - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); let wrapper; let store; @@ -33,7 +33,6 @@ describe('~/ide/components/resizable_panel', () => { ...props, }, store, - localVue, }); }; const findResizer = () => wrapper.find(PanelResizer); diff --git a/spec/frontend/ide/components/terminal/session_spec.js b/spec/frontend/ide/components/terminal/session_spec.js index 5659a7d15da..c988138e9c4 100644 --- a/spec/frontend/ide/components/terminal/session_spec.js +++ b/spec/frontend/ide/components/terminal/session_spec.js @@ -1,5 +1,6 @@ import { GlButton } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import TerminalSession from '~/ide/components/terminal/session.vue'; import Terminal from '~/ide/components/terminal/terminal.vue'; @@ -13,8 +14,7 @@ import { const TEST_TERMINAL_PATH = 'terminal/path'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IDE TerminalSession', () => { let wrapper; @@ -33,7 +33,6 @@ describe('IDE TerminalSession', () => { }); wrapper = shallowMount(TerminalSession, { - localVue, store, ...options, }); diff --git a/spec/frontend/ide/components/terminal/view_spec.js b/spec/frontend/ide/components/terminal/view_spec.js index e97d4d8a73b..49f9513d2ac 100644 --- a/spec/frontend/ide/components/terminal/view_spec.js +++ b/spec/frontend/ide/components/terminal/view_spec.js @@ -1,4 +1,5 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import waitForPromises from 'helpers/wait_for_promises'; import { TEST_HOST } from 'spec/test_constants'; @@ -9,8 +10,7 @@ import TerminalView from '~/ide/components/terminal/view.vue'; const TEST_HELP_PATH = `${TEST_HOST}/help`; const TEST_SVG_PATH = `${TEST_HOST}/illustration.svg`; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('IDE TerminalView', () => { let state; @@ -30,7 +30,7 @@ describe('IDE TerminalView', () => { }, }); - wrapper = shallowMount(TerminalView, { localVue, store }); + wrapper = shallowMount(TerminalView, { store }); // Uses deferred components, so wait for those to load... await waitForPromises(); diff --git a/spec/frontend/ide/components/terminal_sync/terminal_sync_status_safe_spec.js b/spec/frontend/ide/components/terminal_sync/terminal_sync_status_safe_spec.js index 69077ef2c68..f921037d744 100644 --- a/spec/frontend/ide/components/terminal_sync/terminal_sync_status_safe_spec.js +++ b/spec/frontend/ide/components/terminal_sync/terminal_sync_status_safe_spec.js @@ -1,10 +1,10 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import TerminalSyncStatus from '~/ide/components/terminal_sync/terminal_sync_status.vue'; import TerminalSyncStatusSafe from '~/ide/components/terminal_sync/terminal_sync_status_safe.vue'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ide/components/terminal_sync/terminal_sync_status_safe', () => { let store; @@ -16,7 +16,6 @@ describe('ide/components/terminal_sync/terminal_sync_status_safe', () => { }); wrapper = shallowMount(TerminalSyncStatusSafe, { - localVue, store, }); }; diff --git a/spec/frontend/ide/components/terminal_sync/terminal_sync_status_spec.js b/spec/frontend/ide/components/terminal_sync/terminal_sync_status_spec.js index c916c43d1e2..3a326b08fff 100644 --- a/spec/frontend/ide/components/terminal_sync/terminal_sync_status_spec.js +++ b/spec/frontend/ide/components/terminal_sync/terminal_sync_status_spec.js @@ -1,5 +1,6 @@ import { GlLoadingIcon, GlIcon } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import TerminalSyncStatus from '~/ide/components/terminal_sync/terminal_sync_status.vue'; import { @@ -11,8 +12,7 @@ import { const TEST_MESSAGE = 'lorem ipsum dolar sit'; const START_LOADING = 'START_LOADING'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ide/components/terminal_sync/terminal_sync_status', () => { let moduleState; @@ -35,7 +35,6 @@ describe('ide/components/terminal_sync/terminal_sync_status', () => { }); wrapper = shallowMount(TerminalSyncStatus, { - localVue, store, }); }; diff --git a/spec/frontend/ide/stores/plugins/terminal_spec.js b/spec/frontend/ide/stores/plugins/terminal_spec.js index d4cdad16ecb..912de88cb39 100644 --- a/spec/frontend/ide/stores/plugins/terminal_spec.js +++ b/spec/frontend/ide/stores/plugins/terminal_spec.js @@ -1,4 +1,4 @@ -import { createLocalVue } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { TEST_HOST } from 'helpers/test_constants'; import terminalModule from '~/ide/stores/modules/terminal'; @@ -11,8 +11,7 @@ const TEST_DATASET = { eeWebTerminalConfigHelpPath: `${TEST_HOST}/web/terminal/config/help`, eeWebTerminalRunnersHelpPath: `${TEST_HOST}/web/terminal/runners/help`, }; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ide/stores/extend', () => { let store; diff --git a/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js b/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js index 0e748baa313..0b12df83cd1 100644 --- a/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js +++ b/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js @@ -1,6 +1,6 @@ import { GlLoadingIcon, GlButton, GlIntersectionObserver, GlFormInput } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { shallowMount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import { STATUSES } from '~/import_entities/constants'; import ImportProjectsTable from '~/import_entities/import_projects/components/import_projects_table.vue'; @@ -46,8 +46,7 @@ describe('ImportProjectsTable', () => { filterable, paginatable, } = {}) { - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); const store = new Vuex.Store({ state: { ...state(), defaultTargetNamespace: USER_NAMESPACE, ...initialState }, @@ -67,7 +66,6 @@ describe('ImportProjectsTable', () => { }); wrapper = shallowMount(ImportProjectsTable, { - localVue, store, propsData: { providerTitle, diff --git a/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js b/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js index 72640f3d601..c8afa9ea57d 100644 --- a/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js +++ b/spec/frontend/import_entities/import_projects/components/provider_repo_table_row_spec.js @@ -1,6 +1,6 @@ import { GlBadge, GlButton, GlDropdown } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { shallowMount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import { STATUSES } from '~/import_entities//constants'; import ImportGroupDropdown from '~/import_entities/components/group_dropdown.vue'; @@ -38,13 +38,11 @@ describe('ProviderRepoTableRow', () => { }; function mountComponent(props) { - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); const store = initStore(); wrapper = shallowMount(ProviderRepoTableRow, { - localVue, store, propsData: { availableNamespaces, userNamespace, ...props }, }); diff --git a/spec/frontend/issues/related_merge_requests/components/related_merge_requests_spec.js b/spec/frontend/issues/related_merge_requests/components/related_merge_requests_spec.js index 4d780a674be..6e3d9901d7c 100644 --- a/spec/frontend/issues/related_merge_requests/components/related_merge_requests_spec.js +++ b/spec/frontend/issues/related_merge_requests/components/related_merge_requests_spec.js @@ -1,4 +1,4 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; import mockData from 'test_fixtures/issues/related_merge_requests.json'; import axios from '~/lib/utils/axios_utils'; @@ -7,7 +7,6 @@ import createStore from '~/issues/related_merge_requests/store/index'; import RelatedIssuableItem from '~/issuable/components/related_issuable_item.vue'; const API_ENDPOINT = '/api/v4/projects/2/issues/33/related_merge_requests'; -const localVue = createLocalVue(); describe('RelatedMergeRequests', () => { let wrapper; @@ -21,8 +20,7 @@ describe('RelatedMergeRequests', () => { mock = new MockAdapter(axios); mock.onGet(`${API_ENDPOINT}?per_page=100`).reply(200, mockData, { 'x-total': 2 }); - wrapper = mount(localVue.extend(RelatedMergeRequests), { - localVue, + wrapper = mount(RelatedMergeRequests, { store: createStore(), propsData: { endpoint: API_ENDPOINT, diff --git a/spec/frontend/jobs/components/job_app_spec.js b/spec/frontend/jobs/components/job_app_spec.js index 07e6ee46c41..a6e98013d88 100644 --- a/spec/frontend/jobs/components/job_app_spec.js +++ b/spec/frontend/jobs/components/job_app_spec.js @@ -1,5 +1,6 @@ import { GlLoadingIcon } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import Vuex from 'vuex'; import delayedJobFixture from 'test_fixtures/jobs/delayed.json'; @@ -16,8 +17,7 @@ import axios from '~/lib/utils/axios_utils'; import job from '../mock_data'; describe('Job App', () => { - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); let store; let wrapper; diff --git a/spec/frontend/jobs/components/log/log_spec.js b/spec/frontend/jobs/components/log/log_spec.js index 9a5522ab4cd..7e11738f82e 100644 --- a/spec/frontend/jobs/components/log/log_spec.js +++ b/spec/frontend/jobs/components/log/log_spec.js @@ -1,4 +1,5 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import Log from '~/jobs/components/log/log.vue'; import { logLinesParserLegacy, logLinesParser } from '~/jobs/store/utils'; @@ -11,12 +12,10 @@ describe('Job Log', () => { let store; let origGon; - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); const createComponent = () => { wrapper = mount(Log, { - localVue, store, }); }; @@ -91,12 +90,10 @@ describe('Job Log, infinitelyCollapsibleSections feature flag enabled', () => { let store; let origGon; - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); const createComponent = () => { wrapper = mount(Log, { - localVue, store, }); }; diff --git a/spec/frontend/jobs/components/manual_variables_form_spec.js b/spec/frontend/jobs/components/manual_variables_form_spec.js index a5278af8e33..6faab3ddf31 100644 --- a/spec/frontend/jobs/components/manual_variables_form_spec.js +++ b/spec/frontend/jobs/components/manual_variables_form_spec.js @@ -1,12 +1,10 @@ import { GlSprintf, GlLink } from '@gitlab/ui'; -import { createLocalVue, mount } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import ManualVariablesForm from '~/jobs/components/manual_variables_form.vue'; -const localVue = createLocalVue(); - Vue.use(Vuex); describe('Manual Variables Form', () => { @@ -29,9 +27,8 @@ describe('Manual Variables Form', () => { }); wrapper = extendedWrapper( - mount(localVue.extend(ManualVariablesForm), { + mount(ManualVariablesForm, { propsData: { ...requiredProps, ...props }, - localVue, store, stubs: { GlSprintf, diff --git a/spec/frontend/lib/utils/vuex_module_mappers_spec.js b/spec/frontend/lib/utils/vuex_module_mappers_spec.js index d7e51e4daca..1821a15f677 100644 --- a/spec/frontend/lib/utils/vuex_module_mappers_spec.js +++ b/spec/frontend/lib/utils/vuex_module_mappers_spec.js @@ -1,4 +1,4 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; import { @@ -10,13 +10,12 @@ import { const TEST_MODULE_NAME = 'testModuleName'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); // setup test component and store ---------------------------------------------- // // These are used to indirectly test `vuex_module_mappers`. -const TestComponent = Vue.extend({ +const TestComponent = { props: { vuexModule: { type: String, @@ -47,7 +46,7 @@ const TestComponent = Vue.extend({ <pre data-testid="state">{{ stateJson }}</pre> <pre data-testid="getters">{{ gettersJson }}</pre> </div>`, -}); +}; const createTestStore = () => { return new Vuex.Store({ @@ -94,7 +93,6 @@ describe('~/lib/utils/vuex_module_mappers', () => { vuexModule: TEST_MODULE_NAME, }, store, - localVue, }); }); diff --git a/spec/frontend/members/components/action_buttons/approve_access_request_button_spec.js b/spec/frontend/members/components/action_buttons/approve_access_request_button_spec.js index 936715e7723..08d7cf3c932 100644 --- a/spec/frontend/members/components/action_buttons/approve_access_request_button_spec.js +++ b/spec/frontend/members/components/action_buttons/approve_access_request_button_spec.js @@ -1,5 +1,6 @@ import { GlButton, GlForm } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import ApproveAccessRequestButton from '~/members/components/action_buttons/approve_access_request_button.vue'; @@ -7,8 +8,7 @@ import { MEMBER_TYPES } from '~/members/constants'; jest.mock('~/lib/utils/csrf', () => ({ token: 'mock-csrf-token' })); -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ApproveAccessRequestButton', () => { let wrapper; @@ -29,7 +29,6 @@ describe('ApproveAccessRequestButton', () => { const createComponent = (propsData = {}, state) => { wrapper = shallowMount(ApproveAccessRequestButton, { - localVue, store: createStore(state), provide: { namespace: MEMBER_TYPES.accessRequest, diff --git a/spec/frontend/members/components/action_buttons/remove_group_link_button_spec.js b/spec/frontend/members/components/action_buttons/remove_group_link_button_spec.js index f91aef131a1..ca655e36c42 100644 --- a/spec/frontend/members/components/action_buttons/remove_group_link_button_spec.js +++ b/spec/frontend/members/components/action_buttons/remove_group_link_button_spec.js @@ -1,13 +1,13 @@ import { GlButton } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import RemoveGroupLinkButton from '~/members/components/action_buttons/remove_group_link_button.vue'; import { MEMBER_TYPES } from '~/members/constants'; import { group } from '../../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('RemoveGroupLinkButton', () => { let wrapper; @@ -29,7 +29,6 @@ describe('RemoveGroupLinkButton', () => { const createComponent = () => { wrapper = mount(RemoveGroupLinkButton, { - localVue, store: createStore(), provide: { namespace: MEMBER_TYPES.group, diff --git a/spec/frontend/members/components/action_buttons/remove_member_button_spec.js b/spec/frontend/members/components/action_buttons/remove_member_button_spec.js index 1a031cc56d6..0e5b667eb9b 100644 --- a/spec/frontend/members/components/action_buttons/remove_member_button_spec.js +++ b/spec/frontend/members/components/action_buttons/remove_member_button_spec.js @@ -1,13 +1,13 @@ import { GlButton } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { modalData } from 'jest/members/mock_data'; import RemoveMemberButton from '~/members/components/action_buttons/remove_member_button.vue'; import { MEMBER_TYPES } from '~/members/constants'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('RemoveMemberButton', () => { let wrapper; @@ -33,7 +33,6 @@ describe('RemoveMemberButton', () => { const createComponent = (propsData = {}, state) => { wrapper = shallowMount(RemoveMemberButton, { - localVue, store: createStore(state), provide: { namespace: MEMBER_TYPES.user, diff --git a/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js b/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js index 547e067450c..8e933d16463 100644 --- a/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js +++ b/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js @@ -1,5 +1,6 @@ import { GlButton } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import ResendInviteButton from '~/members/components/action_buttons/resend_invite_button.vue'; @@ -7,8 +8,7 @@ import { MEMBER_TYPES } from '~/members/constants'; jest.mock('~/lib/utils/csrf', () => ({ token: 'mock-csrf-token' })); -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ResendInviteButton', () => { let wrapper; @@ -29,7 +29,6 @@ describe('ResendInviteButton', () => { const createComponent = (propsData = {}, state) => { wrapper = shallowMount(ResendInviteButton, { - localVue, store: createStore(state), provide: { namespace: MEMBER_TYPES.invite, diff --git a/spec/frontend/members/components/app_spec.js b/spec/frontend/members/components/app_spec.js index 9590cd9d8d4..4124a1870a6 100644 --- a/spec/frontend/members/components/app_spec.js +++ b/spec/frontend/members/components/app_spec.js @@ -1,6 +1,6 @@ import { GlAlert } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { shallowMount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import * as commonUtils from '~/lib/utils/common_utils'; import MembersApp from '~/members/components/app.vue'; @@ -11,8 +11,7 @@ import { RECEIVE_MEMBER_ROLE_ERROR, HIDE_ERROR } from '~/members/store/mutation_ import mutations from '~/members/store/mutations'; describe('MembersApp', () => { - const localVue = createLocalVue(); - localVue.use(Vuex); + Vue.use(Vuex); let wrapper; let store; @@ -33,7 +32,6 @@ describe('MembersApp', () => { }); wrapper = shallowMount(MembersApp, { - localVue, propsData: { namespace: MEMBER_TYPES.group, tabQueryParamValue: TAB_QUERY_PARAM_VALUES.group, diff --git a/spec/frontend/members/components/filter_sort/filter_sort_container_spec.js b/spec/frontend/members/components/filter_sort/filter_sort_container_spec.js index 16ac52737bc..4ca8a3bdc36 100644 --- a/spec/frontend/members/components/filter_sort/filter_sort_container_spec.js +++ b/spec/frontend/members/components/filter_sort/filter_sort_container_spec.js @@ -1,12 +1,12 @@ -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import FilterSortContainer from '~/members/components/filter_sort/filter_sort_container.vue'; import MembersFilteredSearchBar from '~/members/components/filter_sort/members_filtered_search_bar.vue'; import SortDropdown from '~/members/components/filter_sort/sort_dropdown.vue'; import { MEMBER_TYPES } from '~/members/constants'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('FilterSortContainer', () => { let wrapper; @@ -32,7 +32,6 @@ describe('FilterSortContainer', () => { }); wrapper = shallowMount(FilterSortContainer, { - localVue, store, provide: { namespace: MEMBER_TYPES.user, diff --git a/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js b/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js index 3f47fa024bc..ee2fbbe57b9 100644 --- a/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js +++ b/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js @@ -1,5 +1,6 @@ import { GlFilteredSearchToken } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import setWindowLocation from 'helpers/set_window_location_helper'; import { redirectTo } from '~/lib/utils/url_utility'; @@ -18,8 +19,7 @@ jest.mock('~/lib/utils/url_utility', () => { }; }); -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('MembersFilteredSearchBar', () => { let wrapper; @@ -44,7 +44,6 @@ describe('MembersFilteredSearchBar', () => { }); wrapper = shallowMount(MembersFilteredSearchBar, { - localVue, provide: { sourceId: 1, canManageMembers: true, diff --git a/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js b/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js index d0684acd487..709ad907a38 100644 --- a/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js +++ b/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js @@ -1,13 +1,13 @@ import { GlSorting, GlSortingItem } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import setWindowLocation from 'helpers/set_window_location_helper'; import * as urlUtilities from '~/lib/utils/url_utility'; import SortDropdown from '~/members/components/filter_sort/sort_dropdown.vue'; import { MEMBER_TYPES } from '~/members/constants'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('SortDropdown', () => { let wrapper; @@ -35,7 +35,6 @@ describe('SortDropdown', () => { }); wrapper = mount(SortDropdown, { - localVue, provide: { sourceId: 1, namespace: MEMBER_TYPES.user, diff --git a/spec/frontend/members/components/modals/leave_modal_spec.js b/spec/frontend/members/components/modals/leave_modal_spec.js index f755f08dbf2..cdbabb2f646 100644 --- a/spec/frontend/members/components/modals/leave_modal_spec.js +++ b/spec/frontend/members/components/modals/leave_modal_spec.js @@ -1,8 +1,8 @@ import { GlModal, GlForm } from '@gitlab/ui'; import { within } from '@testing-library/dom'; -import { mount, createLocalVue, createWrapper } from '@vue/test-utils'; +import { mount, createWrapper } from '@vue/test-utils'; import { cloneDeep } from 'lodash'; -import { nextTick } from 'vue'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import LeaveModal from '~/members/components/modals/leave_modal.vue'; import { LEAVE_MODAL_ID, MEMBER_TYPES } from '~/members/constants'; @@ -12,8 +12,7 @@ import { member } from '../../mock_data'; jest.mock('~/lib/utils/csrf', () => ({ token: 'mock-csrf-token' })); -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('LeaveModal', () => { let wrapper; @@ -34,7 +33,6 @@ describe('LeaveModal', () => { const createComponent = (propsData = {}, state) => { wrapper = mount(LeaveModal, { - localVue, store: createStore(state), provide: { namespace: MEMBER_TYPES.user, diff --git a/spec/frontend/members/components/modals/remove_group_link_modal_spec.js b/spec/frontend/members/components/modals/remove_group_link_modal_spec.js index 313c237f51c..447496910b8 100644 --- a/spec/frontend/members/components/modals/remove_group_link_modal_spec.js +++ b/spec/frontend/members/components/modals/remove_group_link_modal_spec.js @@ -1,7 +1,7 @@ import { GlModal, GlForm } from '@gitlab/ui'; import { within } from '@testing-library/dom'; -import { mount, createLocalVue, createWrapper } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { mount, createWrapper } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import RemoveGroupLinkModal from '~/members/components/modals/remove_group_link_modal.vue'; import { REMOVE_GROUP_LINK_MODAL_ID, MEMBER_TYPES } from '~/members/constants'; @@ -9,8 +9,7 @@ import { group } from '../../mock_data'; jest.mock('~/lib/utils/csrf', () => ({ token: 'mock-csrf-token' })); -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('RemoveGroupLinkModal', () => { let wrapper; @@ -38,7 +37,6 @@ describe('RemoveGroupLinkModal', () => { const createComponent = (state) => { wrapper = mount(RemoveGroupLinkModal, { - localVue, store: createStore(state), provide: { namespace: MEMBER_TYPES.group, diff --git a/spec/frontend/members/components/table/expiration_datepicker_spec.js b/spec/frontend/members/components/table/expiration_datepicker_spec.js index 3c4a9ba37ff..4fb43fbd888 100644 --- a/spec/frontend/members/components/table/expiration_datepicker_spec.js +++ b/spec/frontend/members/components/table/expiration_datepicker_spec.js @@ -1,6 +1,6 @@ import { GlDatepicker } from '@gitlab/ui'; -import { mount, createLocalVue } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { mount } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import { useFakeDate } from 'helpers/fake_date'; import waitForPromises from 'helpers/wait_for_promises'; @@ -8,8 +8,7 @@ import ExpirationDatepicker from '~/members/components/table/expiration_datepick import { MEMBER_TYPES } from '~/members/constants'; import { member } from '../../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('ExpirationDatepicker', () => { // March 15th, 2020 3:00 @@ -49,7 +48,6 @@ describe('ExpirationDatepicker', () => { provide: { namespace: MEMBER_TYPES.user, }, - localVue, store: createStore(), mocks: { $toast, diff --git a/spec/frontend/members/components/table/members_table_cell_spec.js b/spec/frontend/members/components/table/members_table_cell_spec.js index 5375ee11736..6575a7c7126 100644 --- a/spec/frontend/members/components/table/members_table_cell_spec.js +++ b/spec/frontend/members/components/table/members_table_cell_spec.js @@ -1,4 +1,5 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import MembersTableCell from '~/members/components/table/members_table_cell.vue'; import { MEMBER_TYPES } from '~/members/constants'; @@ -36,9 +37,8 @@ describe('MembersTableCell', () => { }, }; - const localVue = createLocalVue(); - localVue.use(Vuex); - localVue.component('WrappedComponent', WrappedComponent); + Vue.use(Vuex); + Vue.component('WrappedComponent', WrappedComponent); const createStore = (state = {}) => { return new Vuex.Store({ @@ -50,7 +50,6 @@ describe('MembersTableCell', () => { const createComponent = (propsData, state) => { wrapper = mount(MembersTableCell, { - localVue, propsData, store: createStore(state), provide: { diff --git a/spec/frontend/members/components/table/members_table_spec.js b/spec/frontend/members/components/table/members_table_spec.js index 580e5edd652..b559afb4512 100644 --- a/spec/frontend/members/components/table/members_table_spec.js +++ b/spec/frontend/members/components/table/members_table_spec.js @@ -1,5 +1,5 @@ import { GlBadge, GlPagination, GlTable } from '@gitlab/ui'; -import { createLocalVue } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import setWindowLocation from 'helpers/set_window_location_helper'; import { mountExtended, extendedWrapper } from 'helpers/vue_test_utils_helper'; @@ -28,8 +28,7 @@ import { pagination, } from '../../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('MembersTable', () => { let wrapper; @@ -56,7 +55,6 @@ describe('MembersTable', () => { const createComponent = (state, provide = {}) => { wrapper = mountExtended(MembersTable, { - localVue, propsData: { tabQueryParamValue: TAB_QUERY_PARAM_VALUES.invite, }, diff --git a/spec/frontend/members/components/table/role_dropdown_spec.js b/spec/frontend/members/components/table/role_dropdown_spec.js index a4a4c620921..d4d950e99ba 100644 --- a/spec/frontend/members/components/table/role_dropdown_spec.js +++ b/spec/frontend/members/components/table/role_dropdown_spec.js @@ -1,8 +1,8 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { within } from '@testing-library/dom'; -import { mount, createWrapper, createLocalVue } from '@vue/test-utils'; -import { nextTick } from 'vue'; +import { mount, createWrapper } from '@vue/test-utils'; +import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import waitForPromises from 'helpers/wait_for_promises'; import { BV_DROPDOWN_SHOW } from '~/lib/utils/constants'; @@ -10,8 +10,7 @@ import RoleDropdown from '~/members/components/table/role_dropdown.vue'; import { MEMBER_TYPES } from '~/members/constants'; import { member } from '../../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('RoleDropdown', () => { let wrapper; @@ -42,7 +41,6 @@ describe('RoleDropdown', () => { permissions: {}, ...propsData, }, - localVue, store: createStore(), mocks: { $toast, diff --git a/spec/frontend/merge_conflicts/components/merge_conflict_resolver_app_spec.js b/spec/frontend/merge_conflicts/components/merge_conflict_resolver_app_spec.js index a09edb50f20..fabf65742f5 100644 --- a/spec/frontend/merge_conflicts/components/merge_conflict_resolver_app_spec.js +++ b/spec/frontend/merge_conflicts/components/merge_conflict_resolver_app_spec.js @@ -1,5 +1,6 @@ import { GlSprintf } from '@gitlab/ui'; -import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import InlineConflictLines from '~/merge_conflicts/components/inline_conflict_lines.vue'; import ParallelConflictLines from '~/merge_conflicts/components/parallel_conflict_lines.vue'; @@ -8,8 +9,7 @@ import { createStore } from '~/merge_conflicts/store'; import { decorateFiles } from '~/merge_conflicts/utils'; import { conflictsMock } from '../mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Merge Conflict Resolver App', () => { let wrapper; diff --git a/spec/frontend/monitoring/components/embeds/embed_group_spec.js b/spec/frontend/monitoring/components/embeds/embed_group_spec.js index 79b223d96e4..f6229afd180 100644 --- a/spec/frontend/monitoring/components/embeds/embed_group_spec.js +++ b/spec/frontend/monitoring/components/embeds/embed_group_spec.js @@ -1,5 +1,6 @@ import { GlButton, GlCard } from '@gitlab/ui'; -import { createLocalVue, mount, shallowMount } from '@vue/test-utils'; +import { mount, shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { TEST_HOST } from 'helpers/test_constants'; import EmbedGroup from '~/monitoring/components/embeds/embed_group.vue'; @@ -12,8 +13,7 @@ import { multipleEmbedProps, } from './mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('Embed Group', () => { let wrapper; @@ -23,7 +23,6 @@ describe('Embed Group', () => { function mountComponent({ urls = [TEST_HOST], shallow = true, stubs } = {}) { const mountMethod = shallow ? shallowMount : mount; wrapper = mountMethod(EmbedGroup, { - localVue, store, propsData: { urls, diff --git a/spec/frontend/monitoring/components/embeds/metric_embed_spec.js b/spec/frontend/monitoring/components/embeds/metric_embed_spec.js index 90647f50b14..f9f1be4f277 100644 --- a/spec/frontend/monitoring/components/embeds/metric_embed_spec.js +++ b/spec/frontend/monitoring/components/embeds/metric_embed_spec.js @@ -1,4 +1,5 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { setHTMLFixture } from 'helpers/fixtures'; import { TEST_HOST } from 'helpers/test_constants'; @@ -6,8 +7,7 @@ import DashboardPanel from '~/monitoring/components/dashboard_panel.vue'; import MetricEmbed from '~/monitoring/components/embeds/metric_embed.vue'; import { groups, initialState, metricsData, metricsWithData } from './mock_data'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); describe('MetricEmbed', () => { let wrapper; @@ -17,7 +17,6 @@ describe('MetricEmbed', () => { function mountComponent() { wrapper = shallowMount(MetricEmbed, { - localVue, store, propsData: { dashboardUrl: TEST_HOST, diff --git a/spec/frontend/monitoring/router_spec.js b/spec/frontend/monitoring/router_spec.js index b027d60f61e..7758dd351b7 100644 --- a/spec/frontend/monitoring/router_spec.js +++ b/spec/frontend/monitoring/router_spec.js @@ -1,4 +1,5 @@ -import { mount, createLocalVue } from '@vue/test-utils'; +import { mount } from '@vue/test-utils'; +import Vue from 'vue'; import VueRouter from 'vue-router'; import Dashboard from '~/monitoring/components/dashboard.vue'; import DashboardPage from '~/monitoring/pages/dashboard_page.vue'; @@ -25,8 +26,7 @@ describe('Monitoring router', () => { let store; const createWrapper = (basePath, routeArg) => { - const localVue = createLocalVue(); - localVue.use(VueRouter); + Vue.use(VueRouter); router = createRouter(basePath); if (routeArg !== undefined) { @@ -34,7 +34,6 @@ describe('Monitoring router', () => { } return mount(MockApp, { - localVue, store, router, }); diff --git a/spec/initializers/google_api_client_spec.rb b/spec/initializers/google_api_client_spec.rb new file mode 100644 index 00000000000..0ed82d7debe --- /dev/null +++ b/spec/initializers/google_api_client_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +# Extracted from https://github.com/googleapis/google-api-ruby-client/blob/main/google-apis-core/spec/google/apis/core/http_command_spec.rb + +require 'spec_helper' +require 'google/apis/core/base_service' + +RSpec.describe Google::Apis::Core::HttpCommand do # rubocop:disable RSpec/FilePath + context('with a successful response') do + let(:client) { Google::Apis::Core::BaseService.new('', '').client } + let(:command) { Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals') } + + before do + stub_request(:get, 'https://www.googleapis.com/zoo/animals').to_return(body: %(Hello world)) + end + + it 'returns the response body if block not present' do + result = command.execute(client) + expect(result).to eql 'Hello world' + end + + it 'calls block if present' do + expect { |b| command.execute(client, &b) }.to yield_with_args('Hello world', nil) + end + + it 'retries with max elapsed_time and retries' do + expect(Retriable).to receive(:retriable).with( + tries: Google::Apis::RequestOptions.default.retries + 1, + max_elapsed_time: 3600, + base_interval: 1, + multiplier: 2, + on: described_class::RETRIABLE_ERRORS).and_call_original + allow(Retriable).to receive(:retriable).and_call_original + + command.execute(client) + end + end +end diff --git a/spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb b/spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb index dffe7dfb29d..03634ebeeb9 100644 --- a/spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb +++ b/spec/lib/gitlab/database/no_cross_db_foreign_keys_spec.rb @@ -44,7 +44,6 @@ RSpec.describe 'cross-database foreign keys' do dast_site_profiles_pipelines.ci_pipeline_id external_pull_requests.project_id vulnerability_feedback.pipeline_id - vulnerability_occurrence_pipelines.pipeline_id vulnerability_statistics.latest_pipeline_id ).freeze end diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index 6830a8daa3b..d1007eee186 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -23,6 +23,26 @@ RSpec.describe Ci::Runner do end end + describe 'projects association' do + let(:runner) { create(:ci_runner, :project) } + + it 'does not create a cross-database query' do + with_cross_joins_prevented do + expect(runner.projects.count).to eq(1) + end + end + + context 'when ci_runner_projects_disable_joins is disabled' do + before do + stub_feature_flags(ci_runner_projects_disable_joins: false) + end + + it 'creates a cross-database query' do + expect { runner.projects.count }.to raise_error(Database::PreventCrossJoins::CrossJoinAcrossUnsupportedTablesError) + end + end + end + describe 'validation' do it { is_expected.to validate_presence_of(:access_level) } it { is_expected.to validate_presence_of(:runner_type) } @@ -291,6 +311,30 @@ RSpec.describe Ci::Runner do end end + describe '#only_for' do + let_it_be_with_reload(:runner) { create(:ci_runner, :project) } + let_it_be(:project) { runner.projects.first } + + subject { runner.only_for?(project) } + + context 'with matching project' do + it { is_expected.to be_truthy } + end + + context 'without matching project' do + let_it_be(:project) { create(:project) } + + it { is_expected.to be_falsey } + end + + context 'with runner having multiple projects' do + let_it_be(:other_project) { create(:project) } + let_it_be(:runner_project) { create(:ci_runner_project, project: other_project, runner: runner) } + + it { is_expected.to be_falsey } + end + end + describe '#assign_to' do let(:project) { create(:project) } diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 9aa8aaafc68..b624b95c016 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -612,6 +612,30 @@ RSpec.describe API::Internal::Base do expect(json_response["gitaly"]["features"]).to eq('gitaly-feature-mep-mep' => 'false') end end + + context "with a sidechannels enabled for a project" do + before do + stub_feature_flags(gitlab_shell_upload_pack_sidechannel: project) + end + + it "has the use_sidechannel field set to true for that project" do + pull(key, project) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response["gl_repository"]).to eq("project-#{project.id}") + expect(json_response["gitaly"]["use_sidechannel"]).to eq(true) + end + + it "has the use_sidechannel field set to false for other projects" do + other_project = create(:project, :public, :repository) + + pull(key, other_project) + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response["gl_repository"]).to eq("project-#{other_project.id}") + expect(json_response["gitaly"]["use_sidechannel"]).to eq(false) + end + end end context "git push" do diff --git a/spec/services/concerns/rate_limited_service_spec.rb b/spec/services/concerns/rate_limited_service_spec.rb index f73871b7e44..97f5ca53c0d 100644 --- a/spec/services/concerns/rate_limited_service_spec.rb +++ b/spec/services/concerns/rate_limited_service_spec.rb @@ -6,11 +6,10 @@ RSpec.describe RateLimitedService do let(:key) { :issues_create } let(:scope) { [:project, :current_user] } let(:opts) { { scope: scope, users_allowlist: -> { [User.support_bot.username] } } } - let(:rate_limiter_klass) { ::Gitlab::ApplicationRateLimiter } - let(:rate_limiter_instance) { rate_limiter_klass.new(key, **opts) } + let(:rate_limiter) { ::Gitlab::ApplicationRateLimiter } describe 'RateLimitedError' do - subject { described_class::RateLimitedError.new(key: key, rate_limiter: rate_limiter_instance) } + subject { described_class::RateLimitedError.new(key: key, rate_limiter: rate_limiter) } describe '#headers' do it 'returns a Hash of HTTP headers' do @@ -26,7 +25,7 @@ RSpec.describe RateLimitedService do request = instance_double(Grape::Request) user = instance_double(User) - expect(rate_limiter_klass).to receive(:log_request).with(request, "#{key}_request_limit".to_sym, user) + expect(rate_limiter).to receive(:log_request).with(request, "#{key}_request_limit".to_sym, user) subject.log_request(request, user) end @@ -34,7 +33,7 @@ RSpec.describe RateLimitedService do end describe 'RateLimiterScopedAndKeyed' do - subject { described_class::RateLimiterScopedAndKeyed.new(key: key, opts: opts, rate_limiter_klass: rate_limiter_klass) } + subject { described_class::RateLimiterScopedAndKeyed.new(key: key, opts: opts, rate_limiter: rate_limiter) } describe '#rate_limit!' do let(:project_with_feature_enabled) { create(:project) } @@ -49,13 +48,12 @@ RSpec.describe RateLimitedService do let(:rate_limited_service_issues_create_feature_enabled) { nil } before do - allow(rate_limiter_klass).to receive(:new).with(key, **evaluated_opts).and_return(rate_limiter_instance) stub_feature_flags(rate_limited_service_issues_create: rate_limited_service_issues_create_feature_enabled) end shared_examples 'a service that does not attempt to throttle' do it 'does not attempt to throttle' do - expect(rate_limiter_instance).not_to receive(:throttled?) + expect(rate_limiter).not_to receive(:throttled?) expect(subject.rate_limit!(service)).to be_nil end @@ -63,7 +61,7 @@ RSpec.describe RateLimitedService do shared_examples 'a service that does attempt to throttle' do before do - allow(rate_limiter_instance).to receive(:throttled?).and_return(throttled) + allow(rate_limiter).to receive(:throttled?).and_return(throttled) end context 'when rate limiting is not in effect' do @@ -134,7 +132,7 @@ RSpec.describe RateLimitedService do end before do - allow(RateLimitedService::RateLimiterScopedAndKeyed).to receive(:new).with(key: key, opts: opts, rate_limiter_klass: rate_limiter_klass).and_return(rate_limiter_scoped_and_keyed) + allow(RateLimitedService::RateLimiterScopedAndKeyed).to receive(:new).with(key: key, opts: opts, rate_limiter: rate_limiter).and_return(rate_limiter_scoped_and_keyed) end context 'bypasses rate limiting' do @@ -173,12 +171,12 @@ RSpec.describe RateLimitedService do end before do - allow(RateLimitedService::RateLimiterScopedAndKeyed).to receive(:new).with(key: key, opts: opts, rate_limiter_klass: rate_limiter_klass).and_return(rate_limiter_scoped_and_keyed) + allow(RateLimitedService::RateLimiterScopedAndKeyed).to receive(:new).with(key: key, opts: opts, rate_limiter: rate_limiter).and_return(rate_limiter_scoped_and_keyed) end context 'and applies rate limiting' do it 'raises an RateLimitedService::RateLimitedError exception' do - expect(rate_limiter_scoped_and_keyed).to receive(:rate_limit!).with(subject).and_raise(RateLimitedService::RateLimitedError.new(key: key, rate_limiter: rate_limiter_instance)) + expect(rate_limiter_scoped_and_keyed).to receive(:rate_limit!).with(subject).and_raise(RateLimitedService::RateLimitedError.new(key: key, rate_limiter: rate_limiter)) expect { subject.execute }.to raise_error(RateLimitedService::RateLimitedError) end diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index b2dcfb5c6d3..b0dd3b9eff1 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Issues::CreateService do expect(described_class.rate_limiter_scoped_and_keyed.key).to eq(:issues_create) expect(described_class.rate_limiter_scoped_and_keyed.opts[:scope]).to eq(%i[project current_user external_author]) - expect(described_class.rate_limiter_scoped_and_keyed.rate_limiter_klass).to eq(Gitlab::ApplicationRateLimiter) + expect(described_class.rate_limiter_scoped_and_keyed.rate_limiter).to eq(Gitlab::ApplicationRateLimiter) end end |