Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-23 15:08:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-23 15:08:41 +0300
commit097eb364752b8dbb08758e6b7b98a6e4030792c8 (patch)
tree2cced0bb935a3819f4077eebd96a44f6bbce4ced /spec
parentc71c2ba4c29ed3cc483e528a32f34816c98c39f4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/groups_spec.rb9
-rw-r--r--spec/frontend/admin/application_settings/inactive_project_deletion/components/form_spec.js148
-rw-r--r--spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/cleanup_status_spec.js20
-rw-r--r--spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/registry_header_spec.js2
-rw-r--r--spec/helpers/admin/application_settings/settings_helper_spec.rb34
-rw-r--r--spec/lib/bulk_imports/projects/pipelines/project_attributes_pipeline_spec.rb84
-rw-r--r--spec/requests/projects/usage_quotas_spec.rb21
-rw-r--r--spec/views/admin/application_settings/_repository_check.html.haml_spec.rb75
8 files changed, 312 insertions, 81 deletions
diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb
index ceb4af03f89..fa454cfcc24 100644
--- a/spec/features/groups_spec.rb
+++ b/spec/features/groups_spec.rb
@@ -127,7 +127,7 @@ RSpec.describe 'Group' do
describe 'Mattermost team creation' do
before do
- stub_mattermost_setting(enabled: mattermost_enabled)
+ stub_mattermost_setting(enabled: mattermost_enabled, host: 'https://mattermost.test')
visit new_group_path
click_link 'Create group'
@@ -145,13 +145,14 @@ RSpec.describe 'Group' do
end
it 'updates the team URL on graph path update', :js do
- out_span = find('span[data-bind-out="create_chat_team"]', visible: false)
+ label = find('#group_create_chat_team ~ label[for=group_create_chat_team]')
+ url = 'https://mattermost.test/test-group'
- expect(out_span.text).to be_empty
+ expect(label.text).not_to match(url)
fill_in('group_path', with: 'test-group')
- expect(out_span.text).to eq('test-group')
+ expect(label.text).to match(url)
end
end
diff --git a/spec/frontend/admin/application_settings/inactive_project_deletion/components/form_spec.js b/spec/frontend/admin/application_settings/inactive_project_deletion/components/form_spec.js
new file mode 100644
index 00000000000..2db997942a7
--- /dev/null
+++ b/spec/frontend/admin/application_settings/inactive_project_deletion/components/form_spec.js
@@ -0,0 +1,148 @@
+import { GlFormCheckbox } from '@gitlab/ui';
+import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper';
+import SettingsForm from '~/admin/application_settings/inactive_project_deletion/components/form.vue';
+
+describe('Form component', () => {
+ let wrapper;
+
+ const findEnabledCheckbox = () => wrapper.findComponent(GlFormCheckbox);
+ const findProjectDeletionSettings = () =>
+ wrapper.findByTestId('inactive-project-deletion-settings');
+ const findMinSizeGroup = () => wrapper.findByTestId('min-size-group');
+ const findMinSizeInputGroup = () => wrapper.findByTestId('min-size-input-group');
+ const findMinSizeInput = () => wrapper.findByTestId('min-size-input');
+ const findDeleteAfterMonthsGroup = () => wrapper.findByTestId('delete-after-months-group');
+ const findDeleteAfterMonthsInputGroup = () =>
+ wrapper.findByTestId('delete-after-months-input-group');
+ const findDeleteAfterMonthsInput = () => wrapper.findByTestId('delete-after-months-input');
+ const findSendWarningEmailAfterMonthsGroup = () =>
+ wrapper.findByTestId('send-warning-email-after-months-group');
+ const findSendWarningEmailAfterMonthsInputGroup = () =>
+ wrapper.findByTestId('send-warning-email-after-months-input-group');
+ const findSendWarningEmailAfterMonthsInput = () =>
+ wrapper.findByTestId('send-warning-email-after-months-input');
+
+ const createComponent = (
+ mountFn = shallowMountExtended,
+ propsData = { deleteInactiveProjects: true },
+ ) => {
+ wrapper = mountFn(SettingsForm, { propsData });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('Enable inactive project deletion', () => {
+ it('has the checkbox', () => {
+ createComponent();
+
+ expect(findEnabledCheckbox().exists()).toBe(true);
+ });
+
+ it.each([[true], [false]])(
+ 'when the checkbox is %s then the project deletion settings visibility is set to %s',
+ (visible) => {
+ createComponent(shallowMountExtended, { deleteInactiveProjects: visible });
+
+ expect(findProjectDeletionSettings().exists()).toBe(visible);
+ },
+ );
+ });
+
+ describe('Minimum size for deletion', () => {
+ beforeEach(() => {
+ createComponent(mountExtended);
+ });
+
+ it('has the minimum size input', () => {
+ expect(findMinSizeInput().exists()).toBe(true);
+ });
+
+ it('has the field description', () => {
+ expect(findMinSizeGroup().text()).toContain('Delete inactive projects that exceed');
+ });
+
+ it('has the appended text on the field', () => {
+ expect(findMinSizeInputGroup().text()).toContain('MB');
+ });
+
+ it.each`
+ value | valid
+ ${'0'} | ${true}
+ ${'250'} | ${true}
+ ${'-1'} | ${false}
+ `(
+ 'when the minimum size input has a value of $value, then its validity should be $valid',
+ async ({ value, valid }) => {
+ await findMinSizeInput().find('input').setValue(value);
+
+ expect(findMinSizeGroup().classes('is-valid')).toBe(valid);
+ expect(findMinSizeInput().classes('is-valid')).toBe(valid);
+ },
+ );
+ });
+
+ describe('Delete project after', () => {
+ beforeEach(() => {
+ createComponent(mountExtended);
+ });
+
+ it('has the delete after months input', () => {
+ expect(findDeleteAfterMonthsInput().exists()).toBe(true);
+ });
+
+ it('has the appended text on the field', () => {
+ expect(findDeleteAfterMonthsInputGroup().text()).toContain('months');
+ });
+
+ it.each`
+ value | valid
+ ${'0'} | ${false}
+ ${'1'} | ${false /* Less than the default send warning email months */}
+ ${'2'} | ${true}
+ `(
+ 'when the delete after months input has a value of $value, then its validity should be $valid',
+ async ({ value, valid }) => {
+ await findDeleteAfterMonthsInput().find('input').setValue(value);
+
+ expect(findDeleteAfterMonthsGroup().classes('is-valid')).toBe(valid);
+ expect(findDeleteAfterMonthsInput().classes('is-valid')).toBe(valid);
+ },
+ );
+ });
+
+ describe('Send warning email', () => {
+ beforeEach(() => {
+ createComponent(mountExtended);
+ });
+
+ it('has the send warning email after months input', () => {
+ expect(findSendWarningEmailAfterMonthsInput().exists()).toBe(true);
+ });
+
+ it('has the field description', () => {
+ expect(findSendWarningEmailAfterMonthsGroup().text()).toContain(
+ 'Send email to maintainers after project is inactive for',
+ );
+ });
+
+ it('has the appended text on the field', () => {
+ expect(findSendWarningEmailAfterMonthsInputGroup().text()).toContain('months');
+ });
+
+ it.each`
+ value | valid
+ ${'2'} | ${true}
+ ${'0'} | ${false}
+ `(
+ 'when the minimum size input has a value of $value, then its validity should be $valid',
+ async ({ value, valid }) => {
+ await findSendWarningEmailAfterMonthsInput().find('input').setValue(value);
+
+ expect(findSendWarningEmailAfterMonthsGroup().classes('is-valid')).toBe(valid);
+ expect(findSendWarningEmailAfterMonthsInput().classes('is-valid')).toBe(valid);
+ },
+ );
+ });
+});
diff --git a/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/cleanup_status_spec.js b/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/cleanup_status_spec.js
index af5723267f4..0581a40b6a2 100644
--- a/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/cleanup_status_spec.js
+++ b/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/cleanup_status_spec.js
@@ -1,4 +1,4 @@
-import { GlLink, GlPopover, GlSprintf } from '@gitlab/ui';
+import { GlIcon, GlLink, GlPopover, GlSprintf } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { helpPagePath } from '~/helpers/help_page_helper';
import CleanupStatus from '~/packages_and_registries/container_registry/explorer/components/list_page/cleanup_status.vue';
@@ -16,6 +16,7 @@ describe('cleanup_status', () => {
let wrapper;
const findMainIcon = () => wrapper.findByTestId('main-icon');
+ const findMainIconName = () => wrapper.findByTestId('main-icon').find(GlIcon);
const findExtraInfoIcon = () => wrapper.findByTestId('extra-info');
const findPopover = () => wrapper.findComponent(GlPopover);
@@ -61,6 +62,23 @@ describe('cleanup_status', () => {
expect(findMainIcon().exists()).toBe(true);
});
+
+ it.each`
+ status | visible | iconName
+ ${UNFINISHED_STATUS} | ${true} | ${'expire'}
+ ${SCHEDULED_STATUS} | ${true} | ${'clock'}
+ ${ONGOING_STATUS} | ${true} | ${'clock'}
+ ${UNSCHEDULED_STATUS} | ${false} | ${''}
+ `('matches "$iconName" when the status is "$status"', ({ status, visible, iconName }) => {
+ mountComponent({ status });
+
+ expect(findMainIcon().exists()).toBe(visible);
+ if (visible) {
+ const actualIcon = findMainIconName();
+ expect(actualIcon.exists()).toBe(true);
+ expect(actualIcon.props('name')).toBe(iconName);
+ }
+ });
});
describe('extra info icon', () => {
diff --git a/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/registry_header_spec.js b/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/registry_header_spec.js
index f811468550d..a006de9f00c 100644
--- a/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/registry_header_spec.js
+++ b/spec/frontend/packages_and_registries/container_registry/explorer/components/list_page/registry_header_spec.js
@@ -93,7 +93,7 @@ describe('registry_header', () => {
expect(text.exists()).toBe(true);
expect(text.props()).toMatchObject({
text: EXPIRATION_POLICY_DISABLED_TEXT,
- icon: 'expire',
+ icon: 'clock',
size: 'xl',
});
});
diff --git a/spec/helpers/admin/application_settings/settings_helper_spec.rb b/spec/helpers/admin/application_settings/settings_helper_spec.rb
new file mode 100644
index 00000000000..9981e0d12bd
--- /dev/null
+++ b/spec/helpers/admin/application_settings/settings_helper_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require "spec_helper"
+
+RSpec.describe Admin::ApplicationSettings::SettingsHelper do
+ describe '#inactive_projects_deletion_data' do
+ let(:delete_inactive_projects) { true }
+ let(:inactive_projects_delete_after_months) { 2 }
+ let(:inactive_projects_min_size_mb) { 250 }
+ let(:inactive_projects_send_warning_email_after_months) { 1 }
+
+ let_it_be(:application_settings) { build(:application_setting) }
+
+ before do
+ stub_application_setting(delete_inactive_projects: delete_inactive_projects)
+ stub_application_setting(inactive_projects_delete_after_months: inactive_projects_delete_after_months)
+ stub_application_setting(inactive_projects_min_size_mb: inactive_projects_min_size_mb)
+ stub_application_setting(
+ inactive_projects_send_warning_email_after_months: inactive_projects_send_warning_email_after_months
+ )
+ end
+
+ subject(:result) { helper.inactive_projects_deletion_data(application_settings) }
+
+ it 'has the expected data' do
+ expect(result).to eq({
+ delete_inactive_projects: delete_inactive_projects.to_s,
+ inactive_projects_delete_after_months: inactive_projects_delete_after_months,
+ inactive_projects_min_size_mb: inactive_projects_min_size_mb,
+ inactive_projects_send_warning_email_after_months: inactive_projects_send_warning_email_after_months
+ })
+ end
+ end
+end
diff --git a/spec/lib/bulk_imports/projects/pipelines/project_attributes_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/project_attributes_pipeline_spec.rb
index aa9c7486c27..4320d5dc119 100644
--- a/spec/lib/bulk_imports/projects/pipelines/project_attributes_pipeline_spec.rb
+++ b/spec/lib/bulk_imports/projects/pipelines/project_attributes_pipeline_spec.rb
@@ -54,17 +54,13 @@ RSpec.describe BulkImports::Projects::Pipelines::ProjectAttributesPipeline do
subject(:pipeline) { described_class.new(context) }
- before do
- allow(Dir).to receive(:mktmpdir).with('bulk_imports').and_return(tmpdir)
- end
-
- after do
- FileUtils.remove_entry(tmpdir) if Dir.exist?(tmpdir)
- end
-
describe '#run' do
before do
- allow(pipeline).to receive(:extract).and_return(BulkImports::Pipeline::ExtractedData.new(data: project_attributes))
+ allow_next_instance_of(BulkImports::Common::Extractors::JsonExtractor) do |extractor|
+ allow(extractor).to receive(:extract).and_return(
+ BulkImports::Pipeline::ExtractedData.new(data: project_attributes)
+ )
+ end
pipeline.run
end
@@ -84,46 +80,6 @@ RSpec.describe BulkImports::Projects::Pipelines::ProjectAttributesPipeline do
end
end
- describe '#extract' do
- before do
- file_download_service = instance_double("BulkImports::FileDownloadService")
- file_decompression_service = instance_double("BulkImports::FileDecompressionService")
-
- expect(BulkImports::FileDownloadService)
- .to receive(:new)
- .with(
- configuration: context.configuration,
- relative_url: "/#{entity.pluralized_name}/#{entity.source_full_path}/export_relations/download?relation=self",
- tmpdir: tmpdir,
- filename: 'self.json.gz')
- .and_return(file_download_service)
-
- expect(BulkImports::FileDecompressionService)
- .to receive(:new)
- .with(tmpdir: tmpdir, filename: 'self.json.gz')
- .and_return(file_decompression_service)
-
- expect(file_download_service).to receive(:execute)
- expect(file_decompression_service).to receive(:execute)
- end
-
- it 'downloads, decompresses & decodes json' do
- allow(pipeline).to receive(:json_attributes).and_return("{\"test\":\"test\"}")
-
- extracted_data = pipeline.extract(context)
-
- expect(extracted_data.data).to match_array([{ 'test' => 'test' }])
- end
-
- context 'when json parsing error occurs' do
- it 'raises an error' do
- allow(pipeline).to receive(:json_attributes).and_return("invalid")
-
- expect { pipeline.extract(context) }.to raise_error(BulkImports::Error)
- end
- end
- end
-
describe '#transform' do
it 'removes prohibited attributes from hash' do
input = { 'description' => 'description', 'issues' => [], 'milestones' => [], 'id' => 5 }
@@ -145,35 +101,13 @@ RSpec.describe BulkImports::Projects::Pipelines::ProjectAttributesPipeline do
end
end
- describe '#json_attributes' do
- it 'reads raw json from file' do
- filepath = File.join(tmpdir, 'self.json')
-
- FileUtils.touch(filepath)
- expect_file_read(filepath)
-
- pipeline.json_attributes
- end
- end
-
describe '#after_run' do
- it 'removes tmp dir' do
- allow(FileUtils).to receive(:remove_entry).and_call_original
- expect(FileUtils).to receive(:remove_entry).with(tmpdir).and_call_original
+ it 'calls extractor#remove_tmpdir' do
+ expect_next_instance_of(BulkImports::Common::Extractors::JsonExtractor) do |extractor|
+ expect(extractor).to receive(:remove_tmpdir)
+ end
pipeline.after_run(nil)
-
- expect(Dir.exist?(tmpdir)).to eq(false)
- end
-
- context 'when dir does not exist' do
- it 'does not attempt to remove tmpdir' do
- FileUtils.remove_entry(tmpdir)
-
- expect(FileUtils).not_to receive(:remove_entry).with(tmpdir)
-
- pipeline.after_run(nil)
- end
end
end
diff --git a/spec/requests/projects/usage_quotas_spec.rb b/spec/requests/projects/usage_quotas_spec.rb
index 6e449a21804..3de871823c4 100644
--- a/spec/requests/projects/usage_quotas_spec.rb
+++ b/spec/requests/projects/usage_quotas_spec.rb
@@ -35,5 +35,26 @@ RSpec.describe 'Project Usage Quotas' do
it_behaves_like 'response with 404 status'
end
+
+ context 'container_registry_project_statistics feature flag' do
+ subject(:body) { response.body }
+
+ before do
+ stub_feature_flags(container_registry_project_statistics: container_registry_project_statistics_enabled)
+ get project_usage_quotas_path(project)
+ end
+
+ context 'when disabled' do
+ let(:container_registry_project_statistics_enabled) { false }
+
+ it { is_expected.to have_pushed_frontend_feature_flags(containerRegistryProjectStatistics: false)}
+ end
+
+ context 'when enabled' do
+ let(:container_registry_project_statistics_enabled) { true }
+
+ it { is_expected.to have_pushed_frontend_feature_flags(containerRegistryProjectStatistics: true)}
+ end
+ end
end
end
diff --git a/spec/views/admin/application_settings/_repository_check.html.haml_spec.rb b/spec/views/admin/application_settings/_repository_check.html.haml_spec.rb
new file mode 100644
index 00000000000..fbabc890a8b
--- /dev/null
+++ b/spec/views/admin/application_settings/_repository_check.html.haml_spec.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'admin/application_settings/_repository_check.html.haml' do
+ let_it_be(:user) { create(:admin) }
+ let_it_be(:application_setting) { build(:application_setting) }
+
+ before do
+ assign(:application_setting, application_setting)
+ allow(view).to receive(:current_user).and_return(user)
+ end
+
+ describe 'repository checks' do
+ it 'has the setting subsection' do
+ render
+
+ expect(rendered).to have_content('Repository checks')
+ end
+
+ it 'renders the correct setting subsection content' do
+ render
+
+ expect(rendered).to have_field('Enable repository checks')
+ expect(rendered).to have_link(
+ 'Clear all repository checks',
+ href: clear_repository_check_states_admin_application_settings_path
+ )
+ end
+ end
+
+ describe 'housekeeping' do
+ it 'has the setting subsection' do
+ render
+
+ expect(rendered).to have_content('Housekeeping')
+ end
+
+ it 'renders the correct setting subsection content' do
+ render
+
+ expect(rendered).to have_field('Enable automatic repository housekeeping')
+ expect(rendered).to have_field('Incremental repack period')
+ expect(rendered).to have_field('Full repack period')
+ expect(rendered).to have_field('Git GC period')
+ end
+ end
+
+ describe 'inactive project deletion' do
+ let_it_be(:application_setting) do
+ build(:application_setting,
+ delete_inactive_projects: true,
+ inactive_projects_delete_after_months: 2,
+ inactive_projects_min_size_mb: 250,
+ inactive_projects_send_warning_email_after_months: 1
+ )
+ end
+
+ it 'has the setting subsection' do
+ render
+
+ expect(rendered).to have_content('Inactive project deletion')
+ end
+
+ it 'renders the correct setting subsection content' do
+ render
+
+ expect(rendered).to have_selector('.js-inactive-project-deletion-form')
+ expect(rendered).to have_selector('[data-delete-inactive-projects="true"]')
+ expect(rendered).to have_selector('[data-inactive-projects-delete-after-months="2"]')
+ expect(rendered).to have_selector('[data-inactive-projects-min-size-mb="250"]')
+ expect(rendered).to have_selector('[data-inactive-projects-send-warning-email-after-months="1"]')
+ end
+ end
+end