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>2023-06-16 18:09:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-16 18:09:59 +0300
commit0c87da93750c6428328a3e3cd2ebd0882f6294e3 (patch)
tree1b6cb32a86a461e592634249db84f34b44d0c2eb /spec
parentd87800c3cfa21bde64704542d61a587c5ff4306e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/admin/admin_runners_spec.rb2
-rw-r--r--spec/frontend/ci/runner/components/runner_delete_modal_spec.js51
-rw-r--r--spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js9
-rw-r--r--spec/frontend/notes/components/noteable_discussion_spec.js17
-rw-r--r--spec/helpers/search_helper_spec.rb16
-rw-r--r--spec/lib/banzai/filter/inline_alert_metrics_filter_spec.rb21
-rw-r--r--spec/lib/banzai/filter/inline_cluster_metrics_filter_spec.rb25
-rw-r--r--spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb106
-rw-r--r--spec/lib/banzai/filter/inline_metrics_filter_spec.rb78
-rw-r--r--spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb103
-rw-r--r--spec/lib/banzai/pipeline/post_process_pipeline_spec.rb2
-rw-r--r--spec/requests/api/search_spec.rb16
-rw-r--r--spec/services/google_cloud/generate_pipeline_service_spec.rb94
-rw-r--r--spec/services/search_service_spec.rb22
-rw-r--r--spec/support/helpers/metrics_dashboard_url_helpers.rb26
-rw-r--r--spec/support/shared_examples/banzai/filters/inline_embeds_shared_examples.rb64
-rw-r--r--spec/support/shared_examples/banzai/filters/inline_metrics_redactor_shared_examples.rb30
-rw-r--r--spec/support/shared_examples/features/runners_shared_examples.rb2
18 files changed, 210 insertions, 474 deletions
diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb
index 0b06ee5f40f..b81703f728b 100644
--- a/spec/features/admin/admin_runners_spec.rb
+++ b/spec/features/admin/admin_runners_spec.rb
@@ -565,7 +565,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do
click_on 'Delete runner'
within_modal do
- click_on 'Delete runner'
+ click_on 'Permanently delete runner'
end
end
diff --git a/spec/frontend/ci/runner/components/runner_delete_modal_spec.js b/spec/frontend/ci/runner/components/runner_delete_modal_spec.js
index f2fb0206763..606cc46c018 100644
--- a/spec/frontend/ci/runner/components/runner_delete_modal_spec.js
+++ b/spec/frontend/ci/runner/components/runner_delete_modal_spec.js
@@ -20,25 +20,50 @@ describe('RunnerDeleteModal', () => {
});
};
- it('Displays title', () => {
- createComponent();
+ describe.each([null, 0, 1])('for %o runners', (managersCount) => {
+ beforeEach(() => {
+ createComponent({ props: { managersCount } });
+ });
- expect(findGlModal().props('title')).toBe('Delete runner #99 (AABBCCDD)?');
- });
+ it('Displays title', () => {
+ expect(findGlModal().props('title')).toBe('Delete runner #99 (AABBCCDD)?');
+ });
- it('Displays buttons', () => {
- createComponent();
+ it('Displays buttons', () => {
+ expect(findGlModal().props('actionPrimary')).toMatchObject({
+ text: 'Permanently delete runner',
+ });
+ expect(findGlModal().props('actionCancel')).toMatchObject({ text: 'Cancel' });
+ });
- expect(findGlModal().props('actionPrimary')).toMatchObject({ text: 'Delete runner' });
- expect(findGlModal().props('actionCancel')).toMatchObject({ text: 'Cancel' });
+ it('Displays contents', () => {
+ expect(findGlModal().text()).toContain(
+ 'The runner will be permanently deleted and no longer available for projects or groups in the instance. Are you sure you want to continue?',
+ );
+ });
});
- it('Displays contents', () => {
- createComponent();
+ describe('for 2 runners', () => {
+ beforeEach(() => {
+ createComponent({ props: { managersCount: 2 } });
+ });
+
+ it('Displays title', () => {
+ expect(findGlModal().props('title')).toBe('Delete 2 runners?');
+ });
- expect(findGlModal().html()).toContain(
- 'The runner will be permanently deleted and no longer available for projects or groups in the instance. Are you sure you want to continue?',
- );
+ it('Displays buttons', () => {
+ expect(findGlModal().props('actionPrimary')).toMatchObject({
+ text: 'Permanently delete 2 runners',
+ });
+ expect(findGlModal().props('actionCancel')).toMatchObject({ text: 'Cancel' });
+ });
+
+ it('Displays contents', () => {
+ expect(findGlModal().text()).toContain(
+ '2 runners will be permanently deleted and no longer available for projects or groups in the instance. Are you sure you want to continue?',
+ );
+ });
});
describe('When modal is confirmed by the user', () => {
diff --git a/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js b/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js
index 8d6ace165ab..f9e3c314d02 100644
--- a/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js
@@ -1,5 +1,6 @@
import {
getDateWithUTC,
+ getCurrentUtcDate,
newDateAsLocaleTime,
nSecondsAfter,
nSecondsBefore,
@@ -84,3 +85,11 @@ describe('isToday', () => {
});
});
});
+
+describe('getCurrentUtcDate', () => {
+ useFakeDate(2022, 11, 5, 10, 10);
+
+ it('returns the date at midnight', () => {
+ expect(getCurrentUtcDate()).toEqual(new Date('2022-12-05T00:00:00.000Z'));
+ });
+});
diff --git a/spec/frontend/notes/components/noteable_discussion_spec.js b/spec/frontend/notes/components/noteable_discussion_spec.js
index fa3a1979a98..36f89e479e6 100644
--- a/spec/frontend/notes/components/noteable_discussion_spec.js
+++ b/spec/frontend/notes/components/noteable_discussion_spec.js
@@ -177,6 +177,23 @@ describe('noteable_discussion component', () => {
expect(replyWrapper.exists()).toBe(true);
expect(replyWrapper.classes('internal-note')).toBe(true);
});
+
+ it('should add `public-note` class when the discussion is not internal', async () => {
+ const softCopyInternalNotes = [...discussionMock.notes];
+ const mockPublicNotes = softCopyInternalNotes.splice(0, 2);
+ mockPublicNotes[0].internal = false;
+
+ const mockDiscussion = {
+ ...discussionMock,
+ notes: [...mockPublicNotes],
+ };
+ wrapper.setProps({ discussion: mockDiscussion });
+ await nextTick();
+
+ const replyWrapper = wrapper.find('[data-testid="reply-wrapper"]');
+ expect(replyWrapper.exists()).toBe(true);
+ expect(replyWrapper.classes('public-note')).toBe(true);
+ });
});
describe('for resolved thread', () => {
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb
index c168572ab4c..b2606fcfae1 100644
--- a/spec/helpers/search_helper_spec.rb
+++ b/spec/helpers/search_helper_spec.rb
@@ -1321,16 +1321,22 @@ RSpec.describe SearchHelper, feature_category: :global_search do
end
context 'snippet_titles' do
- where(:global_project, :global_show_snippets, :condition) do
- ref(:project) | true | false
- nil | false | false
- ref(:project) | false | false
- nil | true | true
+ where(:global_project, :global_show_snippets, :global_feature_flag_enabled, :condition) do
+ ref(:project) | true | false | false
+ nil | false | false | false
+ ref(:project) | false | false | false
+ nil | true | false | false
+ ref(:project) | true | true | false
+ nil | false | true | false
+ ref(:project) | false | true | false
+ nil | true | true | true
end
with_them do
it 'data item condition is set correctly' do
allow(search_service).to receive(:show_snippets?).and_return(global_show_snippets)
+ allow(self).to receive(:feature_flag_tab_enabled?).with(:global_search_snippet_titles_tab)
+ .and_return(global_feature_flag_enabled)
@project = global_project
expect(search_navigation[:snippet_titles][:condition]).to eq(condition)
diff --git a/spec/lib/banzai/filter/inline_alert_metrics_filter_spec.rb b/spec/lib/banzai/filter/inline_alert_metrics_filter_spec.rb
deleted file mode 100644
index cc6d9c67b1b..00000000000
--- a/spec/lib/banzai/filter/inline_alert_metrics_filter_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Banzai::Filter::InlineAlertMetricsFilter, feature_category: :metrics do
- include FilterSpecHelper
-
- let(:params) { ['foo', 'bar', 12] }
- let(:query_params) { {} }
-
- let(:trigger_url) { urls.metrics_dashboard_namespace_project_prometheus_alert_url(*params, query_params) }
- let(:dashboard_url) { urls.metrics_dashboard_namespace_project_prometheus_alert_url(*params, **query_params, embedded: true, format: :json) }
-
- it_behaves_like 'a metrics embed filter'
-
- context 'with query params specified' do
- let(:query_params) { { timestamp: 'yesterday' } }
-
- it_behaves_like 'a metrics embed filter'
- end
-end
diff --git a/spec/lib/banzai/filter/inline_cluster_metrics_filter_spec.rb b/spec/lib/banzai/filter/inline_cluster_metrics_filter_spec.rb
deleted file mode 100644
index 364a8160094..00000000000
--- a/spec/lib/banzai/filter/inline_cluster_metrics_filter_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Banzai::Filter::InlineClusterMetricsFilter, feature_category: :metrics do
- include FilterSpecHelper
-
- let!(:cluster) { create(:cluster) }
- let!(:project) { create(:project) }
- let(:params) { [project.namespace.path, project.path, cluster.id] }
- let(:query_params) { { group: 'Food metrics', title: 'Pizza Consumption', y_label: 'Slice Count' } }
- let(:trigger_url) { urls.namespace_project_cluster_url(*params, **query_params) }
- let(:dashboard_url) do
- urls.metrics_dashboard_namespace_project_cluster_url(
- *params,
- **{
- embedded: 'true',
- cluster_type: 'project',
- format: :json
- }.merge(query_params)
- )
- end
-
- it_behaves_like 'a metrics embed filter'
-end
diff --git a/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb b/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb
deleted file mode 100644
index 746fa6c48a5..00000000000
--- a/spec/lib/banzai/filter/inline_grafana_metrics_filter_spec.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Banzai::Filter::InlineGrafanaMetricsFilter, feature_category: :metrics do
- include FilterSpecHelper
-
- let_it_be(:project) { create(:project) }
- let_it_be(:grafana_integration) { create(:grafana_integration, project: project) }
-
- let(:input) { %(<a href="#{trigger_url}">example</a>) }
- let(:doc) { filter(input) }
- let(:embed_url) { doc.at_css('.js-render-metrics')['data-dashboard-url'] }
-
- let(:dashboard_path) do
- '/d/XDaNK6amz/gitlab-omnibus-redis' \
- '?from=1570397739557&panelId=14' \
- '&to=1570484139557&var-instance=All'
- end
-
- let(:trigger_url) { grafana_integration.grafana_url + dashboard_path }
- let(:dashboard_url) do
- urls.project_grafana_api_metrics_dashboard_url(
- project,
- grafana_url: trigger_url,
- embedded: true,
- start: "2019-10-06T21:35:39Z",
- end: "2019-10-07T21:35:39Z"
- )
- end
-
- before do
- stub_feature_flags(remove_monitor_metrics: false)
- end
-
- around do |example|
- travel_to(Time.utc(2019, 3, 17, 13, 10)) { example.run }
- end
-
- it_behaves_like 'a metrics embed filter'
-
- context 'when grafana is not configured' do
- before do
- allow(project).to receive(:grafana_integration).and_return(nil)
- end
-
- it 'leaves the markdown unchanged' do
- expect(unescape(doc.to_s)).to eq(input)
- end
- end
-
- context 'when "panelId" parameter is missing' do
- let(:dashboard_path) { '/d/XDaNK6amz/gitlab-omnibus-redis?from=1570397739557&to=1570484139557' }
-
- it_behaves_like 'a metrics embed filter'
- end
-
- context 'when time window parameters are missing' do
- let(:dashboard_path) { '/d/XDaNK6amz/gitlab-omnibus-redis?panelId=16' }
-
- it 'sets the window to the last 8 hrs' do
- expect(embed_url).to include(
- 'from%3D1552799400000', 'to%3D1552828200000',
- 'start=2019-03-17T05%3A10%3A00Z', 'end=2019-03-17T13%3A10%3A00Z'
- )
- end
- end
-
- context 'when "to" parameter is missing' do
- let(:dashboard_path) { '/d/XDaNK6amz/gitlab-omnibus-redis?panelId=16&from=1570397739557' }
-
- it 'sets "to" to 8 hrs after "from"' do
- expect(embed_url).to include(
- 'from%3D1570397739557', 'to%3D1570426539000',
- 'start=2019-10-06T21%3A35%3A39Z', 'end=2019-10-07T05%3A35%3A39Z'
- )
- end
- end
-
- context 'when "from" parameter is missing' do
- let(:dashboard_path) { '/d/XDaNK6amz/gitlab-omnibus-redis?panelId=16&to=1570484139557' }
-
- it 'sets "from" to 8 hrs before "to"' do
- expect(embed_url).to include(
- 'from%3D1570455339000', 'to%3D1570484139557',
- 'start=2019-10-07T13%3A35%3A39Z', 'end=2019-10-07T21%3A35%3A39Z'
- )
- end
- end
-
- context 'when no parameters are provided' do
- let(:dashboard_path) { '/d/XDaNK6amz/gitlab-omnibus-redis' }
-
- it 'inserts a placeholder' do
- expect(embed_url).to be_present
- end
- end
-
- private
-
- # Nokogiri escapes the URLs, but we don't care about that
- # distinction for the purposes of this filter
- def unescape(html)
- CGI.unescapeHTML(html)
- end
-end
diff --git a/spec/lib/banzai/filter/inline_metrics_filter_spec.rb b/spec/lib/banzai/filter/inline_metrics_filter_spec.rb
deleted file mode 100644
index 2a8f4507429..00000000000
--- a/spec/lib/banzai/filter/inline_metrics_filter_spec.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Banzai::Filter::InlineMetricsFilter, feature_category: :metrics do
- include FilterSpecHelper
-
- let(:environment_id) { 12 }
- let(:dashboard_url) { urls.metrics_dashboard_namespace_project_environment_url(*params, **query_params, embedded: true) }
-
- let(:query_params) do
- {
- dashboard: 'config/prometheus/common_metrics.yml',
- group: 'System metrics (Kubernetes)',
- title: 'Core Usage (Pod Average)',
- y_label: 'Cores per Pod'
- }
- end
-
- context 'with /-/environments/:environment_id/metrics URL' do
- let(:params) { ['group', 'project', environment_id] }
- let(:trigger_url) { urls.metrics_namespace_project_environment_url(*params, **query_params) }
-
- context 'with no query params' do
- let(:query_params) { {} }
-
- it_behaves_like 'a metrics embed filter'
- end
-
- context 'with query params' do
- it_behaves_like 'a metrics embed filter'
- end
- end
-
- context 'with /-/metrics?environment=:environment_id URL' do
- let(:params) { %w(group project) }
- let(:trigger_url) { urls.namespace_project_metrics_dashboard_url(*params, **query_params) }
- let(:dashboard_url) do
- urls.metrics_dashboard_namespace_project_environment_url(
- *params.append(environment_id),
- **query_params.except(:environment),
- embedded: true
- )
- end
-
- context 'with query params' do
- it_behaves_like 'a metrics embed filter' do
- before do
- query_params.merge!(environment: environment_id)
- end
- end
- end
-
- context 'with only environment in query params' do
- let(:query_params) { { environment: environment_id } }
-
- it_behaves_like 'a metrics embed filter'
- end
-
- context 'with no query params' do
- let(:query_params) { {} }
-
- it 'ignores metrics URL without environment parameter' do
- input = %(<a href="#{trigger_url}">example</a>)
- filtered_input = filter(input).to_s
-
- expect(CGI.unescape_html(filtered_input)).to eq(input)
- end
- end
- end
-
- it 'leaves links to other dashboards unchanged' do
- url = urls.namespace_project_grafana_api_metrics_dashboard_url('foo', 'bar')
- input = %(<a href="#{url}">example</a>)
-
- expect(filter(input).to_s).to eq(input)
- end
-end
diff --git a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb b/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
deleted file mode 100644
index 3512ae97f54..00000000000
--- a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Banzai::Filter::InlineMetricsRedactorFilter, feature_category: :metrics do
- include FilterSpecHelper
-
- let_it_be(:project) { create(:project) }
-
- let(:url) { urls.metrics_dashboard_project_environment_url(project, 1, embedded: true) }
- let(:input) { %(<a href="#{url}">example</a>) }
- let(:doc) { filter(input) }
-
- context 'without a metrics charts placeholder' do
- it 'leaves regular non-metrics links unchanged' do
- expect(doc.to_s).to eq input
- end
- end
-
- context 'with a metrics charts placeholder' do
- let(:input) { %(<div class="js-render-metrics" data-dashboard-url="#{url}"></div>) }
-
- it_behaves_like 'redacts the embed placeholder'
- it_behaves_like 'retains the embed placeholder when applicable'
-
- context 'with /-/metrics?environment=:environment_id URL' do
- let(:url) { urls.project_metrics_dashboard_url(project, embedded: true, environment: 1) }
-
- it_behaves_like 'redacts the embed placeholder'
- it_behaves_like 'retains the embed placeholder when applicable'
- end
-
- context 'for a grafana dashboard' do
- let(:url) { urls.project_grafana_api_metrics_dashboard_url(project, embedded: true) }
-
- it_behaves_like 'redacts the embed placeholder'
- it_behaves_like 'retains the embed placeholder when applicable'
- end
-
- context 'for a cluster metric embed' do
- let_it_be(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [project]) }
-
- let(:params) { [project.namespace.path, project.path, cluster.id] }
- let(:query_params) { { group: 'Cluster Health', title: 'CPU Usage', y_label: 'CPU (cores)' } }
- let(:url) { urls.metrics_dashboard_namespace_project_cluster_url(*params, **query_params, format: :json) }
-
- context 'with user who can read cluster' do
- it_behaves_like 'redacts the embed placeholder'
- it_behaves_like 'retains the embed placeholder when applicable'
- end
-
- context 'without user who can read cluster' do
- let(:doc) { filter(input, current_user: create(:user)) }
-
- it 'redacts the embed placeholder' do
- expect(doc.to_s).to be_empty
- end
- end
- end
-
- context 'the user has requisite permissions' do
- let(:user) { create(:user) }
- let(:doc) { filter(input, current_user: user) }
-
- before do
- project.add_maintainer(user)
- end
-
- context 'for an internal non-dashboard url' do
- let(:url) { urls.project_url(project) }
-
- it 'leaves the placeholder' do
- expect(doc.to_s).to be_empty
- end
- end
-
- context 'with over 100 embeds' do
- let(:embed) { %(<div class="js-render-metrics" data-dashboard-url="#{url}"></div>) }
- let(:input) { embed * 150 }
-
- it 'redacts ill-advised embeds' do
- expect(doc.to_s.length).to eq(embed.length * 100)
- end
- end
- end
-
- context 'for an alert embed' do
- let_it_be(:alert) { create(:prometheus_alert, project: project) }
-
- let(:url) do
- urls.metrics_dashboard_project_prometheus_alert_url(
- project,
- alert.prometheus_metric_id,
- environment_id: alert.environment_id,
- embedded: true
- )
- end
-
- it_behaves_like 'redacts the embed placeholder'
- it_behaves_like 'retains the embed placeholder when applicable'
- end
- end
-end
diff --git a/spec/lib/banzai/pipeline/post_process_pipeline_spec.rb b/spec/lib/banzai/pipeline/post_process_pipeline_spec.rb
index 072d77f4112..316f836654b 100644
--- a/spec/lib/banzai/pipeline/post_process_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/post_process_pipeline_spec.rb
@@ -36,7 +36,7 @@ RSpec.describe Banzai::Pipeline::PostProcessPipeline, feature_category: :team_pl
end
let(:doc) { HTML::Pipeline.parse(html) }
- let(:non_related_xpath_calls) { 2 }
+ let(:non_related_xpath_calls) { 1 }
it 'searches for attributes only once' do
expect(doc).to receive(:xpath).exactly(non_related_xpath_calls + 1).times
diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb
index a315bca58d1..1b331e9c099 100644
--- a/spec/requests/api/search_spec.rb
+++ b/spec/requests/api/search_spec.rb
@@ -412,6 +412,22 @@ RSpec.describe API::Search, :clean_gitlab_redis_rate_limiting, feature_category:
end
end
+ context 'global snippet search is disabled' do
+ it 'returns forbidden response' do
+ stub_feature_flags(global_search_snippet_titles_tab: false)
+ get api(endpoint, user), params: { search: 'awesome', scope: 'snippet_titles' }
+ expect(response).to have_gitlab_http_status(:forbidden)
+ end
+ end
+
+ context 'global snippet search is enabled' do
+ it 'returns ok response' do
+ stub_feature_flags(global_search_snippet_titles_tab: true)
+ get api(endpoint, user), params: { search: 'awesome', scope: 'snippet_titles' }
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+ end
+
it 'increments the custom search sli error rate with error false if no error occurred' do
expect(Gitlab::Metrics::GlobalSearchSlis).to receive(:record_error_rate).with(
error: false,
diff --git a/spec/services/google_cloud/generate_pipeline_service_spec.rb b/spec/services/google_cloud/generate_pipeline_service_spec.rb
index c18514884ca..b363b7b17b6 100644
--- a/spec/services/google_cloud/generate_pipeline_service_spec.rb
+++ b/spec/services/google_cloud/generate_pipeline_service_spec.rb
@@ -236,4 +236,98 @@ EOF
end
end
end
+
+ describe 'for vision ai' do
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:maintainer) { create(:user) }
+ let_it_be(:service_params) { { action: described_class::ACTION_VISION_AI_PIPELINE } }
+ let_it_be(:service) { described_class.new(project, maintainer, service_params) }
+
+ describe 'when there is no existing pipeline' do
+ before do
+ project.add_maintainer(maintainer)
+ end
+
+ it 'creates a new branch with commit for cloud-run deployment' do
+ response = service.execute
+
+ branch_name = response[:branch_name]
+ commit = response[:commit]
+ local_branches = project.repository.local_branches
+ created_branch = local_branches.find { |branch| branch.name == branch_name }
+
+ expect(response[:status]).to eq(:success)
+ expect(branch_name).to start_with('vision-ai-pipeline-')
+ expect(created_branch).to be_present
+ expect(created_branch.target).to eq(commit[:result])
+ end
+
+ it 'generated pipeline includes vision ai deployment' do
+ response = service.execute
+
+ ref = response[:commit][:result]
+ gitlab_ci_yml = project.repository.gitlab_ci_yml_for(ref)
+
+ expect(response[:status]).to eq(:success)
+ expect(gitlab_ci_yml).to include('https://gitlab.com/gitlab-org/incubation-engineering/five-minute-production/library/-/raw/main/gcp/vision-ai.gitlab-ci.yml')
+ end
+
+ context 'simulate errors' do
+ it 'fails to create branch' do
+ allow_next_instance_of(Branches::CreateService) do |create_service|
+ allow(create_service).to receive(:execute)
+ .and_return({ status: :error })
+ end
+
+ response = service.execute
+ expect(response[:status]).to eq(:error)
+ end
+
+ it 'fails to commit changes' do
+ allow_next_instance_of(Files::CreateService) do |create_service|
+ allow(create_service).to receive(:execute)
+ .and_return({ status: :error })
+ end
+
+ response = service.execute
+ expect(response[:status]).to eq(:error)
+ end
+ end
+ end
+
+ describe 'when there is an existing pipeline with `includes`' do
+ before do
+ project.add_maintainer(maintainer)
+
+ file_name = '.gitlab-ci.yml'
+ file_content = <<EOF
+stages:
+ - validate
+ - detect
+ - render
+
+include:
+ local: 'some-pipeline.yml'
+EOF
+ project.repository.create_file(maintainer,
+ file_name,
+ file_content,
+ message: 'Pipeline with three stages and two jobs',
+ branch_name: project.default_branch)
+ end
+
+ it 'includes the vision ai pipeline' do
+ response = service.execute
+
+ branch_name = response[:branch_name]
+ gitlab_ci_yml = project.repository.gitlab_ci_yml_for(branch_name)
+ pipeline = Gitlab::Config::Loader::Yaml.new(gitlab_ci_yml).load!
+
+ expect(response[:status]).to eq(:success)
+ expect(pipeline[:stages]).to eq(%w[validate detect render])
+ expect(pipeline[:include]).to be_present
+ expect(gitlab_ci_yml).to include('https://gitlab.com/gitlab-org/incubation-engineering/five-minute-production/library/-/raw/main/gcp/vision-ai.gitlab-ci.yml')
+ end
+ end
+ end
end
diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb
index d11fc377d83..c937a93c6ef 100644
--- a/spec/services/search_service_spec.rb
+++ b/spec/services/search_service_spec.rb
@@ -485,6 +485,8 @@ RSpec.describe SearchService, feature_category: :global_search do
'issues' | :global_search_issues_tab | true | true
'merge_requests' | :global_search_merge_requests_tab | false | false
'merge_requests' | :global_search_merge_requests_tab | true | true
+ 'snippet_titles' | :global_search_snippet_titles_tab | false | false
+ 'snippet_titles' | :global_search_snippet_titles_tab | true | true
'wiki_blobs' | :global_search_wiki_tab | false | false
'wiki_blobs' | :global_search_wiki_tab | true | true
'users' | :global_search_users_tab | false | false
@@ -498,5 +500,25 @@ RSpec.describe SearchService, feature_category: :global_search do
expect(subject.global_search_enabled_for_scope?).to eq expected
end
end
+
+ context 'when snippet search is enabled' do
+ let(:scope) { 'snippet_titles' }
+
+ before do
+ allow(described_class).to receive(:show_snippets?).and_return(true)
+ end
+
+ it 'returns false when feature_flag is not enabled' do
+ stub_feature_flags(global_search_snippet_titles_tab: false)
+
+ expect(subject.global_search_enabled_for_scope?).to eq false
+ end
+
+ it 'returns true when feature_flag is enabled' do
+ stub_feature_flags(global_search_snippet_titles_tab: true)
+
+ expect(subject.global_search_enabled_for_scope?).to eq true
+ end
+ end
end
end
diff --git a/spec/support/helpers/metrics_dashboard_url_helpers.rb b/spec/support/helpers/metrics_dashboard_url_helpers.rb
deleted file mode 100644
index 58b3d1e4d1d..00000000000
--- a/spec/support/helpers/metrics_dashboard_url_helpers.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-module MetricsDashboardUrlHelpers
- # Using the url_helpers available in the test suite uses
- # the sample host, but the urls generated may need to
- # point to the configured host in the :js trait
- def urls
- ::Gitlab::Routing.url_helpers
- end
-
- def clear_host_from_memoized_variables
- [:metrics_regex, :grafana_regex, :clusters_regex, :alert_regex].each do |method_name|
- Gitlab::Metrics::Dashboard::Url.clear_memoization(method_name)
- end
- end
-
- def stub_gitlab_domain
- allow_any_instance_of(Banzai::Filter::InlineEmbedsFilter)
- .to receive(:gitlab_domain)
- .and_return(urls.root_url.chomp('/'))
-
- allow(Gitlab::Metrics::Dashboard::Url)
- .to receive(:gitlab_domain)
- .and_return(urls.root_url.chomp('/'))
- end
-end
diff --git a/spec/support/shared_examples/banzai/filters/inline_embeds_shared_examples.rb b/spec/support/shared_examples/banzai/filters/inline_embeds_shared_examples.rb
deleted file mode 100644
index 8f2f3f89914..00000000000
--- a/spec/support/shared_examples/banzai/filters/inline_embeds_shared_examples.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-# frozen_string_literal: true
-
-# Expects 2 attributes to be defined:
-# trigger_url - Url expected to trigger the insertion of a placeholder.
-# dashboard_url - Url expected to be present in the placeholder.
-RSpec.shared_examples 'a metrics embed filter' do
- let(:input) { %(<a href="#{url}">example</a>) }
- let(:doc) { filter(input) }
-
- before do
- stub_feature_flags(remove_monitor_metrics: false)
- end
-
- context 'when the document has an external link' do
- let(:url) { 'https://foo.com' }
-
- it 'leaves regular non-metrics links unchanged' do
- expect(doc.to_s).to eq(input)
- end
- end
-
- context 'when the document contains an embeddable link' do
- let(:url) { trigger_url }
-
- it 'leaves the original link unchanged' do
- expect(unescape(doc.at_css('a').to_s)).to eq(input)
- end
-
- it 'appends a metrics charts placeholder' do
- node = doc.at_css('.js-render-metrics')
- expect(node).to be_present
-
- expect(node.attribute('data-dashboard-url').to_s).to eq(dashboard_url)
- end
-
- context 'in a paragraph' do
- let(:paragraph) { %(This is an <a href="#{url}">example</a> of metrics.) }
- let(:input) { %(<p>#{paragraph}</p>) }
-
- it 'appends a metrics charts placeholder after the enclosing paragraph' do
- expect(unescape(doc.at_css('p').to_s)).to include(paragraph)
- expect(doc.at_css('.js-render-metrics')).to be_present
- end
- end
-
- context 'when metrics dashboard feature is unavailable' do
- before do
- stub_feature_flags(remove_monitor_metrics: true)
- end
-
- it 'does not append a metrics chart placeholder' do
- node = doc.at_css('.js-render-metrics')
-
- expect(node).not_to be_present
- end
- end
- end
-
- # Nokogiri escapes the URLs, but we don't care about that
- # distinction for the purposes of these filters
- def unescape(html)
- CGI.unescapeHTML(html)
- end
-end
diff --git a/spec/support/shared_examples/banzai/filters/inline_metrics_redactor_shared_examples.rb b/spec/support/shared_examples/banzai/filters/inline_metrics_redactor_shared_examples.rb
deleted file mode 100644
index 07abb86ceb5..00000000000
--- a/spec/support/shared_examples/banzai/filters/inline_metrics_redactor_shared_examples.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.shared_examples 'redacts the embed placeholder' do
- context 'no user is logged in' do
- it 'redacts the placeholder' do
- expect(doc.to_s).to be_empty
- end
- end
-
- context 'the user does not have permission do see charts' do
- let(:doc) { filter(input, current_user: build(:user)) }
-
- it 'redacts the placeholder' do
- expect(doc.to_s).to be_empty
- end
- end
-end
-
-RSpec.shared_examples 'retains the embed placeholder when applicable' do
- context 'the user has requisite permissions' do
- let(:user) { create(:user) }
- let(:doc) { filter(input, current_user: user) }
-
- it 'leaves the placeholder' do
- project.add_maintainer(user)
-
- expect(CGI.unescapeHTML(doc.to_s)).to eq(input)
- end
- end
-end
diff --git a/spec/support/shared_examples/features/runners_shared_examples.rb b/spec/support/shared_examples/features/runners_shared_examples.rb
index 94e5df8c7ae..54a4db0e81d 100644
--- a/spec/support/shared_examples/features/runners_shared_examples.rb
+++ b/spec/support/shared_examples/features/runners_shared_examples.rb
@@ -127,7 +127,7 @@ RSpec.shared_examples 'pauses, resumes and deletes a runner' do
it 'deletes a runner' do
within_modal do
- click_on 'Delete runner'
+ click_on 'Permanently delete runner'
end
expect(page.find('.gl-toast')).to have_text(/Runner .+ deleted/)