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:
Diffstat (limited to 'spec/frontend/boards/components/board_filtered_search_spec.js')
-rw-r--r--spec/frontend/boards/components/board_filtered_search_spec.js73
1 files changed, 45 insertions, 28 deletions
diff --git a/spec/frontend/boards/components/board_filtered_search_spec.js b/spec/frontend/boards/components/board_filtered_search_spec.js
index 0bd936c9abd..5e96b508f37 100644
--- a/spec/frontend/boards/components/board_filtered_search_spec.js
+++ b/spec/frontend/boards/components/board_filtered_search_spec.js
@@ -1,7 +1,4 @@
import { shallowMount } from '@vue/test-utils';
-import Vue from 'vue';
-// eslint-disable-next-line no-restricted-imports
-import Vuex from 'vuex';
import BoardFilteredSearch from '~/boards/components/board_filtered_search.vue';
import { updateHistory } from '~/lib/utils/url_utility';
import {
@@ -20,9 +17,6 @@ import {
import FilteredSearchBarRoot from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue';
import UserToken from '~/vue_shared/components/filtered_search_bar/tokens/user_token.vue';
import LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue';
-import { createStore } from '~/boards/stores';
-
-Vue.use(Vuex);
jest.mock('~/lib/utils/url_utility', () => ({
updateHistory: jest.fn(),
@@ -32,7 +26,6 @@ jest.mock('~/lib/utils/url_utility', () => ({
describe('BoardFilteredSearch', () => {
let wrapper;
- let store;
const tokens = [
{
icon: 'labels',
@@ -63,10 +56,12 @@ describe('BoardFilteredSearch', () => {
];
const createComponent = ({ initialFilterParams = {}, props = {}, provide = {} } = {}) => {
- store = createStore();
wrapper = shallowMount(BoardFilteredSearch, {
- provide: { initialFilterParams, fullPath: '', isApolloBoard: false, ...provide },
- store,
+ provide: {
+ initialFilterParams,
+ fullPath: '',
+ ...provide,
+ },
propsData: {
...props,
tokens,
@@ -79,8 +74,6 @@ describe('BoardFilteredSearch', () => {
describe('default', () => {
beforeEach(() => {
createComponent();
-
- jest.spyOn(store, 'dispatch').mockImplementation();
});
it('passes the correct tokens to FilteredSearch', () => {
@@ -88,12 +81,6 @@ describe('BoardFilteredSearch', () => {
});
describe('when onFilter is emitted', () => {
- it('calls performSearch', () => {
- findFilteredSearch().vm.$emit('onFilter', [{ value: { data: '' } }]);
-
- expect(store.dispatch).toHaveBeenCalledWith('performSearch');
- });
-
it('calls historyPushState', () => {
findFilteredSearch().vm.$emit('onFilter', [{ value: { data: 'searchQuery' } }]);
@@ -104,10 +91,22 @@ describe('BoardFilteredSearch', () => {
});
});
});
+
+ it('emits setFilters and updates URL when onFilter is emitted', () => {
+ findFilteredSearch().vm.$emit('onFilter', [{ value: { data: '' } }]);
+
+ expect(updateHistory).toHaveBeenCalledWith({
+ title: '',
+ replace: true,
+ url: 'http://test.host/',
+ });
+
+ expect(wrapper.emitted('setFilters')).toHaveLength(1);
+ });
});
describe('when eeFilters is not empty', () => {
- it('passes the correct initialFilterValue to FitleredSearchBarRoot', () => {
+ it('passes the correct initialFilterValue to FilteredSearchBarRoot', () => {
createComponent({ props: { eeFilters: { labelName: ['label'] } } });
expect(findFilteredSearch().props('initialFilterValue')).toEqual([
@@ -125,8 +124,6 @@ describe('BoardFilteredSearch', () => {
describe('when searching', () => {
beforeEach(() => {
createComponent();
-
- jest.spyOn(store, 'dispatch').mockImplementation();
});
it('sets the url params to the correct results', () => {
@@ -146,7 +143,6 @@ describe('BoardFilteredSearch', () => {
findFilteredSearch().vm.$emit('onFilter', mockFilters);
- expect(store.dispatch).toHaveBeenCalledWith('performSearch');
expect(updateHistory).toHaveBeenCalledWith({
title: '',
replace: true,
@@ -193,21 +189,42 @@ describe('BoardFilteredSearch', () => {
});
});
- describe('when Apollo boards FF is on', () => {
+ describe('when iteration is passed a wildcard value with a cadence id', () => {
+ const url = (arg) => `http://test.host/?iteration_id=${arg}&iteration_cadence_id=1349`;
+
beforeEach(() => {
- createComponent({ provide: { isApolloBoard: true } });
+ createComponent();
});
- it('emits setFilters and updates URL when onFilter is emitted', () => {
- findFilteredSearch().vm.$emit('onFilter', [{ value: { data: '' } }]);
+ it.each([
+ ['Current&1349', url('Current'), 'Current'],
+ ['Any&1349', url('Any'), 'Any'],
+ ])('sets the url param %s', (iterationParam, expected, wildCardId) => {
+ Object.defineProperty(window, 'location', {
+ writable: true,
+ value: new URL(expected),
+ });
+
+ const mockFilters = [
+ { type: TOKEN_TYPE_ITERATION, value: { data: iterationParam, operator: '=' } },
+ ];
+
+ findFilteredSearch().vm.$emit('onFilter', mockFilters);
expect(updateHistory).toHaveBeenCalledWith({
title: '',
replace: true,
- url: 'http://test.host/',
+ url: expected,
});
- expect(wrapper.emitted('setFilters')).toHaveLength(1);
+ expect(wrapper.emitted('setFilters')).toStrictEqual([
+ [
+ {
+ iterationCadenceId: '1349',
+ iterationId: wildCardId,
+ },
+ ],
+ ]);
});
});
});