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-07-04 12:11:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-04 12:11:02 +0300
commit5f95234f7babb69685710dbfc637f29eeac2a917 (patch)
tree703240ac11f4565a81c505aa10821fbbd506d888 /spec
parent18160560396d57c07a9525eb033e66afb1f07674 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/groups/group_members_controller_spec.rb2
-rw-r--r--spec/controllers/projects/project_members_controller_spec.rb2
-rw-r--r--spec/experiments/force_company_trial_experiment_spec.rb24
-rw-r--r--spec/features/issues/user_creates_issue_spec.rb2
-rw-r--r--spec/features/issues/user_edits_issue_spec.rb2
-rw-r--r--spec/features/merge_request/user_sees_deployment_widget_spec.rb2
-rw-r--r--spec/frontend/boards/components/board_new_issue_spec.js61
-rw-r--r--spec/frontend/boards/stores/actions_spec.js8
-rw-r--r--spec/graphql/mutations/alert_management/prometheus_integration/create_spec.rb13
-rw-r--r--spec/models/integrations/prometheus_spec.rb8
-rw-r--r--spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb19
-rw-r--r--spec/services/projects/update_service_spec.rb2
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb2
-rw-r--r--spec/support/helpers/features/iteration_helpers.rb2
-rw-r--r--spec/support/shared_examples/features/sidebar/sidebar_due_date_shared_examples.rb2
-rw-r--r--spec/tooling/danger/experiments_spec.rb59
16 files changed, 163 insertions, 47 deletions
diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb
index fe4b80e12fe..feebdd972aa 100644
--- a/spec/controllers/groups/group_members_controller_spec.rb
+++ b/spec/controllers/groups/group_members_controller_spec.rb
@@ -234,7 +234,7 @@ RSpec.describe Groups::GroupMembersController do
it 'returns correct json response' do
expect(json_response).to eq({
"expires_soon" => false,
- "expires_at_formatted" => expiry_date.to_time.in_time_zone.to_s(:medium)
+ "expires_at_formatted" => expiry_date.to_time.in_time_zone.to_fs(:medium)
})
end
end
diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb
index ad49529b426..9657cf33afd 100644
--- a/spec/controllers/projects/project_members_controller_spec.rb
+++ b/spec/controllers/projects/project_members_controller_spec.rb
@@ -320,7 +320,7 @@ RSpec.describe Projects::ProjectMembersController do
it 'returns correct json response' do
expect(json_response).to eq({
"expires_soon" => false,
- "expires_at_formatted" => expiry_date.to_time.in_time_zone.to_s(:medium)
+ "expires_at_formatted" => expiry_date.to_time.in_time_zone.to_fs(:medium)
})
end
end
diff --git a/spec/experiments/force_company_trial_experiment_spec.rb b/spec/experiments/force_company_trial_experiment_spec.rb
deleted file mode 100644
index 42a3245771a..00000000000
--- a/spec/experiments/force_company_trial_experiment_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe ForceCompanyTrialExperiment, :experiment do
- subject { described_class.new(current_user: user) }
-
- let(:user) { create(:user, setup_for_company: setup_for_company) }
- let(:setup_for_company) { true }
-
- context 'when a user is setup_for_company' do
- it 'is not excluded' do
- expect(subject).not_to exclude(user: user)
- end
- end
-
- context 'when a user is not setup_for_company' do
- let(:setup_for_company) { nil }
-
- it 'is excluded' do
- expect(subject).to exclude(user: user)
- end
- end
-end
diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb
index d4148717f0a..57183b2e8d9 100644
--- a/spec/features/issues/user_creates_issue_spec.rb
+++ b/spec/features/issues/user_creates_issue_spec.rb
@@ -159,7 +159,7 @@ RSpec.describe "User creates issue", feature_category: :team_planning do
click_button 'Create issue'
page.within '.issuable-sidebar' do
- expect(page).to have_content date.to_s(:medium)
+ expect(page).to have_content date.to_fs(:medium)
end
end
end
diff --git a/spec/features/issues/user_edits_issue_spec.rb b/spec/features/issues/user_edits_issue_spec.rb
index 7e54580b085..47c532c3963 100644
--- a/spec/features/issues/user_edits_issue_spec.rb
+++ b/spec/features/issues/user_edits_issue_spec.rb
@@ -82,7 +82,7 @@ RSpec.describe "Issues > User edits issue", :js, feature_category: :team_plannin
click_button _('Save changes')
page.within '.issuable-sidebar' do
- expect(page).to have_content date.to_s(:medium)
+ expect(page).to have_content date.to_fs(:medium)
end
end
diff --git a/spec/features/merge_request/user_sees_deployment_widget_spec.rb b/spec/features/merge_request/user_sees_deployment_widget_spec.rb
index 44660b247a1..d237faba663 100644
--- a/spec/features/merge_request/user_sees_deployment_widget_spec.rb
+++ b/spec/features/merge_request/user_sees_deployment_widget_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe 'Merge request > User sees deployment widget', :js, feature_categ
wait_for_requests
assert_env_widget("Deployed to", environment.name)
- expect(find('.js-deploy-time')['title']).to eq(deployment.created_at.to_time.in_time_zone.to_s(:medium))
+ expect(find('.js-deploy-time')['title']).to eq(deployment.created_at.to_time.in_time_zone.to_fs(:medium))
end
context 'when a user created a new merge request with the same SHA' do
diff --git a/spec/frontend/boards/components/board_new_issue_spec.js b/spec/frontend/boards/components/board_new_issue_spec.js
index 8c4a1b9e5c5..a1088f1e8f7 100644
--- a/spec/frontend/boards/components/board_new_issue_spec.js
+++ b/spec/frontend/boards/components/board_new_issue_spec.js
@@ -1,26 +1,49 @@
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import Vuex from 'vuex';
+import VueApollo from 'vue-apollo';
+import createMockApollo from 'helpers/mock_apollo_helper';
import BoardNewIssue from '~/boards/components/board_new_issue.vue';
import BoardNewItem from '~/boards/components/board_new_item.vue';
import ProjectSelect from '~/boards/components/project_select.vue';
import eventHub from '~/boards/eventhub';
-
-import { mockList, mockGroupProjects, mockIssue, mockIssue2 } from '../mock_data';
+import groupBoardQuery from '~/boards/graphql/group_board.query.graphql';
+import projectBoardQuery from '~/boards/graphql/project_board.query.graphql';
+import { WORKSPACE_GROUP, WORKSPACE_PROJECT } from '~/issues/constants';
+
+import {
+ mockList,
+ mockGroupProjects,
+ mockIssue,
+ mockIssue2,
+ mockProjectBoardResponse,
+ mockGroupBoardResponse,
+} from '../mock_data';
Vue.use(Vuex);
+Vue.use(VueApollo);
const addListNewIssuesSpy = jest.fn().mockResolvedValue();
const mockActions = { addListNewIssue: addListNewIssuesSpy };
+const projectBoardQueryHandlerSuccess = jest.fn().mockResolvedValue(mockProjectBoardResponse);
+const groupBoardQueryHandlerSuccess = jest.fn().mockResolvedValue(mockGroupBoardResponse);
+
+const mockApollo = createMockApollo([
+ [projectBoardQuery, projectBoardQueryHandlerSuccess],
+ [groupBoardQuery, groupBoardQueryHandlerSuccess],
+]);
+
const createComponent = ({
state = {},
actions = mockActions,
getters = { getBoardItemsByList: () => () => [] },
isGroupBoard = true,
data = { selectedProject: mockGroupProjects[0] },
+ provide = {},
} = {}) =>
shallowMount(BoardNewIssue, {
+ apolloProvider: mockApollo,
store: new Vuex.Store({
state,
actions,
@@ -28,6 +51,7 @@ const createComponent = ({
}),
propsData: {
list: mockList,
+ boardId: 'gid://gitlab/Board/1',
},
data: () => data,
provide: {
@@ -36,6 +60,10 @@ const createComponent = ({
weightFeatureAvailable: false,
boardWeight: null,
isGroupBoard,
+ boardType: 'group',
+ isEpicBoard: false,
+ isApolloBoard: false,
+ ...provide,
},
stubs: {
BoardNewItem,
@@ -139,4 +167,33 @@ describe('Issue boards new issue form', () => {
expect(projectSelect.exists()).toBe(false);
});
});
+
+ describe('Apollo boards', () => {
+ it.each`
+ boardType | queryHandler | notCalledHandler
+ ${WORKSPACE_GROUP} | ${groupBoardQueryHandlerSuccess} | ${projectBoardQueryHandlerSuccess}
+ ${WORKSPACE_PROJECT} | ${projectBoardQueryHandlerSuccess} | ${groupBoardQueryHandlerSuccess}
+ `(
+ 'fetches $boardType board and emits addNewIssue event',
+ async ({ boardType, queryHandler, notCalledHandler }) => {
+ wrapper = createComponent({
+ provide: {
+ boardType,
+ isProjectBoard: boardType === WORKSPACE_PROJECT,
+ isGroupBoard: boardType === WORKSPACE_GROUP,
+ isApolloBoard: true,
+ },
+ });
+
+ await nextTick();
+ findBoardNewItem().vm.$emit('form-submit', { title: 'Foo' });
+
+ await nextTick();
+
+ expect(queryHandler).toHaveBeenCalled();
+ expect(notCalledHandler).not.toHaveBeenCalled();
+ expect(wrapper.emitted('addNewIssue')[0][0]).toMatchObject({ title: 'Foo' });
+ },
+ );
+ });
});
diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js
index f3800ce8324..a2961fb1302 100644
--- a/spec/frontend/boards/stores/actions_spec.js
+++ b/spec/frontend/boards/stores/actions_spec.js
@@ -1541,8 +1541,8 @@ describe('addListNewIssue', () => {
it('should add board scope to the issue being created', async () => {
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
data: {
- createIssue: {
- issue: mockIssue,
+ createIssuable: {
+ issuable: mockIssue,
errors: [],
},
},
@@ -1600,8 +1600,8 @@ describe('addListNewIssue', () => {
it('dispatches a correct set of mutations', () => {
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
data: {
- createIssue: {
- issue: mockIssue,
+ createIssuable: {
+ issuable: mockIssue,
errors: [],
},
},
diff --git a/spec/graphql/mutations/alert_management/prometheus_integration/create_spec.rb b/spec/graphql/mutations/alert_management/prometheus_integration/create_spec.rb
index 164bd9b1e39..c92aeb43f51 100644
--- a/spec/graphql/mutations/alert_management/prometheus_integration/create_spec.rb
+++ b/spec/graphql/mutations/alert_management/prometheus_integration/create_spec.rb
@@ -6,7 +6,8 @@ RSpec.describe Mutations::AlertManagement::PrometheusIntegration::Create do
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project) }
- let(:args) { { project_path: project.full_path, active: true, api_url: 'http://prometheus.com/' } }
+ let(:api_url) { 'http://prometheus.com/' }
+ let(:args) { { project_path: project.full_path, active: true, api_url: api_url } }
specify { expect(described_class).to require_graphql_authorizations(:admin_project) }
@@ -29,6 +30,14 @@ RSpec.describe Mutations::AlertManagement::PrometheusIntegration::Create do
end
end
+ context 'when api_url is nil' do
+ let(:api_url) { nil }
+
+ it 'creates the integration' do
+ expect { resolve }.to change(::Alerting::ProjectAlertingSetting, :count).by(1)
+ end
+ end
+
context 'when UpdateService responds with success' do
it 'returns the integration with no errors' do
expect(resolve).to eq(
@@ -38,7 +47,7 @@ RSpec.describe Mutations::AlertManagement::PrometheusIntegration::Create do
end
it 'creates a corresponding token' do
- expect { resolve }.to change(::Alerting::ProjectAlertingSetting, :count).by(1)
+ expect { resolve }.to change(::Integrations::Prometheus, :count).by(1)
end
end
diff --git a/spec/models/integrations/prometheus_spec.rb b/spec/models/integrations/prometheus_spec.rb
index 8aa9b12c4f0..da43d851b31 100644
--- a/spec/models/integrations/prometheus_spec.rb
+++ b/spec/models/integrations/prometheus_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
require 'googleauth'
-RSpec.describe Integrations::Prometheus, :use_clean_rails_memory_store_caching, :snowplow do
+RSpec.describe Integrations::Prometheus, :use_clean_rails_memory_store_caching, :snowplow, feature_category: :metrics do
include PrometheusHelpers
include ReactiveCachingHelpers
@@ -37,8 +37,8 @@ RSpec.describe Integrations::Prometheus, :use_clean_rails_memory_store_caching,
integration.manual_configuration = true
end
- it 'validates presence of api_url' do
- expect(integration).to validate_presence_of(:api_url)
+ it 'does not validates presence of api_url' do
+ expect(integration).not_to validate_presence_of(:api_url)
end
end
@@ -119,7 +119,7 @@ RSpec.describe Integrations::Prometheus, :use_clean_rails_memory_store_caching,
context 'when configuration is not valid' do
before do
- integration.api_url = nil
+ integration.manual_configuration = nil
end
it 'returns failure message' do
diff --git a/spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb b/spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb
index 3dee7f50af3..ec94760e3f0 100644
--- a/spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb
+++ b/spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb
@@ -8,11 +8,13 @@ RSpec.describe 'Creating a new Prometheus Integration', feature_category: :incid
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project) }
+ let(:api_url) { 'https://prometheus-url.com' }
+
let(:variables) do
{
project_path: project.full_path,
active: false,
- api_url: 'https://prometheus-url.com'
+ api_url: api_url
}
end
@@ -56,7 +58,20 @@ RSpec.describe 'Creating a new Prometheus Integration', feature_category: :incid
expect(integration_response['apiUrl']).to eq(new_integration.api_url)
end
- [:project_path, :active, :api_url].each do |argument|
+ context 'without api url' do
+ let(:api_url) { nil }
+
+ it 'creates a new integration' do
+ post_graphql_mutation(mutation, current_user: current_user)
+
+ integration_response = mutation_response['integration']
+
+ expect(response).to have_gitlab_http_status(:success)
+ expect(integration_response['apiUrl']).to be_nil
+ end
+ end
+
+ [:project_path, :active].each do |argument|
context "without required argument #{argument}" do
before do
variables.delete(argument)
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index badbc8b628e..bfcd2be6ce4 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -690,7 +690,7 @@ RSpec.describe Projects::UpdateService, feature_category: :groups_and_projects d
attributes_for(
:prometheus_integration,
project: project,
- properties: { api_url: nil, manual_configuration: "1" }
+ properties: { api_url: 'invalid-url', manual_configuration: "1" }
)
end
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index 27a966f0521..5d1bfdc7892 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -302,7 +302,7 @@ RSpec.describe QuickActions::InterpretService, feature_category: :team_planning
it 'returns due_date message: Date.new(2016, 8, 28) if content contains /due 2016-08-28' do
_, _, message = service.execute(content, issuable)
- expect(message).to eq("Set the due date to #{expected_date.to_s(:medium)}.")
+ expect(message).to eq("Set the due date to #{expected_date.to_fs(:medium)}.")
end
end
diff --git a/spec/support/helpers/features/iteration_helpers.rb b/spec/support/helpers/features/iteration_helpers.rb
index fab373a547f..7ae546fb83c 100644
--- a/spec/support/helpers/features/iteration_helpers.rb
+++ b/spec/support/helpers/features/iteration_helpers.rb
@@ -3,7 +3,7 @@
module Features
module IterationHelpers
def iteration_period(iteration)
- "#{iteration.start_date.to_s(:medium)} - #{iteration.due_date.to_s(:medium)}"
+ "#{iteration.start_date.to_fs(:medium)} - #{iteration.due_date.to_fs(:medium)}"
end
end
end
diff --git a/spec/support/shared_examples/features/sidebar/sidebar_due_date_shared_examples.rb b/spec/support/shared_examples/features/sidebar/sidebar_due_date_shared_examples.rb
index 206116d66c8..865f5aff476 100644
--- a/spec/support/shared_examples/features/sidebar/sidebar_due_date_shared_examples.rb
+++ b/spec/support/shared_examples/features/sidebar/sidebar_due_date_shared_examples.rb
@@ -26,7 +26,7 @@ RSpec.shared_examples 'date sidebar widget' do
wait_for_requests
- expect(page).to have_content(today.to_s(:medium))
+ expect(page).to have_content(today.to_fs(:medium))
expect(due_date_value.text).to have_content Time.current.strftime('%b %-d, %Y')
end
end
diff --git a/spec/tooling/danger/experiments_spec.rb b/spec/tooling/danger/experiments_spec.rb
new file mode 100644
index 00000000000..85f8060a3ec
--- /dev/null
+++ b/spec/tooling/danger/experiments_spec.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+require 'gitlab-dangerfiles'
+require 'gitlab/dangerfiles/spec_helper'
+
+require_relative '../../../tooling/danger/experiments'
+
+RSpec.describe Tooling::Danger::Experiments, feature_category: :tooling do
+ include_context "with dangerfile"
+
+ let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) }
+
+ subject(:experiments) { fake_danger.new(helper: fake_helper) }
+
+ describe '#removed_experiments' do
+ let(:removed_experiments_yml_files) do
+ [
+ 'config/feature_flags/experiment/tier_badge.yml',
+ 'ee/config/feature_flags/experiment/direct_to_trial.yml'
+ ]
+ end
+
+ let(:deleted_files) do
+ [
+ 'app/models/model.rb',
+ 'app/assets/javascripts/file.js'
+ ] + removed_experiments_yml_files
+ end
+
+ it 'returns names of removed experiments' do
+ expect(experiments.removed_experiments).to eq(%w[tier_badge direct_to_trial])
+ end
+ end
+
+ describe '#class_files_removed?' do
+ let(:removed_experiments_name) { current_experiment_with_class_files_example }
+
+ context 'when yml file is deleted but not class file' do
+ let(:deleted_files) { ["config/feature_flags/experiment/#{removed_experiments_name}.yml"] }
+
+ it 'returns false' do
+ expect(experiments.class_files_removed?).to eq(false)
+ end
+ end
+
+ context 'when yml file is deleted but no corresponding class file exists' do
+ let(:deleted_files) { ["config/feature_flags/experiment/fake_experiment.yml"] }
+
+ it 'returns true' do
+ expect(experiments.class_files_removed?).to eq(true)
+ end
+ end
+ end
+
+ def current_experiment_with_class_files_example
+ path = Dir.glob("app/experiments/*.rb").last
+ File.basename(path).chomp('_experiment.rb')
+ end
+end