summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/filtered_search_bar
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/vue_shared/components/filtered_search_bar')
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js6
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js51
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js13
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/store/modules/filters/test_helper.js4
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/author_token_spec.js4
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/branch_token_spec.js4
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js13
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js9
8 files changed, 75 insertions, 29 deletions
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js
index 8cc5d6775a7..b58ce0083c0 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js
@@ -25,10 +25,11 @@ import {
tokenValueLabel,
tokenValueMilestone,
tokenValueMembership,
+ tokenValueConfidential,
} from './mock_data';
jest.mock('~/vue_shared/components/filtered_search_bar/filtered_search_utils', () => ({
- uniqueTokens: jest.fn().mockImplementation(tokens => tokens),
+ uniqueTokens: jest.fn().mockImplementation((tokens) => tokens),
stripQuotes: jest.requireActual(
'~/vue_shared/components/filtered_search_bar/filtered_search_utils',
).stripQuotes,
@@ -227,12 +228,13 @@ describe('FilteredSearchBarRoot', () => {
});
describe('removeQuotesEnclosure', () => {
- const mockFilters = [tokenValueAuthor, tokenValueLabel, 'foo'];
+ const mockFilters = [tokenValueAuthor, tokenValueLabel, tokenValueConfidential, 'foo'];
it('returns filter array with unescaped strings for values which have spaces', () => {
expect(wrapper.vm.removeQuotesEnclosure(mockFilters)).toEqual([
tokenValueAuthor,
tokenValueLabel,
+ tokenValueConfidential,
'foo',
]);
});
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js
index 4869e75a2f3..9e96c154546 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_utils_spec.js
@@ -82,7 +82,10 @@ describe('prepareTokens', () => {
],
[
'assignees',
- [{ value: 'krillin', operator: '=' }, { value: 'piccolo', operator: '!=' }],
+ [
+ { value: 'krillin', operator: '=' },
+ { value: 'piccolo', operator: '!=' },
+ ],
[
{ type: 'assignees', value: { data: 'krillin', operator: '=' } },
{ type: 'assignees', value: { data: 'piccolo', operator: '!=' } },
@@ -90,7 +93,10 @@ describe('prepareTokens', () => {
],
[
'foo',
- [{ value: 'bar', operator: '!=' }, { value: 'baz', operator: '!=' }],
+ [
+ { value: 'bar', operator: '!=' },
+ { value: 'baz', operator: '!=' },
+ ],
[
{ type: 'foo', value: { data: 'bar', operator: '!=' } },
{ type: 'foo', value: { data: 'baz', operator: '!=' } },
@@ -112,7 +118,10 @@ describe('processFilters', () => {
expect(result).toStrictEqual({
foo: [{ value: 'foo', operator: '=' }],
- bar: [{ value: 'bar1', operator: '=' }, { value: 'bar2', operator: '!=' }],
+ bar: [
+ { value: 'bar1', operator: '=' },
+ { value: 'bar2', operator: '!=' },
+ ],
});
});
@@ -164,17 +173,26 @@ describe('filterToQueryObject', () => {
],
[
'foo',
- [{ value: 'bar', operator: '=' }, { value: 'baz', operator: '=' }],
+ [
+ { value: 'bar', operator: '=' },
+ { value: 'baz', operator: '=' },
+ ],
{ foo: ['bar', 'baz'], 'not[foo]': null },
],
[
'foo',
- [{ value: 'bar', operator: '!=' }, { value: 'baz', operator: '!=' }],
+ [
+ { value: 'bar', operator: '!=' },
+ { value: 'baz', operator: '!=' },
+ ],
{ foo: null, 'not[foo]': ['bar', 'baz'] },
],
[
'foo',
- [{ value: 'bar', operator: '!=' }, { value: 'baz', operator: '=' }],
+ [
+ { value: 'bar', operator: '!=' },
+ { value: 'baz', operator: '=' },
+ ],
{ foo: ['baz'], 'not[foo]': ['bar'] },
],
])('gathers filter values %s=%j into query object=%j', (token, value, result) => {
@@ -200,15 +218,30 @@ describe('urlQueryToFilter', () => {
['not[foo]=bar&foo=baz', { foo: { value: 'baz', operator: '=' } }],
[
'foo[]=bar&foo[]=baz&not[foo]=',
- { foo: [{ value: 'bar', operator: '=' }, { value: 'baz', operator: '=' }] },
+ {
+ foo: [
+ { value: 'bar', operator: '=' },
+ { value: 'baz', operator: '=' },
+ ],
+ },
],
[
'foo[]=&not[foo][]=bar&not[foo][]=baz',
- { foo: [{ value: 'bar', operator: '!=' }, { value: 'baz', operator: '!=' }] },
+ {
+ foo: [
+ { value: 'bar', operator: '!=' },
+ { value: 'baz', operator: '!=' },
+ ],
+ },
],
[
'foo[]=baz&not[foo][]=bar',
- { foo: [{ value: 'baz', operator: '=' }, { value: 'bar', operator: '!=' }] },
+ {
+ foo: [
+ { value: 'baz', operator: '=' },
+ { value: 'bar', operator: '!=' },
+ ],
+ },
],
['not[foo][]=bar', { foo: [{ value: 'bar', operator: '!=' }] }],
])('gathers filter values %s into query object=%j', (query, result) => {
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js b/spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js
index 64fbe70696d..7606b3bd91c 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js
@@ -110,7 +110,10 @@ export const mockMembershipToken = {
token: GlFilteredSearchToken,
unique: true,
operators: [{ value: '=', description: 'is' }],
- options: [{ value: 'exclude', title: 'Direct' }, { value: 'only', title: 'Inherited' }],
+ options: [
+ { value: 'exclude', title: 'Direct' },
+ { value: 'only', title: 'Inherited' },
+ ],
};
export const mockMembershipTokenOptionsWithoutTitles = {
@@ -152,6 +155,14 @@ export const tokenValueMembership = {
},
};
+export const tokenValueConfidential = {
+ type: 'confidential',
+ value: {
+ operator: '=',
+ data: true,
+ },
+};
+
export const tokenValuePlain = {
type: 'filtered-search-term',
value: { data: 'foo' },
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/store/modules/filters/test_helper.js b/spec/frontend/vue_shared/components/filtered_search_bar/store/modules/filters/test_helper.js
index 1b7c80a5252..84297923df3 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/store/modules/filters/test_helper.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/store/modules/filters/test_helper.js
@@ -1,11 +1,11 @@
export function getFilterParams(tokens, options = {}) {
const { key = 'value', operator = '=', prop = 'title' } = options;
- return tokens.map(token => {
+ return tokens.map((token) => {
return { [key]: token[prop], operator };
});
}
export function getFilterValues(tokens, options = {}) {
const { prop = 'title' } = options;
- return tokens.map(token => token[prop]);
+ return tokens.map((token) => token[prop]);
}
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/author_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/author_token_spec.js
index 3fd1d8b7f42..3997d6a99a6 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/author_token_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/author_token_spec.js
@@ -189,8 +189,8 @@ describe('AuthorToken', () => {
suggestionsSegment.vm.$emit('activate');
await wrapper.vm.$nextTick();
- expect(wrapper.contains(GlFilteredSearchSuggestion)).toBe(false);
- expect(wrapper.contains(GlDropdownDivider)).toBe(false);
+ expect(wrapper.find(GlFilteredSearchSuggestion).exists()).toBe(false);
+ expect(wrapper.find(GlDropdownDivider).exists()).toBe(false);
});
it('renders `DEFAULT_LABEL_ANY` as default suggestions', async () => {
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/branch_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/branch_token_spec.js
index 5b7f7d242e9..35f487330be 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/branch_token_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/branch_token_spec.js
@@ -189,8 +189,8 @@ describe('BranchToken', () => {
});
await showSuggestions();
- expect(wrapper.contains(GlFilteredSearchSuggestion)).toBe(false);
- expect(wrapper.contains(GlDropdownDivider)).toBe(false);
+ expect(wrapper.find(GlFilteredSearchSuggestion).exists()).toBe(false);
+ expect(wrapper.find(GlDropdownDivider).exists()).toBe(false);
});
it('renders no suggestions as default', async () => {
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js
index 74172db81c2..dda0ad39bbc 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js
@@ -181,12 +181,9 @@ describe('LabelToken', () => {
expect(tokenSegments).toHaveLength(3); // Label, =, "Foo Label"
expect(tokenSegments.at(2).text()).toBe(`~${mockRegularLabel.title}`); // "Foo Label"
- expect(
- tokenSegments
- .at(2)
- .find('.gl-token')
- .attributes('style'),
- ).toBe('background-color: rgb(186, 218, 85); color: rgb(255, 255, 255);');
+ expect(tokenSegments.at(2).find('.gl-token').attributes('style')).toBe(
+ 'background-color: rgb(186, 218, 85); color: rgb(255, 255, 255);',
+ );
});
it('renders provided defaultLabels as suggestions', async () => {
@@ -219,8 +216,8 @@ describe('LabelToken', () => {
suggestionsSegment.vm.$emit('activate');
await wrapper.vm.$nextTick();
- expect(wrapper.contains(GlFilteredSearchSuggestion)).toBe(false);
- expect(wrapper.contains(GlDropdownDivider)).toBe(false);
+ expect(wrapper.find(GlFilteredSearchSuggestion).exists()).toBe(false);
+ expect(wrapper.find(GlDropdownDivider).exists()).toBe(false);
});
it('renders `DEFAULT_LABELS` as default suggestions', async () => {
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js
index 67f9a9c70cc..164561f6244 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/milestone_token_spec.js
@@ -140,7 +140,10 @@ describe('MilestoneToken', () => {
});
describe('template', () => {
- const defaultMilestones = [{ text: 'foo', value: 'foo' }, { text: 'bar', value: 'baz' }];
+ const defaultMilestones = [
+ { text: 'foo', value: 'foo' },
+ { text: 'bar', value: 'baz' },
+ ];
beforeEach(async () => {
wrapper = createComponent({ value: { data: `"${mockRegularMilestone.title}"` } });
@@ -193,8 +196,8 @@ describe('MilestoneToken', () => {
suggestionsSegment.vm.$emit('activate');
await wrapper.vm.$nextTick();
- expect(wrapper.contains(GlFilteredSearchSuggestion)).toBe(false);
- expect(wrapper.contains(GlDropdownDivider)).toBe(false);
+ expect(wrapper.find(GlFilteredSearchSuggestion).exists()).toBe(false);
+ expect(wrapper.find(GlDropdownDivider).exists()).toBe(false);
});
it('renders `DEFAULT_MILESTONES` as default suggestions', async () => {