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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-31 12:10:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-31 12:10:26 +0300
commit26d2324ac136c7a28235789ff9a0b2974b5f7c7b (patch)
treef6a8cb8c0edf9225c3182ba115916f861bcc6357 /spec/frontend/search
parent4603adb20ba7c5b84700fb0bf41b43f7b1a49f8c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/search')
-rw-r--r--spec/frontend/search/mock_data.js19
-rw-r--r--spec/frontend/search/sidebar/components/app_spec.js24
-rw-r--r--spec/frontend/search/sidebar/components/archived_filter_spec.js56
-rw-r--r--spec/frontend/search/sidebar/components/projects_filters_specs.js28
-rw-r--r--spec/frontend/search/store/getters_spec.js20
5 files changed, 107 insertions, 40 deletions
diff --git a/spec/frontend/search/mock_data.js b/spec/frontend/search/mock_data.js
index 3f23803bbf6..a063f20aca6 100644
--- a/spec/frontend/search/mock_data.js
+++ b/spec/frontend/search/mock_data.js
@@ -884,23 +884,4 @@ export const MOCK_FILTERED_LABELS = [
},
];
-export const MOCK_FILTERED_UNAPPLIED_SELECTED_LABELS = [
- {
- key: '6',
- count: 12,
- title: 'Cosche',
- color: '#cea786',
- type: 'GroupLabel',
- parent_full_name: 'Toolbox',
- },
- {
- key: '73',
- count: 12,
- title: 'Accent',
- color: '#a5c6fb',
- type: 'ProjectLabel',
- parent_full_name: 'Toolbox / Gitlab Smoke Tests',
- },
-];
-
export const CURRENT_SCOPE = 'blobs';
diff --git a/spec/frontend/search/sidebar/components/app_spec.js b/spec/frontend/search/sidebar/components/app_spec.js
index aace9c8f83e..83eb4cd3ab7 100644
--- a/spec/frontend/search/sidebar/components/app_spec.js
+++ b/spec/frontend/search/sidebar/components/app_spec.js
@@ -6,6 +6,7 @@ import GlobalSearchSidebar from '~/search/sidebar/components/app.vue';
import IssuesFilters from '~/search/sidebar/components/issues_filters.vue';
import MergeRequestsFilters from '~/search/sidebar/components/merge_requests_filters.vue';
import BlobsFilters from '~/search/sidebar/components/blobs_filters.vue';
+import ProjectsFilters from '~/search/sidebar/components/projects_filters.vue';
import ScopeLegacyNavigation from '~/search/sidebar/components/scope_legacy_navigation.vue';
import ScopeSidebarNavigation from '~/search/sidebar/components/scope_sidebar_navigation.vue';
@@ -18,7 +19,7 @@ describe('GlobalSearchSidebar', () => {
currentScope: jest.fn(() => 'issues'),
};
- const createComponent = (initialState = {}) => {
+ const createComponent = (initialState = {}, ff = false) => {
const store = new Vuex.Store({
state: {
urlQuery: MOCK_QUERY,
@@ -29,6 +30,11 @@ describe('GlobalSearchSidebar', () => {
wrapper = shallowMount(GlobalSearchSidebar, {
store,
+ provide: {
+ glFeatures: {
+ searchProjectsHideArchived: ff,
+ },
+ },
});
};
@@ -36,6 +42,7 @@ describe('GlobalSearchSidebar', () => {
const findIssuesFilters = () => wrapper.findComponent(IssuesFilters);
const findMergeRequestsFilters = () => wrapper.findComponent(MergeRequestsFilters);
const findBlobsFilters = () => wrapper.findComponent(BlobsFilters);
+ const findProjectsFilters = () => wrapper.findComponent(ProjectsFilters);
const findScopeLegacyNavigation = () => wrapper.findComponent(ScopeLegacyNavigation);
const findScopeSidebarNavigation = () => wrapper.findComponent(ScopeSidebarNavigation);
@@ -66,6 +73,21 @@ describe('GlobalSearchSidebar', () => {
});
describe.each`
+ featureFlag
+ ${false}
+ ${true}
+ `('with sidebar $scope scope:', ({ featureFlag }) => {
+ beforeEach(() => {
+ getterSpies.currentScope = jest.fn(() => 'projects');
+ createComponent({ urlQuery: { scope: 'projects' } }, featureFlag);
+ });
+
+ it(`shows filter ProjectsFilters}`, () => {
+ expect(findProjectsFilters().exists()).toBe(featureFlag);
+ });
+ });
+
+ describe.each`
currentScope | sidebarNavShown | legacyNavShown
${'issues'} | ${false} | ${true}
${''} | ${false} | ${false}
diff --git a/spec/frontend/search/sidebar/components/archived_filter_spec.js b/spec/frontend/search/sidebar/components/archived_filter_spec.js
new file mode 100644
index 00000000000..eaea731882e
--- /dev/null
+++ b/spec/frontend/search/sidebar/components/archived_filter_spec.js
@@ -0,0 +1,56 @@
+import { shallowMount } from '@vue/test-utils';
+import Vue from 'vue';
+import Vuex from 'vuex';
+import { GlFormCheckboxGroup } from '@gitlab/ui';
+import ArchivedFilter from '~/search/sidebar/components/archived_filter/index.vue';
+
+import { archivedFilterData } from '~/search/sidebar/components/archived_filter/data';
+
+Vue.use(Vuex);
+
+describe('ArchivedFilter', () => {
+ let wrapper;
+
+ const createComponent = (state) => {
+ const store = new Vuex.Store({
+ state,
+ });
+
+ wrapper = shallowMount(ArchivedFilter, {
+ store,
+ });
+ };
+
+ const findCheckboxFilter = () => wrapper.findComponent(GlFormCheckboxGroup);
+ const findH5 = () => wrapper.findComponent('h5');
+
+ describe('old sidebar', () => {
+ beforeEach(() => {
+ createComponent({ useNewNavigation: false });
+ });
+
+ it('renders the component', () => {
+ expect(findCheckboxFilter().exists()).toBe(true);
+ });
+
+ it('renders the divider', () => {
+ expect(findH5().exists()).toBe(true);
+ expect(findH5().text()).toBe(archivedFilterData.headerLabel);
+ });
+ });
+
+ describe('new sidebar', () => {
+ beforeEach(() => {
+ createComponent({ useNewNavigation: true });
+ });
+
+ it('renders the component', () => {
+ expect(findCheckboxFilter().exists()).toBe(true);
+ });
+
+ it("doesn't render the divider", () => {
+ expect(findH5().exists()).toBe(true);
+ expect(findH5().text()).toBe(archivedFilterData.headerLabel);
+ });
+ });
+});
diff --git a/spec/frontend/search/sidebar/components/projects_filters_specs.js b/spec/frontend/search/sidebar/components/projects_filters_specs.js
new file mode 100644
index 00000000000..15e3254e289
--- /dev/null
+++ b/spec/frontend/search/sidebar/components/projects_filters_specs.js
@@ -0,0 +1,28 @@
+import { shallowMount } from '@vue/test-utils';
+import ProjectsFilters from '~/search/sidebar/components/projects_filters.vue';
+import ArchivedFilter from '~/search/sidebar/components/language_filter/index.vue';
+import FiltersTemplate from '~/search/sidebar/components/filters_template.vue';
+
+describe('GlobalSearch ProjectsFilters', () => {
+ let wrapper;
+
+ const findArchivedFilter = () => wrapper.findComponent(ArchivedFilter);
+ const findFiltersTemplate = () => wrapper.findComponent(FiltersTemplate);
+
+ const createComponent = () => {
+ wrapper = shallowMount(ProjectsFilters);
+ };
+
+ describe('Renders correctly', () => {
+ beforeEach(() => {
+ createComponent();
+ });
+ it('renders ArchivedFilter', () => {
+ expect(findArchivedFilter().exists()).toBe(true);
+ });
+
+ it('renders FiltersTemplate', () => {
+ expect(findFiltersTemplate().exists()).toBe(true);
+ });
+ });
+});
diff --git a/spec/frontend/search/store/getters_spec.js b/spec/frontend/search/store/getters_spec.js
index 66a888037ea..571525bd025 100644
--- a/spec/frontend/search/store/getters_spec.js
+++ b/spec/frontend/search/store/getters_spec.js
@@ -17,7 +17,6 @@ import {
MOCK_LABEL_SEARCH_RESULT,
MOCK_FILTERED_APPLIED_SELECTED_LABELS,
MOCK_FILTERED_UNSELECTED_LABELS,
- MOCK_FILTERED_UNAPPLIED_SELECTED_LABELS,
} from '../mock_data';
describe('Global Search Store Getters', () => {
@@ -121,25 +120,6 @@ describe('Global Search Store Getters', () => {
});
});
- describe('filteredUnappliedSelectedLabels', () => {
- beforeEach(() => {
- state.query.labels = ['6', '73'];
- });
-
- it('returns all labels that are selected (part of URL) no search', () => {
- expect(getters.filteredUnappliedSelectedLabels(state)).toStrictEqual(
- MOCK_FILTERED_UNAPPLIED_SELECTED_LABELS,
- );
- });
-
- it('returns labels that are selected (part of URL) and result of search', () => {
- state.searchLabelString = 'ACC';
- expect(getters.filteredUnappliedSelectedLabels(state)).toStrictEqual([
- MOCK_FILTERED_UNAPPLIED_SELECTED_LABELS[1],
- ]);
- });
- });
-
describe('filteredUnselectedLabels', () => {
it('returns all labels that are selected (part of URL) no search', () => {
expect(getters.filteredUnselectedLabels(state)).toStrictEqual(