diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-17 00:06:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-17 00:06:39 +0300 |
commit | d62742b0169769191b32038cf20445a47db3b287 (patch) | |
tree | 0b718d822d0b3bffac1973dcff11b56853e664a2 /spec | |
parent | e18006fc6313b1d04128416cdb5f1533adcdb53e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
7 files changed, 132 insertions, 48 deletions
diff --git a/spec/features/admin/admin_browse_spam_logs_spec.rb b/spec/features/admin/admin_browse_spam_logs_spec.rb index 1f89232759c..c7d52ef441a 100644 --- a/spec/features/admin/admin_browse_spam_logs_spec.rb +++ b/spec/features/admin/admin_browse_spam_logs_spec.rb @@ -25,6 +25,11 @@ RSpec.describe 'Admin browse spam logs', feature_category: :shared do expect(page).to have_link('Trust user') end + it 'passes axe automated accessibility testing', :js do + visit admin_spam_logs_path + expect(page).to be_axe_clean.within('.table').skipping :'link-in-text-block' + end + it 'does not perform N+1 queries' do control_queries = ActiveRecord::QueryRecorder.new { visit admin_spam_logs_path } create(:spam_log) diff --git a/spec/frontend/usage_quotas/storage/components/dependency_proxy_usage_spec.js b/spec/frontend/usage_quotas/storage/components/dependency_proxy_usage_spec.js new file mode 100644 index 00000000000..01245d8c0d0 --- /dev/null +++ b/spec/frontend/usage_quotas/storage/components/dependency_proxy_usage_spec.js @@ -0,0 +1,60 @@ +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import HelpPageLink from '~/vue_shared/components/help_page_link/help_page_link.vue'; +import DependencyProxyUsage from '~/usage_quotas/storage/components/dependency_proxy_usage.vue'; + +describe('Dependency proxy usage component', () => { + /** @type {import('helpers/vue_test_utils_helper').ExtendedWrapper} */ + let wrapper; + + const defaultProps = { + dependencyProxyTotalSize: 512, + }; + + const findDependencyProxySizeSection = () => wrapper.findByTestId('dependency-proxy-size'); + + const createComponent = ({ props = {} } = {}) => { + wrapper = shallowMountExtended(DependencyProxyUsage, { + propsData: { + ...defaultProps, + ...props, + }, + }); + }; + + beforeEach(() => { + createComponent(); + }); + + it('displays the dependency proxy size section when prop is provided', () => { + expect(findDependencyProxySizeSection().props('value')).toBe( + defaultProps.dependencyProxyTotalSize, + ); + }); + + describe('when `dependencyProxyTotalSize` has BigInt value', () => { + const mockDependencyProxyTotalSize = Number.MAX_SAFE_INTEGER; + + beforeEach(() => { + createComponent({ + props: { + dependencyProxyTotalSize: mockDependencyProxyTotalSize, + }, + }); + }); + + it('displays the dependency proxy size section when prop is provided', () => { + expect(findDependencyProxySizeSection().props('value')).toBe(Number.MAX_SAFE_INTEGER); + }); + }); + + it('displays the description section', () => { + const descriptionWrapper = wrapper.findByTestId('dependency-proxy-description'); + const moreInformationComponent = descriptionWrapper.findComponent(HelpPageLink); + + expect(descriptionWrapper.text()).toMatchInterpolatedText( + 'Local proxy used for frequently-accessed upstream Docker images. More information', + ); + expect(moreInformationComponent.text()).toBe('More information'); + expect(moreInformationComponent.props('href')).toBe('user/packages/dependency_proxy/index'); + }); +}); diff --git a/spec/frontend/usage_quotas/storage/components/namespace_storage_app_spec.js b/spec/frontend/usage_quotas/storage/components/namespace_storage_app_spec.js index e4f99d401a2..27fbfbe6c2c 100644 --- a/spec/frontend/usage_quotas/storage/components/namespace_storage_app_spec.js +++ b/spec/frontend/usage_quotas/storage/components/namespace_storage_app_spec.js @@ -1,6 +1,8 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import waitForPromises from 'helpers/wait_for_promises'; import NamespaceStorageApp from '~/usage_quotas/storage/components/namespace_storage_app.vue'; import StorageUsageStatistics from '~/usage_quotas/storage/components/storage_usage_statistics.vue'; +import DependencyProxyUsage from '~/usage_quotas/storage/components/dependency_proxy_usage.vue'; import { defaultNamespaceProvideValues } from '../mock_data'; const defaultProps = { @@ -20,6 +22,8 @@ describe('NamespaceStorageApp', () => { let wrapper; const findStorageUsageStatistics = () => wrapper.findComponent(StorageUsageStatistics); + const findDependencyProxy = () => wrapper.findComponent(DependencyProxyUsage); + const findBreakdownSubtitle = () => wrapper.findByTestId('breakdown-subtitle'); const createComponent = ({ provide = {}, props = {} } = {}) => { wrapper = shallowMountExtended(NamespaceStorageApp, { @@ -33,13 +37,12 @@ describe('NamespaceStorageApp', () => { }, }); }; + beforeEach(() => { + createComponent(); + }); describe('Namespace usage overview', () => { describe('StorageUsageStatistics', () => { - beforeEach(() => { - createComponent(); - }); - it('passes the correct props to StorageUsageStatistics', () => { expect(findStorageUsageStatistics().props()).toMatchObject({ usedStorage: defaultProps.namespace.rootStorageStatistics.storageSize, @@ -48,4 +51,29 @@ describe('NamespaceStorageApp', () => { }); }); }); + + describe('Storage usage breakdown', () => { + it('shows the namespace storage breakdown subtitle', () => { + expect(findBreakdownSubtitle().text()).toBe('Storage usage breakdown'); + }); + + describe('Dependency proxy usage', () => { + it('shows the dependency proxy usage component', async () => { + createComponent({ + provide: { userNamespace: false }, + }); + await waitForPromises(); + + expect(findDependencyProxy().exists()).toBe(true); + }); + + it('does not display the dependency proxy for personal namespaces', () => { + createComponent({ + provide: { userNamespace: true }, + }); + + expect(findDependencyProxy().exists()).toBe(false); + }); + }); + }); }); diff --git a/spec/frontend/usage_quotas/storage/mock_data.js b/spec/frontend/usage_quotas/storage/mock_data.js index 266c1150815..7847ddbe0a4 100644 --- a/spec/frontend/usage_quotas/storage/mock_data.js +++ b/spec/frontend/usage_quotas/storage/mock_data.js @@ -7,4 +7,6 @@ export const defaultProjectProvideValues = { projectPath: '/project-path', }; -export const defaultNamespaceProvideValues = {}; +export const defaultNamespaceProvideValues = { + userNamespace: false, +}; diff --git a/spec/workers/pipeline_schedule_worker_spec.rb b/spec/workers/pipeline_schedule_worker_spec.rb index 5648c5bc4c5..cb5389ee8ca 100644 --- a/spec/workers/pipeline_schedule_worker_spec.rb +++ b/spec/workers/pipeline_schedule_worker_spec.rb @@ -82,16 +82,6 @@ RSpec.describe PipelineScheduleWorker, :sidekiq_inline, feature_category: :conti it 'creates a new pipeline' do expect { subject }.to change { project.ci_pipelines.count }.by(1) end - - context 'with feature flag persist_failed_pipelines_from_schedules disabled' do - before do - stub_feature_flags(persist_failed_pipelines_from_schedules: false) - end - - it 'does not create a new pipeline' do - expect { subject }.not_to change { project.ci_pipelines.count } - end - end end end diff --git a/spec/workers/projects/git_garbage_collect_worker_spec.rb b/spec/workers/projects/git_garbage_collect_worker_spec.rb index 899e3ed2007..7daee107a74 100644 --- a/spec/workers/projects/git_garbage_collect_worker_spec.rb +++ b/spec/workers/projects/git_garbage_collect_worker_spec.rb @@ -69,6 +69,38 @@ RSpec.describe Projects::GitGarbageCollectWorker, feature_category: :source_code expect(project.lfs_objects.reload).not_to include(lfs_object) end + context 'when optimize repository call fails' do + before do + allow(project.repository.gitaly_repository_client).to receive(:optimize_repository).and_raise('Boom') + end + + it 'does not clean up unreferenced LFS objects' do + expect(Gitlab::Cleanup::OrphanLfsFileReferences).not_to receive(:new) + + expect { subject.perform(*params) }.to raise_error('Boom') + + expect(project.lfs_objects.reload).to include(lfs_object) + end + + context 'when feature flag "reorder_garbage_collection_calls" is disabled' do + before do + stub_feature_flags(reorder_garbage_collection_calls: false) + end + + it 'cleans up unreferenced LFS object first' do + expect_next_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences) do |svc| + expect(svc.project).to eq(project) + expect(svc.dry_run).to be_falsy + expect(svc).to receive(:run!).and_call_original + end + + expect { subject.perform(*params) }.to raise_error('Boom') + + expect(project.lfs_objects.reload).not_to include(lfs_object) + end + end + end + it 'catches and logs exceptions' do allow_next_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences) do |svc| allow(svg).to receive(:run!).and_raise(/Failed/) diff --git a/spec/workers/run_pipeline_schedule_worker_spec.rb b/spec/workers/run_pipeline_schedule_worker_spec.rb index 4b46ca1e125..0bf7e11a982 100644 --- a/spec/workers/run_pipeline_schedule_worker_spec.rb +++ b/spec/workers/run_pipeline_schedule_worker_spec.rb @@ -95,20 +95,6 @@ RSpec.describe RunPipelineScheduleWorker, feature_category: :continuous_integrat end end end - - context "when pipeline was not persisted" do - let(:service_response) { instance_double(ServiceResponse, error?: true, message: "Error", payload: pipeline) } - let(:pipeline) { instance_double(Ci::Pipeline, persisted?: false) } - - it "logs a pipeline creation error" do - expect(worker) - .to receive(:log_extra_metadata_on_done) - .with(:pipeline_creation_error, service_response.message) - .and_call_original - - expect(worker.perform(pipeline_schedule.id, user.id)).to eq(service_response.message) - end - end end context 'when schedule is already executed' do @@ -129,25 +115,6 @@ RSpec.describe RunPipelineScheduleWorker, feature_category: :continuous_integrat worker.perform(pipeline_schedule.id, user.id) end end - - context 'with feature flag persist_failed_pipelines_from_schedules disabled' do - before do - stub_feature_flags(persist_failed_pipelines_from_schedules: false) - end - - it 'does not save_on_errors' do - expect(Ci::CreatePipelineService).to receive(:new).with(project, user, ref: pipeline_schedule.ref).and_return(create_pipeline_service) - - expect(create_pipeline_service).to receive(:execute).with( - :schedule, - ignore_skip_ci: true, - save_on_errors: false, - schedule: pipeline_schedule - ) - - worker.perform(pipeline_schedule.id, user.id) - end - end end context 'when database statement timeout happens' do |