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-03-02 21:12:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-02 21:12:20 +0300
commit3c4d101de003ea292be5ac5baf5d73c6c2747367 (patch)
tree5918d12b69c4bfd84f05a585d62174586a80fd18 /spec/frontend/search
parentb2c21b99c7eb52b5fd906b1e7b4b08d4eb7a296c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/search')
-rw-r--r--spec/frontend/search/sidebar/components/app_spec.js6
-rw-r--r--spec/frontend/search/sidebar/components/checkbox_filter_spec.js2
-rw-r--r--spec/frontend/search/sidebar/components/language_filter_spec.js10
-rw-r--r--spec/frontend/search/sidebar/components/scope_navigation_spec.js35
-rw-r--r--spec/frontend/search/store/getters_spec.js16
5 files changed, 50 insertions, 19 deletions
diff --git a/spec/frontend/search/sidebar/components/app_spec.js b/spec/frontend/search/sidebar/components/app_spec.js
index 83302b90233..bbe04ba67f1 100644
--- a/spec/frontend/search/sidebar/components/app_spec.js
+++ b/spec/frontend/search/sidebar/components/app_spec.js
@@ -17,6 +17,10 @@ describe('GlobalSearchSidebar', () => {
resetQuery: jest.fn(),
};
+ const getterSpies = {
+ currentScope: jest.fn(() => 'issues'),
+ };
+
const createComponent = (initialState, featureFlags) => {
const store = new Vuex.Store({
state: {
@@ -24,6 +28,7 @@ describe('GlobalSearchSidebar', () => {
...initialState,
},
actions: actionSpies,
+ getters: getterSpies,
});
wrapper = shallowMount(GlobalSearchSidebar, {
@@ -59,6 +64,7 @@ describe('GlobalSearchSidebar', () => {
${'blobs'} | ${false} | ${true}
`('sidebar scope: $scope', ({ scope, showFilters, ShowsLanguage }) => {
beforeEach(() => {
+ getterSpies.currentScope = jest.fn(() => scope);
createComponent({ urlQuery: { scope } }, { searchBlobsLanguageAggregation: true });
});
diff --git a/spec/frontend/search/sidebar/components/checkbox_filter_spec.js b/spec/frontend/search/sidebar/components/checkbox_filter_spec.js
index e2a3fdeeb25..f7b35c7bb14 100644
--- a/spec/frontend/search/sidebar/components/checkbox_filter_spec.js
+++ b/spec/frontend/search/sidebar/components/checkbox_filter_spec.js
@@ -18,7 +18,7 @@ describe('CheckboxFilter', () => {
};
const getterSpies = {
- queryLangugageFilters: jest.fn(() => []),
+ queryLanguageFilters: jest.fn(() => []),
};
const defaultProps = {
diff --git a/spec/frontend/search/sidebar/components/language_filter_spec.js b/spec/frontend/search/sidebar/components/language_filter_spec.js
index 6870e759110..17656ba749b 100644
--- a/spec/frontend/search/sidebar/components/language_filter_spec.js
+++ b/spec/frontend/search/sidebar/components/language_filter_spec.js
@@ -22,8 +22,8 @@ describe('GlobalSearchSidebarLanguageFilter', () => {
};
const getterSpies = {
- langugageAggregationBuckets: jest.fn(() => MOCK_LANGUAGE_AGGREGATIONS_BUCKETS),
- queryLangugageFilters: jest.fn(() => []),
+ languageAggregationBuckets: jest.fn(() => MOCK_LANGUAGE_AGGREGATIONS_BUCKETS),
+ queryLanguageFilters: jest.fn(() => []),
};
const createComponent = (initialState) => {
@@ -95,7 +95,7 @@ describe('GlobalSearchSidebarLanguageFilter', () => {
${'no sidebar and no query filters'} | ${false} | ${[]} | ${'true'}
`('$description', ({ sidebarDirty, queryFilters, isDisabled }) => {
beforeEach(() => {
- getterSpies.queryLangugageFilters = jest.fn(() => queryFilters);
+ getterSpies.queryLanguageFilters = jest.fn(() => queryFilters);
createComponent({ sidebarDirty, query: { ...MOCK_QUERY, language: queryFilters } });
});
@@ -156,8 +156,8 @@ describe('GlobalSearchSidebarLanguageFilter', () => {
createComponent({});
});
- it('uses getter langugageAggregationBuckets', () => {
- expect(getterSpies.langugageAggregationBuckets).toHaveBeenCalled();
+ it('uses getter languageAggregationBuckets', () => {
+ expect(getterSpies.languageAggregationBuckets).toHaveBeenCalled();
});
it('uses action fetchLanguageAggregation', () => {
diff --git a/spec/frontend/search/sidebar/components/scope_navigation_spec.js b/spec/frontend/search/sidebar/components/scope_navigation_spec.js
index 23c158239dc..1018fae56e1 100644
--- a/spec/frontend/search/sidebar/components/scope_navigation_spec.js
+++ b/spec/frontend/search/sidebar/components/scope_navigation_spec.js
@@ -14,6 +14,10 @@ describe('ScopeNavigation', () => {
fetchSidebarCount: jest.fn(),
};
+ const getterSpies = {
+ currentScope: jest.fn(() => 'issues'),
+ };
+
const createComponent = (initialState) => {
const store = new Vuex.Store({
state: {
@@ -22,6 +26,7 @@ describe('ScopeNavigation', () => {
...initialState,
},
actions: actionSpies,
+ getters: getterSpies,
});
wrapper = shallowMount(ScopeNavigation, {
@@ -36,9 +41,9 @@ describe('ScopeNavigation', () => {
const findNavElement = () => wrapper.find('nav');
const findGlNav = () => wrapper.findComponent(GlNav);
const findGlNavItems = () => wrapper.findAllComponents(GlNavItem);
- const findGlNavItemActive = () => findGlNavItems().wrappers.filter((w) => w.attributes('active'));
- const findGlNavItemActiveLabel = () => findGlNavItemActive().at(0).findAll('span').at(0).text();
- const findGlNavItemActiveCount = () => findGlNavItemActive().at(0).findAll('span').at(1);
+ const findGlNavItemActive = () => wrapper.find('[active=true]');
+ const findGlNavItemActiveLabel = () => findGlNavItemActive().find('[data-testid="label"]');
+ const findGlNavItemActiveCount = () => findGlNavItemActive().find('[data-testid="count"]');
describe('scope navigation', () => {
beforeEach(() => {
@@ -71,8 +76,8 @@ describe('ScopeNavigation', () => {
});
it('has correct active item', () => {
- expect(findGlNavItemActive()).toHaveLength(1);
- expect(findGlNavItemActiveLabel()).toBe('Issues');
+ expect(findGlNavItemActive().exists()).toBe(true);
+ expect(findGlNavItemActiveLabel().text()).toBe('Issues');
});
it('has correct active item count', () => {
@@ -80,7 +85,7 @@ describe('ScopeNavigation', () => {
});
it('does not have plus sign after count text', () => {
- expect(findGlNavItemActive().at(0).findComponent(GlIcon).exists()).toBe(false);
+ expect(findGlNavItemActive().findComponent(GlIcon).exists()).toBe(false);
});
it('has count is highlighted correctly', () => {
@@ -90,14 +95,26 @@ describe('ScopeNavigation', () => {
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(findGlNavItems().at(0).attributes('active')).toBe('true');
- expect(findGlNavItemActiveLabel()).toBe('Projects');
+ expect(findGlNavItemActive().exists()).toBe(true);
+ expect(findGlNavItemActiveLabel().text()).toBe('Projects');
});
it('has correct active item count', () => {
@@ -105,7 +122,7 @@ describe('ScopeNavigation', () => {
});
it('has correct active item count and over limit sign', () => {
- expect(findGlNavItemActive().at(0).findComponent(GlIcon).exists()).toBe(true);
+ expect(findGlNavItemActive().findComponent(GlIcon).exists()).toBe(true);
});
});
});
diff --git a/spec/frontend/search/store/getters_spec.js b/spec/frontend/search/store/getters_spec.js
index b70a6be8d46..0ef0922c4b0 100644
--- a/spec/frontend/search/store/getters_spec.js
+++ b/spec/frontend/search/store/getters_spec.js
@@ -9,6 +9,7 @@ import {
MOCK_AGGREGATIONS,
MOCK_LANGUAGE_AGGREGATIONS_BUCKETS,
TEST_FILTER_DATA,
+ MOCK_NAVIGATION,
} from '../mock_data';
describe('Global Search Store Getters', () => {
@@ -33,19 +34,26 @@ describe('Global Search Store Getters', () => {
});
});
- describe('langugageAggregationBuckets', () => {
+ describe('languageAggregationBuckets', () => {
it('returns the correct data', () => {
state.aggregations.data = MOCK_AGGREGATIONS;
- expect(getters.langugageAggregationBuckets(state)).toStrictEqual(
+ expect(getters.languageAggregationBuckets(state)).toStrictEqual(
MOCK_LANGUAGE_AGGREGATIONS_BUCKETS,
);
});
});
- describe('queryLangugageFilters', () => {
+ describe('queryLanguageFilters', () => {
it('returns the correct data', () => {
state.query.language = Object.keys(TEST_FILTER_DATA.filters);
- expect(getters.queryLangugageFilters(state)).toStrictEqual(state.query.language);
+ expect(getters.queryLanguageFilters(state)).toStrictEqual(state.query.language);
+ });
+ });
+
+ describe('currentScope', () => {
+ it('returns the correct scope name', () => {
+ state.navigation = MOCK_NAVIGATION;
+ expect(getters.currentScope(state)).toBe('issues');
});
});