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:
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap59
-rw-r--r--spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js24
-rw-r--r--spec/lib/google_api/cloud_platform/client_spec.rb12
-rw-r--r--spec/migrations/swap_notes_id_to_bigint_for_gitlab_dot_com_spec.rb66
-rw-r--r--spec/services/google_cloud/enable_vision_ai_service_spec.rb38
-rw-r--r--spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb3
6 files changed, 172 insertions, 30 deletions
diff --git a/spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap b/spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap
index ba8215f4e00..0bee37dbf15 100644
--- a/spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap
+++ b/spec/frontend/artifacts_settings/components/__snapshots__/keep_latest_artifact_checkbox_spec.js.snap
@@ -1,32 +1,57 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Keep latest artifact checkbox when application keep latest artifact setting is enabled sets correct setting value in checkbox with query result 1`] = `
+exports[`Keep latest artifact toggle when application keep latest artifact setting is enabled sets correct setting value in toggle with query result 1`] = `
<div>
<!---->
- <b-form-checkbox-stub
- checked="true"
- class="gl-form-checkbox"
- id="4"
- value="true"
+ <div
+ class="gl-toggle-wrapper gl-display-flex gl-mb-0 gl-flex-direction-column"
+ data-testid="toggle-wrapper"
>
- <strong
- class="gl-mr-3"
+ <span
+ class="gl-toggle-label gl-flex-shrink-0 gl-mb-3"
+ data-testid="toggle-label"
+ id="toggle-label-4"
>
Keep artifacts from most recent successful jobs
- </strong>
+ </span>
- <gl-link-stub
- href="/help/ci/pipelines/job_artifacts"
+ <!---->
+
+ <!---->
+
+ <button
+ aria-checked="true"
+ aria-describedby="toggle-help-2"
+ aria-labelledby="toggle-label-4"
+ class="gl-flex-shrink-0 gl-toggle is-checked"
+ role="switch"
+ type="button"
>
- More information
- </gl-link-stub>
+ <span
+ class="toggle-icon"
+ >
+ <gl-icon-stub
+ name="mobile-issue-close"
+ size="16"
+ />
+ </span>
+ </button>
- <p
- class="help-text"
+ <span
+ class="gl-help-label"
+ data-testid="toggle-help"
+ id="toggle-help-2"
>
+
The latest artifacts created by jobs in the most recent successful pipeline will be stored.
- </p>
- </b-form-checkbox-stub>
+
+ <gl-link-stub
+ href="/help/ci/pipelines/job_artifacts"
+ >
+ Learn more.
+ </gl-link-stub>
+ </span>
+ </div>
</div>
`;
diff --git a/spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js b/spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js
index 8dafff350f2..d0a7515432b 100644
--- a/spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js
+++ b/spec/frontend/artifacts_settings/components/keep_latest_artifact_checkbox_spec.js
@@ -1,4 +1,4 @@
-import { GlFormCheckbox, GlLink } from '@gitlab/ui';
+import { GlToggle, GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
@@ -7,7 +7,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import UpdateKeepLatestArtifactProjectSetting from '~/artifacts_settings/graphql/mutations/update_keep_latest_artifact_project_setting.mutation.graphql';
import GetKeepLatestArtifactApplicationSetting from '~/artifacts_settings/graphql/queries/get_keep_latest_artifact_application_setting.query.graphql';
import GetKeepLatestArtifactProjectSetting from '~/artifacts_settings/graphql/queries/get_keep_latest_artifact_project_setting.query.graphql';
-import KeepLatestArtifactCheckbox from '~/artifacts_settings/keep_latest_artifact_checkbox.vue';
+import KeepLatestArtifactToggle from '~/artifacts_settings/keep_latest_artifact_toggle.vue';
Vue.use(VueApollo);
@@ -34,7 +34,7 @@ const keepLatestArtifactMockResponse = {
},
};
-describe('Keep latest artifact checkbox', () => {
+describe('Keep latest artifact toggle', () => {
let wrapper;
let apolloProvider;
let requestHandlers;
@@ -42,7 +42,7 @@ describe('Keep latest artifact checkbox', () => {
const fullPath = 'gitlab-org/gitlab';
const helpPagePath = '/help/ci/pipelines/job_artifacts';
- const findCheckbox = () => wrapper.findComponent(GlFormCheckbox);
+ const findToggle = () => wrapper.findComponent(GlToggle);
const findHelpLink = () => wrapper.findComponent(GlLink);
const createComponent = (handlers) => {
@@ -68,13 +68,13 @@ describe('Keep latest artifact checkbox', () => {
[UpdateKeepLatestArtifactProjectSetting, requestHandlers.keepLatestArtifactMutationHandler],
]);
- wrapper = shallowMount(KeepLatestArtifactCheckbox, {
+ wrapper = shallowMount(KeepLatestArtifactToggle, {
provide: {
fullPath,
helpPagePath,
},
stubs: {
- GlFormCheckbox,
+ GlToggle,
},
apolloProvider,
});
@@ -89,13 +89,13 @@ describe('Keep latest artifact checkbox', () => {
createComponent();
});
- it('displays the checkbox and the help link', () => {
- expect(findCheckbox().exists()).toBe(true);
+ it('displays the toggle and the help link', () => {
+ expect(findToggle().exists()).toBe(true);
expect(findHelpLink().exists()).toBe(true);
});
it('calls mutation on artifact setting change with correct payload', () => {
- findCheckbox().vm.$emit('change', false);
+ findToggle().vm.$emit('change', false);
expect(requestHandlers.keepLatestArtifactMutationHandler).toHaveBeenCalledWith({
fullPath,
@@ -110,12 +110,12 @@ describe('Keep latest artifact checkbox', () => {
await waitForPromises();
});
- it('sets correct setting value in checkbox with query result', () => {
+ it('sets correct setting value in toggle with query result', () => {
expect(wrapper.element).toMatchSnapshot();
});
- it('checkbox is enabled when application setting is enabled', () => {
- expect(findCheckbox().attributes('disabled')).toBeUndefined();
+ it('toggle is enabled when application setting is enabled', () => {
+ expect(findToggle().attributes('disabled')).toBeUndefined();
});
});
});
diff --git a/spec/lib/google_api/cloud_platform/client_spec.rb b/spec/lib/google_api/cloud_platform/client_spec.rb
index 4ea395830ad..057bae1b38c 100644
--- a/spec/lib/google_api/cloud_platform/client_spec.rb
+++ b/spec/lib/google_api/cloud_platform/client_spec.rb
@@ -254,6 +254,18 @@ RSpec.describe GoogleApi::CloudPlatform::Client do
end
end
+ describe '#enable_visionai' do
+ subject { client.enable_vision_api(gcp_project_id) }
+
+ it 'calls Google Api ServiceUsageService' do
+ expect_any_instance_of(Google::Apis::ServiceusageV1::ServiceUsageService)
+ .to receive(:enable_service)
+ .with("projects/#{gcp_project_id}/services/vision.googleapis.com")
+ .and_return(operation)
+ is_expected.to eq(operation)
+ end
+ end
+
describe '#revoke_authorizations' do
subject { client.revoke_authorizations }
diff --git a/spec/migrations/swap_notes_id_to_bigint_for_gitlab_dot_com_spec.rb b/spec/migrations/swap_notes_id_to_bigint_for_gitlab_dot_com_spec.rb
new file mode 100644
index 00000000000..d2e64296a70
--- /dev/null
+++ b/spec/migrations/swap_notes_id_to_bigint_for_gitlab_dot_com_spec.rb
@@ -0,0 +1,66 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe SwapNotesIdToBigintForGitlabDotCom, feature_category: :database do
+ describe '#up' do
+ before do
+ # A we call `schema_migrate_down!` before each example, and for this migration
+ # `#down` is same as `#up`, we need to ensure we start from the expected state.
+ connection = described_class.new.connection
+ connection.execute('ALTER TABLE notes ALTER COLUMN id TYPE integer')
+ connection.execute('ALTER TABLE notes ALTER COLUMN id_convert_to_bigint TYPE bigint')
+ end
+
+ # rubocop: disable RSpec/AnyInstanceOf
+ it 'swaps the integer and bigint columns for GitLab.com, dev, or test' do
+ allow_any_instance_of(described_class).to receive(:com_or_dev_or_test_but_not_jh?).and_return(true)
+
+ notes = table(:notes)
+
+ disable_migrations_output do
+ reversible_migration do |migration|
+ migration.before -> {
+ notes.reset_column_information
+
+ expect(notes.columns.find { |c| c.name == 'id' }.sql_type).to eq('integer')
+ expect(notes.columns.find { |c| c.name == 'id_convert_to_bigint' }.sql_type).to eq('bigint')
+ }
+
+ migration.after -> {
+ notes.reset_column_information
+
+ expect(notes.columns.find { |c| c.name == 'id' }.sql_type).to eq('bigint')
+ expect(notes.columns.find { |c| c.name == 'id_convert_to_bigint' }.sql_type).to eq('integer')
+ }
+ end
+ end
+ end
+
+ it 'is a no-op for other instances' do
+ allow_any_instance_of(described_class).to receive(:com_or_dev_or_test_but_not_jh?).and_return(false)
+
+ notes = table(:notes)
+
+ disable_migrations_output do
+ reversible_migration do |migration|
+ migration.before -> {
+ notes.reset_column_information
+
+ expect(notes.columns.find { |c| c.name == 'id' }.sql_type).to eq('integer')
+ expect(notes.columns.find { |c| c.name == 'id_convert_to_bigint' }.sql_type).to eq('bigint')
+ }
+
+ migration.after -> {
+ notes.reset_column_information
+
+ expect(notes.columns.find { |c| c.name == 'id' }.sql_type).to eq('integer')
+ expect(notes.columns.find { |c| c.name == 'id_convert_to_bigint' }.sql_type).to eq('bigint')
+ }
+ end
+ end
+ end
+ # rubocop: enable RSpec/AnyInstanceOf
+ end
+end
diff --git a/spec/services/google_cloud/enable_vision_ai_service_spec.rb b/spec/services/google_cloud/enable_vision_ai_service_spec.rb
new file mode 100644
index 00000000000..5adafcffe69
--- /dev/null
+++ b/spec/services/google_cloud/enable_vision_ai_service_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe GoogleCloud::EnableVisionAiService, feature_category: :deployment_management do
+ describe 'when a project does not have any gcp projects' do
+ let_it_be(:project) { create(:project) }
+
+ it 'returns error' do
+ result = described_class.new(project).execute
+ message = 'No GCP projects found. Configure a service account or GCP_PROJECT_ID ci variable.'
+
+ expect(result[:status]).to eq(:error)
+ expect(result[:message]).to eq(message)
+ end
+ end
+
+ describe 'when a project has 3 gcp projects' do
+ let_it_be(:project) { create(:project) }
+
+ before do
+ project.variables.build(environment_scope: 'production', key: 'GCP_PROJECT_ID', value: 'prj-prod')
+ project.variables.build(environment_scope: 'staging', key: 'GCP_PROJECT_ID', value: 'prj-staging')
+ project.save!
+ end
+
+ it 'enables cloud run, artifacts registry and cloud build', :aggregate_failures do
+ expect_next_instance_of(GoogleApi::CloudPlatform::Client) do |instance|
+ expect(instance).to receive(:enable_vision_api).with('prj-prod')
+ expect(instance).to receive(:enable_vision_api).with('prj-staging')
+ end
+
+ result = described_class.new(project).execute
+
+ expect(result[:status]).to eq(:success)
+ end
+ end
+end
diff --git a/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb b/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb
index a332fdec963..8ebec19a884 100644
--- a/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb
+++ b/spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb
@@ -47,7 +47,8 @@ RSpec.shared_examples 'labels sidebar widget' do
end
end
- it 'adds first label by pressing enter when search' do
+ it 'adds first label by pressing enter when search',
+ quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/414877' do
within(labels_widget) do
page.within('[data-testid="value-wrapper"]') do
expect(page).not_to have_content(development.name)