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-11-15 18:14:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-11-15 18:14:09 +0300
commit3f9e76c30fd80f01bbe2e69569851fa5e3ea71d6 (patch)
treeb6fcb33e71119081b99ea4b820e4c7fb87c52b4d /spec/frontend/search/sidebar
parentd221a274982118d92d424ce382646a7ef2f5887a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/search/sidebar')
-rw-r--r--spec/frontend/search/sidebar/components/app_spec.js55
-rw-r--r--spec/frontend/search/sidebar/components/blobs_filters_spec.js34
-rw-r--r--spec/frontend/search/sidebar/components/confidentiality_filter_spec.js20
-rw-r--r--spec/frontend/search/sidebar/components/filters_template_spec.js5
-rw-r--r--spec/frontend/search/sidebar/components/issues_filters_spec.js50
-rw-r--r--spec/frontend/search/sidebar/components/merge_requests_filters_spec.js34
-rw-r--r--spec/frontend/search/sidebar/components/scope_legacy_navigation_spec.js145
-rw-r--r--spec/frontend/search/sidebar/components/small_screen_drawer_navigation_spec.js68
-rw-r--r--spec/frontend/search/sidebar/components/status_filter_spec.js20
9 files changed, 27 insertions, 404 deletions
diff --git a/spec/frontend/search/sidebar/components/app_spec.js b/spec/frontend/search/sidebar/components/app_spec.js
index c2d88493d71..9413927ac26 100644
--- a/spec/frontend/search/sidebar/components/app_spec.js
+++ b/spec/frontend/search/sidebar/components/app_spec.js
@@ -18,8 +18,6 @@ import NotesFilters from '~/search/sidebar/components/notes_filters.vue';
import CommitsFilters from '~/search/sidebar/components/commits_filters.vue';
import MilestonesFilters from '~/search/sidebar/components/milestones_filters.vue';
import WikiBlobsFilters from '~/search/sidebar/components/wiki_blobs_filters.vue';
-import ScopeLegacyNavigation from '~/search/sidebar/components/scope_legacy_navigation.vue';
-import SmallScreenDrawerNavigation from '~/search/sidebar/components/small_screen_drawer_navigation.vue';
import ScopeSidebarNavigation from '~/search/sidebar/components/scope_sidebar_navigation.vue';
import DomElementListener from '~/vue_shared/components/dom_element_listener.vue';
@@ -62,8 +60,6 @@ describe('GlobalSearchSidebar', () => {
const findCommitsFilters = () => wrapper.findComponent(CommitsFilters);
const findMilestonesFilters = () => wrapper.findComponent(MilestonesFilters);
const findWikiBlobsFilters = () => wrapper.findComponent(WikiBlobsFilters);
- const findScopeLegacyNavigation = () => wrapper.findComponent(ScopeLegacyNavigation);
- const findSmallScreenDrawerNavigation = () => wrapper.findComponent(SmallScreenDrawerNavigation);
const findScopeSidebarNavigation = () => wrapper.findComponent(ScopeSidebarNavigation);
const findDomElementListener = () => wrapper.findComponent(DomElementListener);
@@ -129,46 +125,27 @@ describe('GlobalSearchSidebar', () => {
});
});
- describe.each`
- currentScope | sidebarNavShown | legacyNavShown
- ${'issues'} | ${false} | ${true}
- ${'test'} | ${false} | ${true}
- ${'issues'} | ${true} | ${false}
- ${'test'} | ${true} | ${false}
- `(
- 'renders navigation for scope $currentScope',
- ({ currentScope, sidebarNavShown, legacyNavShown }) => {
- beforeEach(() => {
- getterSpies.currentScope = jest.fn(() => currentScope);
- createComponent({ useSidebarNavigation: sidebarNavShown });
- });
-
- it(`renders navigation correctly with legacyNavShown ${legacyNavShown}`, () => {
- expect(findScopeLegacyNavigation().exists()).toBe(legacyNavShown);
- expect(findSmallScreenDrawerNavigation().exists()).toBe(legacyNavShown);
- });
-
- it(`renders navigation correctly with sidebarNavShown ${sidebarNavShown}`, () => {
- expect(findScopeSidebarNavigation().exists()).toBe(sidebarNavShown);
- });
- },
- );
- });
+ describe.each(['issues', 'test'])('for scope %p', (currentScope) => {
+ beforeEach(() => {
+ getterSpies.currentScope = jest.fn(() => currentScope);
+ createComponent();
+ });
- describe('when useSidebarNavigation=true', () => {
- beforeEach(() => {
- createComponent({ useSidebarNavigation: true });
+ it(`renders navigation correctly`, () => {
+ expect(findScopeSidebarNavigation().exists()).toBe(true);
+ });
});
+ });
- it('toggles super sidebar when button is clicked', () => {
- const elListener = findDomElementListener();
+ it('toggles super sidebar when button is clicked', () => {
+ createComponent();
+ const elListener = findDomElementListener();
- expect(toggleSuperSidebarCollapsed).not.toHaveBeenCalled();
+ expect(toggleSuperSidebarCollapsed).not.toHaveBeenCalled();
- elListener.vm.$emit('click');
+ elListener.vm.$emit('click');
- expect(toggleSuperSidebarCollapsed).toHaveBeenCalledTimes(1);
- expect(elListener.props('selector')).toBe('#js-open-mobile-filters');
- });
+ expect(toggleSuperSidebarCollapsed).toHaveBeenCalledTimes(1);
+ expect(elListener.props('selector')).toBe('#js-open-mobile-filters');
});
});
diff --git a/spec/frontend/search/sidebar/components/blobs_filters_spec.js b/spec/frontend/search/sidebar/components/blobs_filters_spec.js
index 245ddb8f8bb..3f1feae8527 100644
--- a/spec/frontend/search/sidebar/components/blobs_filters_spec.js
+++ b/spec/frontend/search/sidebar/components/blobs_filters_spec.js
@@ -17,13 +17,11 @@ describe('GlobalSearch BlobsFilters', () => {
currentScope: () => 'blobs',
};
- const createComponent = ({ initialState = {} } = {}) => {
+ const createComponent = () => {
const store = new Vuex.Store({
state: {
urlQuery: MOCK_QUERY,
- useSidebarNavigation: false,
searchType: SEARCH_TYPE_ADVANCED,
- ...initialState,
},
getters: defaultGetters,
});
@@ -35,10 +33,9 @@ describe('GlobalSearch BlobsFilters', () => {
const findLanguageFilter = () => wrapper.findComponent(LanguageFilter);
const findArchivedFilter = () => wrapper.findComponent(ArchivedFilter);
- const findDividers = () => wrapper.findAll('hr');
beforeEach(() => {
- createComponent({});
+ createComponent();
});
it('renders LanguageFilter', () => {
@@ -48,31 +45,4 @@ describe('GlobalSearch BlobsFilters', () => {
it('renders ArchivedFilter', () => {
expect(findArchivedFilter().exists()).toBe(true);
});
-
- it('renders divider correctly', () => {
- expect(findDividers()).toHaveLength(1);
- });
-
- describe('Renders correctly in new nav', () => {
- beforeEach(() => {
- createComponent({
- initialState: {
- searchType: SEARCH_TYPE_ADVANCED,
- useSidebarNavigation: true,
- },
- });
- });
-
- it('renders correctly LanguageFilter', () => {
- expect(findLanguageFilter().exists()).toBe(true);
- });
-
- it('renders correctly ArchivedFilter', () => {
- expect(findArchivedFilter().exists()).toBe(true);
- });
-
- it("doesn't render dividers", () => {
- expect(findDividers()).toHaveLength(0);
- });
- });
});
diff --git a/spec/frontend/search/sidebar/components/confidentiality_filter_spec.js b/spec/frontend/search/sidebar/components/confidentiality_filter_spec.js
index 6444ec10466..fedbd407b0b 100644
--- a/spec/frontend/search/sidebar/components/confidentiality_filter_spec.js
+++ b/spec/frontend/search/sidebar/components/confidentiality_filter_spec.js
@@ -22,23 +22,11 @@ describe('ConfidentialityFilter', () => {
const findRadioFilter = () => wrapper.findComponent(RadioFilter);
- describe('old sidebar', () => {
- beforeEach(() => {
- createComponent({ useSidebarNavigation: false });
- });
-
- it('renders the component', () => {
- expect(findRadioFilter().exists()).toBe(true);
- });
+ beforeEach(() => {
+ createComponent();
});
- describe('new sidebar', () => {
- beforeEach(() => {
- createComponent({ useSidebarNavigation: true });
- });
-
- it('renders the component', () => {
- expect(findRadioFilter().exists()).toBe(true);
- });
+ it('renders the component', () => {
+ expect(findRadioFilter().exists()).toBe(true);
});
});
diff --git a/spec/frontend/search/sidebar/components/filters_template_spec.js b/spec/frontend/search/sidebar/components/filters_template_spec.js
index f1a807c5ceb..18144e25ac3 100644
--- a/spec/frontend/search/sidebar/components/filters_template_spec.js
+++ b/spec/frontend/search/sidebar/components/filters_template_spec.js
@@ -52,7 +52,6 @@ describe('GlobalSearchSidebarLanguageFilter', () => {
};
const findForm = () => wrapper.findComponent(GlForm);
- const findDividers = () => wrapper.findAll('hr');
const findApplyButton = () => wrapper.findComponent(GlButton);
const findResetButton = () => wrapper.findComponent(GlLink);
const findSlotContent = () => wrapper.findByText('Filters Content');
@@ -66,10 +65,6 @@ describe('GlobalSearchSidebarLanguageFilter', () => {
expect(findForm().exists()).toBe(true);
});
- it('renders dividers', () => {
- expect(findDividers()).toHaveLength(2);
- });
-
it('renders slot content', () => {
expect(findSlotContent().exists()).toBe(true);
});
diff --git a/spec/frontend/search/sidebar/components/issues_filters_spec.js b/spec/frontend/search/sidebar/components/issues_filters_spec.js
index 860c5c147a6..acdfa41b5f8 100644
--- a/spec/frontend/search/sidebar/components/issues_filters_spec.js
+++ b/spec/frontend/search/sidebar/components/issues_filters_spec.js
@@ -23,7 +23,6 @@ describe('GlobalSearch IssuesFilters', () => {
const store = new Vuex.Store({
state: {
urlQuery: MOCK_QUERY,
- useSidebarNavigation: false,
searchType: SEARCH_TYPE_ADVANCED,
...initialState,
},
@@ -44,7 +43,6 @@ describe('GlobalSearch IssuesFilters', () => {
const findConfidentialityFilter = () => wrapper.findComponent(ConfidentialityFilter);
const findLabelFilter = () => wrapper.findComponent(LabelFilter);
const findArchivedFilter = () => wrapper.findComponent(ArchivedFilter);
- const findDividers = () => wrapper.findAll('hr');
describe.each`
description | searchIssueLabelAggregation
@@ -72,15 +70,6 @@ describe('GlobalSearch IssuesFilters', () => {
it(`renders correctly LabelFilter when searchIssueLabelAggregation is ${searchIssueLabelAggregation}`, () => {
expect(findLabelFilter().exists()).toBe(searchIssueLabelAggregation);
});
-
- it('renders divider correctly', () => {
- // two dividers can't be disabled
- let dividersCount = 2;
- if (searchIssueLabelAggregation) {
- dividersCount += 1;
- }
- expect(findDividers()).toHaveLength(dividersCount);
- });
});
describe('Renders correctly with basic search', () => {
@@ -102,41 +91,6 @@ describe('GlobalSearch IssuesFilters', () => {
it("doesn't render ArchivedFilter", () => {
expect(findArchivedFilter().exists()).toBe(true);
});
-
- it('renders 1 divider', () => {
- expect(findDividers()).toHaveLength(2);
- });
- });
-
- describe('Renders correctly in new nav', () => {
- beforeEach(() => {
- createComponent({
- initialState: {
- searchType: SEARCH_TYPE_ADVANCED,
- useSidebarNavigation: true,
- },
- searchIssueLabelAggregation: true,
- });
- });
- it('renders StatusFilter', () => {
- expect(findStatusFilter().exists()).toBe(true);
- });
-
- it('renders ConfidentialityFilter', () => {
- expect(findConfidentialityFilter().exists()).toBe(true);
- });
-
- it('renders LabelFilter', () => {
- expect(findLabelFilter().exists()).toBe(true);
- });
-
- it('renders ArchivedFilter', () => {
- expect(findArchivedFilter().exists()).toBe(true);
- });
-
- it("doesn't render dividers", () => {
- expect(findDividers()).toHaveLength(0);
- });
});
describe('Renders correctly with wrong scope', () => {
@@ -159,9 +113,5 @@ describe('GlobalSearch IssuesFilters', () => {
it("doesn't render ArchivedFilter", () => {
expect(findArchivedFilter().exists()).toBe(false);
});
-
- it("doesn't render dividers", () => {
- expect(findDividers()).toHaveLength(0);
- });
});
});
diff --git a/spec/frontend/search/sidebar/components/merge_requests_filters_spec.js b/spec/frontend/search/sidebar/components/merge_requests_filters_spec.js
index b02228a418f..8cd3cb45a20 100644
--- a/spec/frontend/search/sidebar/components/merge_requests_filters_spec.js
+++ b/spec/frontend/search/sidebar/components/merge_requests_filters_spec.js
@@ -21,7 +21,6 @@ describe('GlobalSearch MergeRequestsFilters', () => {
const store = new Vuex.Store({
state: {
urlQuery: MOCK_QUERY,
- useSidebarNavigation: false,
searchType: SEARCH_TYPE_ADVANCED,
...initialState,
},
@@ -35,7 +34,6 @@ describe('GlobalSearch MergeRequestsFilters', () => {
const findStatusFilter = () => wrapper.findComponent(StatusFilter);
const findArchivedFilter = () => wrapper.findComponent(ArchivedFilter);
- const findDividers = () => wrapper.findAll('hr');
describe('Renders correctly with Archived Filter', () => {
beforeEach(() => {
@@ -46,8 +44,8 @@ describe('GlobalSearch MergeRequestsFilters', () => {
expect(findStatusFilter().exists()).toBe(true);
});
- it('renders divider correctly', () => {
- expect(findDividers()).toHaveLength(1);
+ it('renders ArchivedFilter', () => {
+ expect(findArchivedFilter().exists()).toBe(true);
});
});
@@ -60,33 +58,9 @@ describe('GlobalSearch MergeRequestsFilters', () => {
expect(findStatusFilter().exists()).toBe(true);
});
- it('renders render ArchivedFilter', () => {
- expect(findArchivedFilter().exists()).toBe(true);
- });
-
- it('renders 1 divider', () => {
- expect(findDividers()).toHaveLength(1);
- });
- });
-
- describe('Renders correctly in new nav', () => {
- beforeEach(() => {
- createComponent({
- searchType: SEARCH_TYPE_ADVANCED,
- useSidebarNavigation: true,
- });
- });
- it('renders StatusFilter', () => {
- expect(findStatusFilter().exists()).toBe(true);
- });
-
it('renders ArchivedFilter', () => {
expect(findArchivedFilter().exists()).toBe(true);
});
-
- it("doesn't render divider", () => {
- expect(findDividers()).toHaveLength(0);
- });
});
describe('Renders correctly with wrong scope', () => {
@@ -101,9 +75,5 @@ describe('GlobalSearch MergeRequestsFilters', () => {
it("doesn't render ArchivedFilter", () => {
expect(findArchivedFilter().exists()).toBe(false);
});
-
- it("doesn't render dividers", () => {
- expect(findDividers()).toHaveLength(0);
- });
});
});
diff --git a/spec/frontend/search/sidebar/components/scope_legacy_navigation_spec.js b/spec/frontend/search/sidebar/components/scope_legacy_navigation_spec.js
deleted file mode 100644
index 63d8b34fcf0..00000000000
--- a/spec/frontend/search/sidebar/components/scope_legacy_navigation_spec.js
+++ /dev/null
@@ -1,145 +0,0 @@
-import { GlNav, GlNavItem, GlIcon } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import Vue from 'vue';
-// eslint-disable-next-line no-restricted-imports
-import Vuex from 'vuex';
-import { MOCK_QUERY, MOCK_NAVIGATION } from 'jest/search/mock_data';
-import ScopeLegacyNavigation from '~/search/sidebar/components/scope_legacy_navigation.vue';
-
-Vue.use(Vuex);
-
-const MOCK_NAVIGATION_ENTRIES = Object.entries(MOCK_NAVIGATION);
-
-describe('ScopeLegacyNavigation', () => {
- let wrapper;
-
- const actionSpies = {
- fetchSidebarCount: jest.fn(),
- };
-
- const getterSpies = {
- currentScope: jest.fn(() => 'issues'),
- };
-
- const createComponent = (initialState) => {
- const store = new Vuex.Store({
- state: {
- urlQuery: MOCK_QUERY,
- navigation: MOCK_NAVIGATION,
- ...initialState,
- },
- actions: actionSpies,
- getters: getterSpies,
- });
-
- wrapper = shallowMount(ScopeLegacyNavigation, {
- store,
- });
- };
-
- const findNavElement = () => wrapper.find('nav');
- const findGlNav = () => wrapper.findComponent(GlNav);
- const findGlNavItems = () => wrapper.findAllComponents(GlNavItem);
- const findGlNavItemActive = () => wrapper.find('[active=true]');
- const findGlNavItemActiveLabel = () => findGlNavItemActive().find('[data-testid="label"]');
- const findGlNavItemActiveCount = () => findGlNavItemActive().find('[data-testid="count"]');
-
- describe('scope navigation', () => {
- beforeEach(() => {
- createComponent();
- });
-
- it('renders section', () => {
- expect(findNavElement().exists()).toBe(true);
- });
-
- it('renders nav component', () => {
- expect(findGlNav().exists()).toBe(true);
- });
-
- it('renders all nav item components', () => {
- expect(findGlNavItems()).toHaveLength(MOCK_NAVIGATION_ENTRIES.length);
- });
-
- it('has all proper links', () => {
- const linkAtPosition = 3;
- const { link } = MOCK_NAVIGATION_ENTRIES[linkAtPosition][1];
-
- expect(findGlNavItems().at(linkAtPosition).attributes('href')).toBe(link);
- });
- });
-
- describe('scope navigation sets proper state with url scope set', () => {
- beforeEach(() => {
- createComponent();
- });
-
- it('has correct active item', () => {
- expect(findGlNavItemActive().exists()).toBe(true);
- expect(findGlNavItemActiveLabel().text()).toBe('Issues');
- });
-
- it('has correct active item count', () => {
- expect(findGlNavItemActiveCount().text()).toBe('2.4K');
- });
-
- it('does not have plus sign after count text', () => {
- expect(findGlNavItemActive().findComponent(GlIcon).exists()).toBe(false);
- });
-
- it('has count is highlighted correctly', () => {
- expect(findGlNavItemActiveCount().classes('gl-text-gray-900')).toBe(true);
- });
- });
-
- describe('scope navigation sets proper state with NO url scope set', () => {
- beforeEach(() => {
- getterSpies.currentScope = jest.fn(() => 'projects');
- createComponent({
- urlQuery: {},
- navigation: {
- ...MOCK_NAVIGATION,
- projects: {
- ...MOCK_NAVIGATION.projects,
- active: true,
- },
- issues: {
- ...MOCK_NAVIGATION.issues,
- active: false,
- },
- },
- });
- });
-
- it('has correct active item', () => {
- expect(findGlNavItemActive().exists()).toBe(true);
- expect(findGlNavItemActiveLabel().text()).toBe('Projects');
- });
-
- it('has correct active item count', () => {
- expect(findGlNavItemActiveCount().text()).toBe('10K');
- });
-
- it('has correct active item count and over limit sign', () => {
- expect(findGlNavItemActive().findComponent(GlIcon).exists()).toBe(true);
- });
- });
-
- describe.each`
- searchTherm | hasBeenCalled
- ${null} | ${0}
- ${'test'} | ${1}
- `('fetchSidebarCount', ({ searchTherm, hasBeenCalled }) => {
- beforeEach(() => {
- createComponent({
- urlQuery: {
- search: searchTherm,
- },
- });
- });
-
- it('is only called when search term is set', () => {
- expect(actionSpies.fetchSidebarCount).toHaveBeenCalledTimes(hasBeenCalled);
- });
- });
-});
diff --git a/spec/frontend/search/sidebar/components/small_screen_drawer_navigation_spec.js b/spec/frontend/search/sidebar/components/small_screen_drawer_navigation_spec.js
deleted file mode 100644
index 5ab4afba7f0..00000000000
--- a/spec/frontend/search/sidebar/components/small_screen_drawer_navigation_spec.js
+++ /dev/null
@@ -1,68 +0,0 @@
-import { nextTick } from 'vue';
-import { GlDrawer } from '@gitlab/ui';
-import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
-import DomElementListener from '~/vue_shared/components/dom_element_listener.vue';
-import { DRAWER_Z_INDEX } from '~/lib/utils/constants';
-import SmallScreenDrawerNavigation from '~/search/sidebar/components/small_screen_drawer_navigation.vue';
-
-describe('ScopeLegacyNavigation', () => {
- let wrapper;
- let closeSpy;
- let toggleSpy;
-
- const createComponent = () => {
- wrapper = shallowMountExtended(SmallScreenDrawerNavigation, {
- slots: {
- default: '<div data-testid="default-slot-content">test</div>',
- },
- });
- };
-
- const findGlDrawer = () => wrapper.findComponent(GlDrawer);
- const findTitle = () => wrapper.findComponent('h2');
- const findSlot = () => wrapper.findByTestId('default-slot-content');
- const findDomElementListener = () => wrapper.findComponent(DomElementListener);
-
- describe('small screen navigation', () => {
- beforeEach(() => {
- createComponent();
- });
-
- it('renders drawer', () => {
- expect(findGlDrawer().exists()).toBe(true);
- expect(findGlDrawer().attributes('zindex')).toBe(DRAWER_Z_INDEX.toString());
- expect(findGlDrawer().attributes('headerheight')).toBe('0');
- });
-
- it('renders title', () => {
- expect(findTitle().exists()).toBe(true);
- });
-
- it('renders slots', () => {
- expect(findSlot().exists()).toBe(true);
- });
- });
-
- describe('actions', () => {
- beforeEach(() => {
- closeSpy = jest.spyOn(SmallScreenDrawerNavigation.methods, 'closeSmallScreenFilters');
- toggleSpy = jest.spyOn(SmallScreenDrawerNavigation.methods, 'toggleSmallScreenFilters');
- createComponent();
- });
-
- it('calls onClose', () => {
- findGlDrawer().vm.$emit('close');
- expect(closeSpy).toHaveBeenCalled();
- });
-
- it('calls toggleSmallScreenFilters', async () => {
- expect(findGlDrawer().props('open')).toBe(false);
-
- findDomElementListener().vm.$emit('click');
- await nextTick();
-
- expect(toggleSpy).toHaveBeenCalled();
- expect(findGlDrawer().props('open')).toBe(true);
- });
- });
-});
diff --git a/spec/frontend/search/sidebar/components/status_filter_spec.js b/spec/frontend/search/sidebar/components/status_filter_spec.js
index c230341c172..719932a79ef 100644
--- a/spec/frontend/search/sidebar/components/status_filter_spec.js
+++ b/spec/frontend/search/sidebar/components/status_filter_spec.js
@@ -22,23 +22,9 @@ describe('StatusFilter', () => {
const findRadioFilter = () => wrapper.findComponent(RadioFilter);
- describe('old sidebar', () => {
- beforeEach(() => {
- createComponent({ useSidebarNavigation: false });
- });
-
- it('renders the component', () => {
- expect(findRadioFilter().exists()).toBe(true);
- });
- });
+ it('renders the component', () => {
+ createComponent();
- describe('new sidebar', () => {
- beforeEach(() => {
- createComponent({ useSidebarNavigation: true });
- });
-
- it('renders the component', () => {
- expect(findRadioFilter().exists()).toBe(true);
- });
+ expect(findRadioFilter().exists()).toBe(true);
});
});