diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 03:09:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 03:09:56 +0300 |
commit | d7511e6d2f947dbae4b19947b746fdabb0897d92 (patch) | |
tree | e4084212e1b0a47d4ac3c7df6f404f47da0fa4ab /spec | |
parent | 7361375554b55ca52e0282bbe6cd063e2848bc2b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
6 files changed, 102 insertions, 39 deletions
diff --git a/spec/features/incidents/incident_timeline_events_spec.rb b/spec/features/incidents/incident_timeline_events_spec.rb index 4d51ed652c9..8829f21cabe 100644 --- a/spec/features/incidents/incident_timeline_events_spec.rb +++ b/spec/features/incidents/incident_timeline_events_spec.rb @@ -86,8 +86,8 @@ RSpec.describe 'Incident timeline events', :js, feature_category: :incident_mana def trigger_dropdown_action(text) click_button _('More actions') - page.within '.gl-dropdown-contents' do - page.find('.gl-dropdown-item', text: text).click + page.within '[data-testid="disclosure-content"]' do + page.find('[data-testid="disclosure-dropdown-item"]', text: text).click end end end diff --git a/spec/frontend/issues/show/components/incidents/timeline_events_item_spec.js b/spec/frontend/issues/show/components/incidents/timeline_events_item_spec.js index 24653a23036..2500c808073 100644 --- a/spec/frontend/issues/show/components/incidents/timeline_events_item_spec.js +++ b/spec/frontend/issues/show/components/incidents/timeline_events_item_spec.js @@ -1,5 +1,5 @@ import timezoneMock from 'timezone-mock'; -import { GlIcon, GlDropdown, GlBadge } from '@gitlab/ui'; +import { GlIcon, GlDisclosureDropdown, GlBadge } from '@gitlab/ui'; import { nextTick } from 'vue'; import { timelineItemI18n } from '~/issues/show/components/incidents/constants'; import { mountExtended } from 'helpers/vue_test_utils_helper'; @@ -28,7 +28,7 @@ describe('IncidentTimelineEventList', () => { const findCommentIcon = () => wrapper.findComponent(GlIcon); const findEventTime = () => wrapper.findByTestId('event-time'); const findEventTags = () => wrapper.findAllComponents(GlBadge); - const findDropdown = () => wrapper.findComponent(GlDropdown); + const findGlDropdown = () => wrapper.findComponent(GlDisclosureDropdown); const findDeleteButton = () => wrapper.findByText(timelineItemI18n.delete); const findEditButton = () => wrapper.findByText(timelineItemI18n.edit); @@ -85,7 +85,7 @@ describe('IncidentTimelineEventList', () => { describe('action dropdown', () => { it('does not show the action dropdown by default', () => { - expect(findDropdown().exists()).toBe(false); + expect(findGlDropdown().exists()).toBe(false); expect(findDeleteButton().exists()).toBe(false); }); @@ -100,14 +100,14 @@ describe('IncidentTimelineEventList', () => { mockEvent: systemGeneratedMockEvent, }); - expect(findDropdown().exists()).toBe(true); + expect(findGlDropdown().exists()).toBe(true); expect(findEditButton().exists()).toBe(false); }); it('shows dropdown and delete item when user has update permission', () => { mountComponent({ provide: { canUpdateTimelineEvent: true } }); - expect(findDropdown().exists()).toBe(true); + expect(findGlDropdown().exists()).toBe(true); expect(findDeleteButton().exists()).toBe(true); }); diff --git a/spec/lib/generators/batched_background_migration/batched_background_migration_generator_spec.rb b/spec/lib/generators/batched_background_migration/batched_background_migration_generator_spec.rb index d533bcf0039..d60d0c3c853 100644 --- a/spec/lib/generators/batched_background_migration/batched_background_migration_generator_spec.rb +++ b/spec/lib/generators/batched_background_migration/batched_background_migration_generator_spec.rb @@ -20,15 +20,17 @@ RSpec.describe BatchedBackgroundMigration::BatchedBackgroundMigrationGenerator, rm_rf(destination_root) end - context 'with valid arguments' do - let(:expected_migration_file) { load_expected_file('queue_my_batched_migration.txt') } - let(:expected_migration_spec_file) { load_expected_file('queue_my_batched_migration_spec.txt') } - let(:expected_migration_job_file) { load_expected_file('my_batched_migration.txt') } - let(:expected_migration_job_spec_file) { load_expected_file('my_batched_migration_spec_matcher.txt') } - let(:expected_migration_dictionary) { load_expected_file('my_batched_migration_dictionary_matcher.txt') } - - it 'generates expected files' do - run_generator %w[my_batched_migration --table_name=projects --column_name=id --feature_category=database] + shared_examples "generates files common to both types of migrations" do |migration_job_file, migration_file, + migration_spec_file, migration_dictionary_file| + let(:expected_migration_job_file) { load_expected_file(migration_job_file) } + let(:expected_migration_file) { load_expected_file(migration_file) } + let(:expected_migration_spec_file) { load_expected_file(migration_spec_file) } + let(:expected_migration_dictionary) { load_expected_file(migration_dictionary_file) } + + it 'generates expected common files' do + assert_file('lib/gitlab/background_migration/my_batched_migration.rb') do |migration_job_file| + expect(migration_job_file).to eq(expected_migration_job_file) + end assert_migration('db/post_migrate/queue_my_batched_migration.rb') do |migration_file| expect(migration_file).to eq(expected_migration_file) @@ -38,15 +40,6 @@ RSpec.describe BatchedBackgroundMigration::BatchedBackgroundMigrationGenerator, expect(migration_spec_file).to eq(expected_migration_spec_file) end - assert_file('lib/gitlab/background_migration/my_batched_migration.rb') do |migration_job_file| - expect(migration_job_file).to eq(expected_migration_job_file) - end - - assert_file('spec/lib/gitlab/background_migration/my_batched_migration_spec.rb') do |migration_job_spec_file| - # Regex is used to match the dynamic schema: <version> in the specs - expect(migration_job_spec_file).to match(/#{expected_migration_job_spec_file}/) - end - assert_file('db/docs/batched_background_migrations/my_batched_migration.yml') do |migration_dictionary| # Regex is used to match the dynamically generated 'milestone' in the dictionary expect(migration_dictionary).to match(/#{expected_migration_dictionary}/) @@ -54,23 +47,50 @@ RSpec.describe BatchedBackgroundMigration::BatchedBackgroundMigrationGenerator, end end - context 'without required arguments' do - it 'throws table_name is required error' do - expect do - run_generator %w[my_batched_migration] - end.to raise_error(ArgumentError, 'table_name is required') + context 'when generating EE-only batched background migration' do + before do + run_generator %w[my_batched_migration --table_name=projects --column_name=id --feature_category=database + --ee-only] + end + + let(:expected_ee_migration_job_file) { load_expected_file('ee_my_batched_migration.txt') } + let(:expected_migration_job_spec_file) { load_expected_file('my_batched_migration_spec_matcher.txt') } + + include_examples "generates files common to both types of migrations", + 'foss_my_batched_migration.txt', + 'queue_my_batched_migration.txt', + 'queue_my_batched_migration_spec.txt', + 'my_batched_migration_dictionary_matcher.txt' + + it 'generates expected files' do + assert_file('ee/lib/ee/gitlab/background_migration/my_batched_migration.rb') do |migration_job_file| + expect(migration_job_file).to eq(expected_ee_migration_job_file) + end + + assert_file('ee/spec/lib/ee/gitlab/background_migration/my_batched_migration_spec.rb') do |migration_job_spec_file| # rubocop:disable Layout/LineLength + expect(migration_job_spec_file).to match(/#{expected_migration_job_spec_file}/) + end end + end - it 'throws column_name is required error' do - expect do - run_generator %w[my_batched_migration --table_name=projects] - end.to raise_error(ArgumentError, 'column_name is required') + context 'when generating FOSS batched background migration' do + before do + run_generator %w[my_batched_migration --table_name=projects --column_name=id --feature_category=database] end - it 'throws feature_category is required error' do - expect do - run_generator %w[my_batched_migration --table_name=projects --column_name=id] - end.to raise_error(ArgumentError, 'feature_category is required') + let(:expected_migration_job_spec_file) { load_expected_file('my_batched_migration_spec_matcher.txt') } + + include_examples "generates files common to both types of migrations", + 'my_batched_migration.txt', + 'queue_my_batched_migration.txt', + 'queue_my_batched_migration_spec.txt', + 'my_batched_migration_dictionary_matcher.txt' + + it 'generates expected files' do + assert_file('spec/lib/gitlab/background_migration/my_batched_migration_spec.rb') do |migration_job_spec_file| + # Regex is used to match the dynamic schema: <version> in the specs + expect(migration_job_spec_file).to match(/#{expected_migration_job_spec_file}/) + end end end diff --git a/spec/lib/generators/batched_background_migration/expected_files/ee_my_batched_migration.txt b/spec/lib/generators/batched_background_migration/expected_files/ee_my_batched_migration.txt new file mode 100644 index 00000000000..004ae46ca5f --- /dev/null +++ b/spec/lib/generators/batched_background_migration/expected_files/ee_my_batched_migration.txt @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/database/batched_background_migrations.html +# for more information on how to use batched background migrations + +# Update below commented lines with appropriate values. + +module EE + module Gitlab + module BackgroundMigration + module MyBatchedMigration + extend ActiveSupport::Concern + extend ::Gitlab::Utils::Override + + prepended do + # operation_name :my_operation + # scope_to ->(relation) { relation.where(column: "value") } + end + + override :perform + def perform + each_sub_batch do |sub_batch| + # Your action on each sub_batch + end + end + end + end + end +end diff --git a/spec/lib/generators/batched_background_migration/expected_files/foss_my_batched_migration.txt b/spec/lib/generators/batched_background_migration/expected_files/foss_my_batched_migration.txt new file mode 100644 index 00000000000..7c2e1f4fc04 --- /dev/null +++ b/spec/lib/generators/batched_background_migration/expected_files/foss_my_batched_migration.txt @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Gitlab + module BackgroundMigration + # TODO Add a top-level documentation comment for the class + class MyBatchedMigration < BatchedMigrationJob + feature_category :database + + def perform; end + end + end +end + +Gitlab::BackgroundMigration::MyBatchedMigration.prepend_mod diff --git a/spec/models/integrations/webex_teams_spec.rb b/spec/models/integrations/webex_teams_spec.rb index b5cba6762aa..50a1383292b 100644 --- a/spec/models/integrations/webex_teams_spec.rb +++ b/spec/models/integrations/webex_teams_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -RSpec.describe Integrations::WebexTeams do +RSpec.describe Integrations::WebexTeams, feature_category: :integrations do it_behaves_like "chat integration", "Webex Teams" do let(:client_arguments) { webhook_url } let(:payload) do |