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-02-07 06:11:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-07 06:11:09 +0300
commitfcfafe81d1f1aa442c5a5c93cd27b5f5b798cb90 (patch)
treec75080b3bf76b2a8f891e6b0b7437794da03519e /spec
parent11438b1771abda3c216ca627bf5319684474889b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/branches_controller_spec.rb12
-rw-r--r--spec/frontend/super_sidebar/components/help_center_spec.js66
-rw-r--r--spec/frontend/super_sidebar/mock_data.js2
-rw-r--r--spec/helpers/sidebars_helper_spec.rb4
-rw-r--r--spec/lib/slack_markdown_sanitizer_spec.rb23
-rw-r--r--spec/models/analytics/cycle_analytics/stage_spec.rb15
-rw-r--r--spec/support/shared_examples/features/sidebar_shared_examples.rb20
7 files changed, 130 insertions, 12 deletions
diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb
index ed11d5936b0..fd01aee709a 100644
--- a/spec/controllers/projects/branches_controller_spec.rb
+++ b/spec/controllers/projects/branches_controller_spec.rb
@@ -676,6 +676,18 @@ RSpec.describe Projects::BranchesController do
end
end
+ context 'when state is not supported' do
+ before do
+ get :index, format: :html, params: {
+ namespace_id: project.namespace, project_id: project, state: 'unknown'
+ }
+ end
+
+ it 'returns 404 page' do
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
context 'sorting', :aggregate_failures do
let(:sort) { 'name_asc' }
diff --git a/spec/frontend/super_sidebar/components/help_center_spec.js b/spec/frontend/super_sidebar/components/help_center_spec.js
index f1db755a711..86d4286a3f7 100644
--- a/spec/frontend/super_sidebar/components/help_center_spec.js
+++ b/spec/frontend/super_sidebar/components/help_center_spec.js
@@ -1,10 +1,12 @@
-import { GlDisclosureDropdown } from '@gitlab/ui';
+import { GlDisclosureDropdownGroup } from '@gitlab/ui';
import { within } from '@testing-library/dom';
import toggleWhatsNewDrawer from '~/whats_new';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import HelpCenter from '~/super_sidebar/components/help_center.vue';
import { helpPagePath } from '~/helpers/help_page_helper';
import { PROMO_URL } from 'jh_else_ce/lib/utils/url_utility';
+import { useLocalStorageSpy } from 'helpers/local_storage_helper';
+import { STORAGE_KEY } from '~/whats_new/utils/notification';
import { sidebarData } from '../mock_data';
jest.mock('~/whats_new');
@@ -12,11 +14,14 @@ jest.mock('~/whats_new');
describe('HelpCenter component', () => {
let wrapper;
- const findDropdown = () => wrapper.findComponent(GlDisclosureDropdown);
+ const findDropdownGroup = (i = 0) => {
+ return wrapper.findAllComponents(GlDisclosureDropdownGroup).at(i);
+ };
const withinComponent = () => within(wrapper.element);
const findButton = (name) => withinComponent().getByRole('button', { name });
- const createWrapper = () => {
+ // eslint-disable-next-line no-shadow
+ const createWrapper = (sidebarData) => {
wrapper = mountExtended(HelpCenter, {
propsData: { sidebarData },
});
@@ -24,11 +29,11 @@ describe('HelpCenter component', () => {
describe('default', () => {
beforeEach(() => {
- createWrapper();
+ createWrapper(sidebarData);
});
it('renders menu items', () => {
- expect(findDropdown().props('items')[0].items).toEqual([
+ expect(findDropdownGroup(0).props('group').items).toEqual([
{ text: HelpCenter.i18n.help, href: helpPagePath() },
{ text: HelpCenter.i18n.support, href: sidebarData.support_path },
{ text: HelpCenter.i18n.docs, href: 'https://docs.gitlab.com' },
@@ -41,7 +46,7 @@ describe('HelpCenter component', () => {
{ text: HelpCenter.i18n.feedback, href: 'https://about.gitlab.com/submit-feedback' },
]);
- expect(findDropdown().props('items')[1].items).toEqual([
+ expect(findDropdownGroup(1).props('group').items).toEqual([
expect.objectContaining({ text: HelpCenter.i18n.shortcuts }),
expect.objectContaining({ text: HelpCenter.i18n.whatsnew }),
]);
@@ -51,7 +56,7 @@ describe('HelpCenter component', () => {
beforeEach(() => {
jest.spyOn(wrapper.vm.$refs.dropdown, 'close');
window.toggleShortcutsHelp = jest.fn();
- findButton('Keyboard shortcuts').click();
+ findButton('Keyboard shortcuts ?').click();
});
it('closes the dropdown', () => {
@@ -66,7 +71,7 @@ describe('HelpCenter component', () => {
describe('showWhatsNew', () => {
beforeEach(() => {
jest.spyOn(wrapper.vm.$refs.dropdown, 'close');
- findButton("What's new").click();
+ findButton("What's new 5").click();
});
it('closes the dropdown', () => {
@@ -83,5 +88,50 @@ describe('HelpCenter component', () => {
expect(toggleWhatsNewDrawer).toHaveBeenLastCalledWith();
});
});
+
+ describe('shouldShowWhatsNewNotification', () => {
+ describe('when setting is disabled', () => {
+ beforeEach(() => {
+ createWrapper({ ...sidebarData, display_whats_new: false });
+ });
+
+ it('is false', () => {
+ expect(wrapper.vm.showWhatsNewNotification).toBe(false);
+ });
+ });
+
+ describe('when setting is enabled', () => {
+ useLocalStorageSpy();
+
+ beforeEach(() => {
+ createWrapper({ ...sidebarData, display_whats_new: true });
+ });
+
+ it('is true', () => {
+ expect(wrapper.vm.showWhatsNewNotification).toBe(true);
+ });
+
+ describe('when "What\'s new" drawer got opened', () => {
+ beforeEach(() => {
+ findButton("What's new 5").click();
+ });
+
+ it('is false', () => {
+ expect(wrapper.vm.showWhatsNewNotification).toBe(false);
+ });
+ });
+
+ describe('with matching version digest in local storage', () => {
+ beforeEach(() => {
+ window.localStorage.setItem(STORAGE_KEY, 1);
+ createWrapper({ ...sidebarData, display_whats_new: true });
+ });
+
+ it('is false', () => {
+ expect(wrapper.vm.showWhatsNewNotification).toBe(false);
+ });
+ });
+ });
+ });
});
});
diff --git a/spec/frontend/super_sidebar/mock_data.js b/spec/frontend/super_sidebar/mock_data.js
index 0194360cb57..8467306eb34 100644
--- a/spec/frontend/super_sidebar/mock_data.js
+++ b/spec/frontend/super_sidebar/mock_data.js
@@ -69,4 +69,6 @@ export const sidebarData = {
merge_request_menu: mergeRequestMenuGroup,
support_path: '/support',
display_whats_new: true,
+ whats_new_most_recent_release_items_count: 5,
+ whats_new_version_digest: 1,
};
diff --git a/spec/helpers/sidebars_helper_spec.rb b/spec/helpers/sidebars_helper_spec.rb
index 0622e73936d..e3e1d39b4f8 100644
--- a/spec/helpers/sidebars_helper_spec.rb
+++ b/spec/helpers/sidebars_helper_spec.rb
@@ -70,7 +70,9 @@ RSpec.describe SidebarsHelper do
issues_dashboard_path: issues_dashboard_path(assignee_username: user.username),
total_merge_requests_count: 4,
support_path: helper.support_url,
- display_whats_new: helper.display_whats_new?
+ display_whats_new: helper.display_whats_new?,
+ whats_new_most_recent_release_items_count: helper.whats_new_most_recent_release_items_count,
+ whats_new_version_digest: helper.whats_new_version_digest
})
end
diff --git a/spec/lib/slack_markdown_sanitizer_spec.rb b/spec/lib/slack_markdown_sanitizer_spec.rb
new file mode 100644
index 00000000000..f4042439213
--- /dev/null
+++ b/spec/lib/slack_markdown_sanitizer_spec.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe SlackMarkdownSanitizer, feature_category: :integrations do
+ describe '.sanitize' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:input, :output) do
+ nil | nil
+ '' | ''
+ '[label](url)' | 'label(url)'
+ '<url|label>' | 'urllabel'
+ '<a href="url">label</a>' | 'a href="url"label/a'
+ end
+
+ with_them do
+ it 'returns the expected output' do
+ expect(described_class.sanitize(input)).to eq(output)
+ end
+ end
+ end
+end
diff --git a/spec/models/analytics/cycle_analytics/stage_spec.rb b/spec/models/analytics/cycle_analytics/stage_spec.rb
index e37edda80b1..57748f8942e 100644
--- a/spec/models/analytics/cycle_analytics/stage_spec.rb
+++ b/spec/models/analytics/cycle_analytics/stage_spec.rb
@@ -27,6 +27,7 @@ RSpec.describe Analytics::CycleAnalytics::Stage, feature_category: :value_stream
describe '.distinct_stages_within_hierarchy' do
let_it_be(:group) { create(:group) }
let_it_be(:sub_group) { create(:group, parent: group) }
+ let_it_be(:project) { create(:project, group: sub_group).reload }
before do
# event identifiers are the same
@@ -36,12 +37,19 @@ RSpec.describe Analytics::CycleAnalytics::Stage, feature_category: :value_stream
start_event_identifier: :merge_request_created, end_event_identifier: :merge_request_merged)
create(:cycle_analytics_stage, name: 'Stage A3', namespace: sub_group,
start_event_identifier: :merge_request_created, end_event_identifier: :merge_request_merged)
+ create(:cycle_analytics_stage, name: 'Stage A4', project: project,
+ start_event_identifier: :merge_request_created, end_event_identifier: :merge_request_merged)
create(:cycle_analytics_stage,
name: 'Stage B1',
namespace: group,
start_event_identifier: :merge_request_last_build_started,
end_event_identifier: :merge_request_last_build_finished)
+
+ create(:cycle_analytics_stage, name: 'Stage C1', project: project,
+ start_event_identifier: :issue_created, end_event_identifier: :issue_deployed_to_production)
+ create(:cycle_analytics_stage, name: 'Stage C2', project: project,
+ start_event_identifier: :issue_created, end_event_identifier: :issue_deployed_to_production)
end
it 'returns distinct stages by the event identifiers' do
@@ -49,12 +57,13 @@ RSpec.describe Analytics::CycleAnalytics::Stage, feature_category: :value_stream
expected_event_pairs = [
%w[merge_request_created merge_request_merged],
- %w[merge_request_last_build_started merge_request_last_build_finished]
- ]
+ %w[merge_request_last_build_started merge_request_last_build_finished],
+ %w[issue_created issue_deployed_to_production]
+ ].sort
current_event_pairs = stages.map do |stage|
[stage.start_event_identifier, stage.end_event_identifier]
- end
+ end.sort
expect(current_event_pairs).to eq(expected_event_pairs)
end
diff --git a/spec/support/shared_examples/features/sidebar_shared_examples.rb b/spec/support/shared_examples/features/sidebar_shared_examples.rb
index 77334db6a36..c2c50e8762f 100644
--- a/spec/support/shared_examples/features/sidebar_shared_examples.rb
+++ b/spec/support/shared_examples/features/sidebar_shared_examples.rb
@@ -42,6 +42,26 @@ RSpec.shared_examples 'issue boards sidebar' do
end
end
+ context 'editing issue title' do
+ it 'edits issue title' do
+ page.within('[data-testid="sidebar-title"]') do
+ click_button 'Edit'
+
+ wait_for_requests
+
+ find('input').set('Test title')
+
+ click_button 'Save changes'
+
+ wait_for_requests
+
+ expect(page).to have_content('Test title')
+ end
+
+ expect(first_card).to have_content('Test title')
+ end
+ end
+
context 'editing issue milestone', :js do
it_behaves_like 'milestone sidebar widget'
end