diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-29 15:08:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-29 15:08:03 +0300 |
commit | ef59e05bd14aea8bf19bbe77c52116bfe24c7107 (patch) | |
tree | 6b3f51c7afd746c2cbe3369fcff9a97b392d6cac /spec | |
parent | e878a8e80f55bb09565ca33408f5295b8784e455 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
12 files changed, 80 insertions, 28 deletions
diff --git a/spec/frontend/alerts_settings/components/alerts_settings_wrapper_spec.js b/spec/frontend/alerts_settings/components/alerts_settings_wrapper_spec.js index 6193233881d..ed185c11732 100644 --- a/spec/frontend/alerts_settings/components/alerts_settings_wrapper_spec.js +++ b/spec/frontend/alerts_settings/components/alerts_settings_wrapper_spec.js @@ -476,9 +476,6 @@ describe('AlertsSettingsWrapper', () => { destroyHttpIntegration(wrapper); expect(destroyIntegrationHandler).toHaveBeenCalled(); - await waitForPromises(); - - expect(findIntegrations()).toHaveLength(3); }); it('displays flash if mutation had a recoverable error', async () => { diff --git a/spec/frontend/alerts_settings/components/mocks/apollo_mock.js b/spec/frontend/alerts_settings/components/mocks/apollo_mock.js index 694dff56632..170af1b5e0c 100644 --- a/spec/frontend/alerts_settings/components/mocks/apollo_mock.js +++ b/spec/frontend/alerts_settings/components/mocks/apollo_mock.js @@ -102,7 +102,7 @@ export const destroyIntegrationResponse = { httpIntegrationDestroy: { errors: [], integration: { - __typename: 'AlertManagementIntegration', + __typename: 'AlertManagementHttpIntegration', id: '37', type: 'HTTP', active: true, diff --git a/spec/frontend/clusters_list/mocks/apollo.js b/spec/frontend/clusters_list/mocks/apollo.js index b0f2978a230..3467b4c665c 100644 --- a/spec/frontend/clusters_list/mocks/apollo.js +++ b/spec/frontend/clusters_list/mocks/apollo.js @@ -1,4 +1,5 @@ const agent = { + __typename: 'ClusterAgent', id: 'agent-id', name: 'agent-name', webPath: 'agent-webPath', diff --git a/spec/frontend/design_management/pages/index_spec.js b/spec/frontend/design_management/pages/index_spec.js index a240a41959f..87531e8b645 100644 --- a/spec/frontend/design_management/pages/index_spec.js +++ b/spec/frontend/design_management/pages/index_spec.js @@ -183,7 +183,7 @@ describe('Design management index page', () => { [moveDesignMutation, moveDesignHandler], ]; - fakeApollo = createMockApollo(requestHandlers); + fakeApollo = createMockApollo(requestHandlers, {}, { addTypename: true }); wrapper = shallowMount(Index, { apolloProvider: fakeApollo, router, diff --git a/spec/frontend/releases/components/app_index_spec.js b/spec/frontend/releases/components/app_index_spec.js index 0d376acf1ae..63ce4c8bb17 100644 --- a/spec/frontend/releases/components/app_index_spec.js +++ b/spec/frontend/releases/components/app_index_spec.js @@ -150,7 +150,8 @@ describe('app_index.vue', () => { expect(findEmptyState().exists()).toBe(emptyState); }); - it(`${toDescription(flashMessage)} show a flash message`, () => { + it(`${toDescription(flashMessage)} show a flash message`, async () => { + await waitForPromises(); if (flashMessage) { expect(createFlash).toHaveBeenCalledWith({ message: ReleasesIndexApp.i18n.errorMessage, diff --git a/spec/frontend/releases/components/app_show_spec.js b/spec/frontend/releases/components/app_show_spec.js index 41c9746a363..c2ea6900d6e 100644 --- a/spec/frontend/releases/components/app_show_spec.js +++ b/spec/frontend/releases/components/app_show_spec.js @@ -143,6 +143,12 @@ describe('Release show component', () => { describe('when the request succeeded, but the returned "project.release" key was null', () => { beforeEach(async () => { + // As we return a release as `null`, Apollo also throws an error to the console + // about the missing field. We need to suppress console.error in order to check + // that flash message was called + + // eslint-disable-next-line no-console + console.error = jest.fn(); const apolloProvider = createMockApollo([ [ oneReleaseQuery, diff --git a/spec/frontend/terraform/components/mock_data.js b/spec/frontend/terraform/components/mock_data.js new file mode 100644 index 00000000000..f0109047d4c --- /dev/null +++ b/spec/frontend/terraform/components/mock_data.js @@ -0,0 +1,35 @@ +export const getStatesResponse = { + data: { + project: { + id: 'project-1', + terraformStates: { + count: 1, + nodes: { + _showDetails: true, + errorMessages: [], + loadingLock: false, + loadingRemove: false, + id: 'state-1', + name: 'state', + lockedAt: '01-01-2022', + updatedAt: '01-01-2022', + lockedByUser: { + id: 'user-1', + avatarUrl: 'avatar', + name: 'User 1', + username: 'user-1', + webUrl: 'web', + }, + latestVersion: null, + }, + pageInfo: { + __typename: 'PageInfo', + hasNextPage: true, + hasPreviousPage: false, + startCursor: 'prev', + endCursor: 'next', + }, + }, + }, + }, +}; diff --git a/spec/frontend/terraform/components/states_table_actions_spec.js b/spec/frontend/terraform/components/states_table_actions_spec.js index a6c80b95af4..d01f6af9023 100644 --- a/spec/frontend/terraform/components/states_table_actions_spec.js +++ b/spec/frontend/terraform/components/states_table_actions_spec.js @@ -9,6 +9,8 @@ import StateActions from '~/terraform/components/states_table_actions.vue'; import lockStateMutation from '~/terraform/graphql/mutations/lock_state.mutation.graphql'; import removeStateMutation from '~/terraform/graphql/mutations/remove_state.mutation.graphql'; import unlockStateMutation from '~/terraform/graphql/mutations/unlock_state.mutation.graphql'; +import getStatesQuery from '~/terraform/graphql/queries/get_states.query.graphql'; +import { getStatesResponse } from './mock_data'; Vue.use(VueApollo); @@ -49,6 +51,7 @@ describe('StatesTableActions', () => { [lockStateMutation, lockResponse], [removeStateMutation, removeResponse], [unlockStateMutation, unlockResponse], + [getStatesQuery, jest.fn().mockResolvedValue(getStatesResponse)], ], { Mutation: { diff --git a/spec/lib/gitlab/database/background_migration/batch_metrics_spec.rb b/spec/lib/gitlab/database/background_migration/batch_metrics_spec.rb index 66983733411..6db3081ca7e 100644 --- a/spec/lib/gitlab/database/background_migration/batch_metrics_spec.rb +++ b/spec/lib/gitlab/database/background_migration/batch_metrics_spec.rb @@ -10,7 +10,6 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchMetrics do expect(batch_metrics.timings).to be_empty expect(Gitlab::Metrics::System).to receive(:monotonic_time) - .exactly(6).times .and_return(0.0, 111.0, 200.0, 290.0, 300.0, 410.0) batch_metrics.time_operation(:my_label) do @@ -28,4 +27,33 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchMetrics do expect(batch_metrics.timings).to eq(my_label: [111.0, 110.0], my_other_label: [90.0]) end end + + describe '#instrument_operation' do + it 'tracks duration and affected rows' do + expect(batch_metrics.timings).to be_empty + expect(batch_metrics.affected_rows).to be_empty + + expect(Gitlab::Metrics::System).to receive(:monotonic_time) + .and_return(0.0, 111.0, 200.0, 290.0, 300.0, 410.0, 420.0, 450.0) + + batch_metrics.instrument_operation(:my_label) do + 3 + end + + batch_metrics.instrument_operation(:my_other_label) do + 42 + end + + batch_metrics.instrument_operation(:my_label) do + 2 + end + + batch_metrics.instrument_operation(:my_other_label) do + :not_an_integer + end + + expect(batch_metrics.timings).to eq(my_label: [111.0, 110.0], my_other_label: [90.0, 30.0]) + expect(batch_metrics.affected_rows).to eq(my_label: [3, 2], my_other_label: [42]) + end + end end diff --git a/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb b/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb index 6a19afbc60d..9f7c8d691f7 100644 --- a/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb +++ b/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb @@ -295,25 +295,6 @@ RSpec.describe Gitlab::GithubImport::ParallelScheduling do importer.parallel_import end end - - context 'when FF is disabled' do - before do - stub_feature_flags(spread_parallel_import: false) - end - - it 'imports data in parallel' do - expect(importer) - .to receive(:each_object_to_import) - .and_yield(object) - - expect(worker_class) - .to receive(:perform_async) - .with(project.id, { title: 'Foo' }, an_instance_of(String)) - - expect(importer.parallel_import) - .to be_an_instance_of(Gitlab::JobWaiter) - end - end end describe '#each_object_to_import' do diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 94e0e8a9ea1..b00ee61004e 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -800,7 +800,7 @@ RSpec.describe QuickActions::InterpretService do let(:project) { repository_project } let(:service) { described_class.new(project, developer, {}) } - it_behaves_like 'failed command', 'Merge request diff sha parameter is required for the merge quick action.' do + it_behaves_like 'failed command', 'The `/merge` quick action requires the SHA of the head of the branch.' do let(:content) { "/merge" } let(:issuable) { merge_request } end diff --git a/spec/support/helpers/gitaly_setup.rb b/spec/support/helpers/gitaly_setup.rb index a4ee618457d..0ad83bdeeb2 100644 --- a/spec/support/helpers/gitaly_setup.rb +++ b/spec/support/helpers/gitaly_setup.rb @@ -267,7 +267,7 @@ module GitalySetup { 'default' => repos_path }, force: true, options: { - internal_socket_dir: File.join(gitaly_dir, "internal_gitaly2"), + runtime_dir: File.join(gitaly_dir, "run2"), gitaly_socket: "gitaly2.socket", config_filename: "gitaly2.config.toml" } |