diff options
Diffstat (limited to 'spec/frontend/search/sidebar')
3 files changed, 107 insertions, 1 deletions
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); + }); + }); +}); |