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/vue_shared/components/filtered_search_bar')
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/filtered_search_bar_root_spec.js33
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/mock_data.js109
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js18
-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/crm_contact_token_spec.js10
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_organization_token_spec.js10
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/emoji_token_spec.js14
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/label_token_spec.js12
-rw-r--r--spec/frontend/vue_shared/components/filtered_search_bar/tokens/user_token_spec.js (renamed from spec/frontend/vue_shared/components/filtered_search_bar/tokens/author_token_spec.js)104
9 files changed, 162 insertions, 152 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 1b9ca8e6092..b0e393bbf5e 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
@@ -13,7 +13,10 @@ import RecentSearchesService from '~/filtered_search/services/recent_searches_se
import RecentSearchesStore from '~/filtered_search/stores/recent_searches_store';
import {
FILTERED_SEARCH_TERM,
- SortDirection,
+ SORT_DIRECTION,
+ TOKEN_TYPE_AUTHOR,
+ TOKEN_TYPE_LABEL,
+ TOKEN_TYPE_MILESTONE,
} from '~/vue_shared/components/filtered_search_bar/constants';
import FilteredSearchBarRoot from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue';
import { uniqueTokens } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils';
@@ -87,7 +90,7 @@ describe('FilteredSearchBarRoot', () => {
it('initializes `filterValue`, `selectedSortOption` and `selectedSortDirection` data props and displays the sort dropdown', () => {
expect(wrapper.vm.filterValue).toEqual([]);
expect(wrapper.vm.selectedSortOption).toBe(mockSortOptions[0]);
- expect(wrapper.vm.selectedSortDirection).toBe(SortDirection.descending);
+ expect(wrapper.vm.selectedSortDirection).toBe(SORT_DIRECTION.descending);
expect(wrapper.findComponent(GlButtonGroup).exists()).toBe(true);
expect(wrapper.findComponent(GlButton).exists()).toBe(true);
expect(wrapper.findComponent(GlDropdown).exists()).toBe(true);
@@ -110,9 +113,9 @@ describe('FilteredSearchBarRoot', () => {
describe('tokenSymbols', () => {
it('returns a map containing type and symbols from `tokens` prop', () => {
expect(wrapper.vm.tokenSymbols).toEqual({
- author_username: '@',
- label_name: '~',
- milestone_title: '%',
+ [TOKEN_TYPE_AUTHOR]: '@',
+ [TOKEN_TYPE_LABEL]: '~',
+ [TOKEN_TYPE_MILESTONE]: '%',
});
});
});
@@ -120,9 +123,9 @@ describe('FilteredSearchBarRoot', () => {
describe('tokenTitles', () => {
it('returns a map containing type and title from `tokens` prop', () => {
expect(wrapper.vm.tokenTitles).toEqual({
- author_username: 'Author',
- label_name: 'Label',
- milestone_title: 'Milestone',
+ [TOKEN_TYPE_AUTHOR]: 'Author',
+ [TOKEN_TYPE_LABEL]: 'Label',
+ [TOKEN_TYPE_MILESTONE]: 'Milestone',
});
});
});
@@ -132,7 +135,7 @@ describe('FilteredSearchBarRoot', () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
wrapper.setData({
- selectedSortDirection: SortDirection.ascending,
+ selectedSortDirection: SORT_DIRECTION.ascending,
});
expect(wrapper.vm.sortDirectionIcon).toBe('sort-lowest');
@@ -142,7 +145,7 @@ describe('FilteredSearchBarRoot', () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
wrapper.setData({
- selectedSortDirection: SortDirection.descending,
+ selectedSortDirection: SORT_DIRECTION.descending,
});
expect(wrapper.vm.sortDirectionIcon).toBe('sort-highest');
@@ -154,7 +157,7 @@ describe('FilteredSearchBarRoot', () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
wrapper.setData({
- selectedSortDirection: SortDirection.ascending,
+ selectedSortDirection: SORT_DIRECTION.ascending,
});
expect(wrapper.vm.sortDirectionTooltip).toBe('Sort direction: Ascending');
@@ -164,7 +167,7 @@ describe('FilteredSearchBarRoot', () => {
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
wrapper.setData({
- selectedSortDirection: SortDirection.descending,
+ selectedSortDirection: SORT_DIRECTION.descending,
});
expect(wrapper.vm.sortDirectionTooltip).toBe('Sort direction: Descending');
@@ -272,11 +275,11 @@ describe('FilteredSearchBarRoot', () => {
});
it('sets `selectedSortDirection` to be opposite of its current value', () => {
- expect(wrapper.vm.selectedSortDirection).toBe(SortDirection.descending);
+ expect(wrapper.vm.selectedSortDirection).toBe(SORT_DIRECTION.descending);
wrapper.vm.handleSortDirectionClick();
- expect(wrapper.vm.selectedSortDirection).toBe(SortDirection.ascending);
+ expect(wrapper.vm.selectedSortDirection).toBe(SORT_DIRECTION.ascending);
});
it('emits component event `onSort` with opposite of currently selected sort by value', () => {
@@ -384,7 +387,7 @@ describe('FilteredSearchBarRoot', () => {
// eslint-disable-next-line no-restricted-syntax
wrapper.setData({
selectedSortOption: mockSortOptions[0],
- selectedSortDirection: SortDirection.descending,
+ selectedSortDirection: SORT_DIRECTION.descending,
recentSearches: mockHistoryItems,
});
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 a6713b7e7e4..b2f4c780f51 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
@@ -1,8 +1,28 @@
import { GlFilteredSearchToken } from '@gitlab/ui';
-import { mockLabels } from 'jest/vue_shared/components/sidebar/labels_select_vue/mock_data';
+import { mockLabels } from 'jest/sidebar/components/labels/labels_select_vue/mock_data';
import Api from '~/api';
-import { OPERATOR_IS_ONLY } from '~/vue_shared/components/filtered_search_bar/constants';
-import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue';
+import {
+ FILTERED_SEARCH_TERM,
+ OPERATORS_IS,
+ TOKEN_TITLE_AUTHOR,
+ TOKEN_TITLE_CONTACT,
+ TOKEN_TITLE_LABEL,
+ TOKEN_TITLE_MILESTONE,
+ TOKEN_TITLE_MY_REACTION,
+ TOKEN_TITLE_ORGANIZATION,
+ TOKEN_TITLE_RELEASE,
+ TOKEN_TITLE_SOURCE_BRANCH,
+ TOKEN_TYPE_AUTHOR,
+ TOKEN_TYPE_CONFIDENTIAL,
+ TOKEN_TYPE_CONTACT,
+ TOKEN_TYPE_LABEL,
+ TOKEN_TYPE_MILESTONE,
+ TOKEN_TYPE_MY_REACTION,
+ TOKEN_TYPE_ORGANIZATION,
+ TOKEN_TYPE_RELEASE,
+ TOKEN_TYPE_SOURCE_BRANCH,
+} from '~/vue_shared/components/filtered_search_bar/constants';
+import UserToken from '~/vue_shared/components/filtered_search_bar/tokens/user_token.vue';
import BranchToken from '~/vue_shared/components/filtered_search_bar/tokens/branch_token.vue';
import EmojiToken from '~/vue_shared/components/filtered_search_bar/tokens/emoji_token.vue';
import LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue';
@@ -11,7 +31,7 @@ import ReleaseToken from '~/vue_shared/components/filtered_search_bar/tokens/rel
import CrmContactToken from '~/vue_shared/components/filtered_search_bar/tokens/crm_contact_token.vue';
import CrmOrganizationToken from '~/vue_shared/components/filtered_search_bar/tokens/crm_organization_token.vue';
-export const mockAuthor1 = {
+export const mockUser1 = {
id: 1,
name: 'Administrator',
username: 'root',
@@ -20,7 +40,7 @@ export const mockAuthor1 = {
web_url: 'http://0.0.0.0:3000/root',
};
-export const mockAuthor2 = {
+export const mockUser2 = {
id: 2,
name: 'Claudio Beer',
username: 'ericka_terry',
@@ -29,7 +49,7 @@ export const mockAuthor2 = {
web_url: 'http://0.0.0.0:3000/ericka_terry',
};
-export const mockAuthor3 = {
+export const mockUser3 = {
id: 6,
name: 'Shizue Hartmann',
username: 'junita.weimann',
@@ -38,7 +58,7 @@ export const mockAuthor3 = {
web_url: 'http://0.0.0.0:3000/junita.weimann',
};
-export const mockAuthors = [mockAuthor1, mockAuthor2, mockAuthor3];
+export const mockUsers = [mockUser1, mockUser2, mockUser3];
export const mockBranches = [{ name: 'Main' }, { name: 'v1.x' }, { name: 'my-Branch' }];
@@ -197,86 +217,86 @@ export const mockEmoji2 = {
export const mockEmojis = [mockEmoji1, mockEmoji2];
export const mockBranchToken = {
- type: 'source_branch',
+ type: TOKEN_TYPE_SOURCE_BRANCH,
icon: 'branch',
- title: 'Source Branch',
+ title: TOKEN_TITLE_SOURCE_BRANCH,
unique: true,
token: BranchToken,
- operators: OPERATOR_IS_ONLY,
+ operators: OPERATORS_IS,
fetchBranches: Api.branches.bind(Api),
};
export const mockAuthorToken = {
- type: 'author_username',
+ type: TOKEN_TYPE_AUTHOR,
icon: 'user',
- title: 'Author',
+ title: TOKEN_TITLE_AUTHOR,
unique: false,
symbol: '@',
- token: AuthorToken,
- operators: OPERATOR_IS_ONLY,
+ token: UserToken,
+ operators: OPERATORS_IS,
fetchPath: 'gitlab-org/gitlab-test',
- fetchAuthors: Api.projectUsers.bind(Api),
+ fetchUsers: Api.projectUsers.bind(Api),
};
export const mockLabelToken = {
- type: 'label_name',
+ type: TOKEN_TYPE_LABEL,
icon: 'labels',
- title: 'Label',
+ title: TOKEN_TITLE_LABEL,
unique: false,
symbol: '~',
token: LabelToken,
- operators: OPERATOR_IS_ONLY,
+ operators: OPERATORS_IS,
fetchLabels: () => Promise.resolve(mockLabels),
};
export const mockMilestoneToken = {
- type: 'milestone_title',
+ type: TOKEN_TYPE_MILESTONE,
icon: 'clock',
- title: 'Milestone',
+ title: TOKEN_TITLE_MILESTONE,
unique: true,
symbol: '%',
token: MilestoneToken,
- operators: OPERATOR_IS_ONLY,
+ operators: OPERATORS_IS,
fetchMilestones: () => Promise.resolve({ data: mockMilestones }),
};
export const mockReleaseToken = {
- type: 'release',
+ type: TOKEN_TYPE_RELEASE,
icon: 'rocket',
- title: 'Release',
+ title: TOKEN_TITLE_RELEASE,
token: ReleaseToken,
fetchReleases: () => Promise.resolve(),
};
export const mockReactionEmojiToken = {
- type: 'my_reaction_emoji',
+ type: TOKEN_TYPE_MY_REACTION,
icon: 'thumb-up',
- title: 'My-Reaction',
+ title: TOKEN_TITLE_MY_REACTION,
unique: true,
token: EmojiToken,
- operators: OPERATOR_IS_ONLY,
+ operators: OPERATORS_IS,
fetchEmojis: () => Promise.resolve(mockEmojis),
};
export const mockCrmContactToken = {
- type: 'crm_contact',
- title: 'Contact',
+ type: TOKEN_TYPE_CONTACT,
+ title: TOKEN_TITLE_CONTACT,
icon: 'user',
token: CrmContactToken,
isProject: false,
fullPath: 'group',
- operators: OPERATOR_IS_ONLY,
+ operators: OPERATORS_IS,
unique: true,
};
export const mockCrmOrganizationToken = {
- type: 'crm_contact',
- title: 'Organization',
+ type: TOKEN_TYPE_ORGANIZATION,
+ title: TOKEN_TITLE_ORGANIZATION,
icon: 'user',
token: CrmOrganizationToken,
isProject: false,
fullPath: 'group',
- operators: OPERATOR_IS_ONLY,
+ operators: OPERATORS_IS,
unique: true,
};
@@ -286,7 +306,7 @@ export const mockMembershipToken = {
title: 'Membership',
token: GlFilteredSearchToken,
unique: true,
- operators: OPERATOR_IS_ONLY,
+ operators: OPERATORS_IS,
options: [
{ value: 'exclude', title: 'Direct' },
{ value: 'only', title: 'Inherited' },
@@ -301,7 +321,7 @@ export const mockMembershipTokenOptionsWithoutTitles = {
export const mockAvailableTokens = [mockAuthorToken, mockLabelToken, mockMilestoneToken];
export const tokenValueAuthor = {
- type: 'author_username',
+ type: TOKEN_TYPE_AUTHOR,
value: {
data: 'root',
operator: '=',
@@ -309,7 +329,7 @@ export const tokenValueAuthor = {
};
export const tokenValueLabel = {
- type: 'label_name',
+ type: TOKEN_TYPE_LABEL,
value: {
operator: '=',
data: 'bug',
@@ -317,7 +337,7 @@ export const tokenValueLabel = {
};
export const tokenValueMilestone = {
- type: 'milestone_title',
+ type: TOKEN_TYPE_MILESTONE,
value: {
operator: '=',
data: 'v1.0',
@@ -333,7 +353,7 @@ export const tokenValueMembership = {
};
export const tokenValueConfidential = {
- type: 'confidential',
+ type: TOKEN_TYPE_CONFIDENTIAL,
value: {
operator: '=',
data: true,
@@ -341,23 +361,10 @@ export const tokenValueConfidential = {
};
export const tokenValuePlain = {
- type: 'filtered-search-term',
+ type: FILTERED_SEARCH_TERM,
value: { data: 'foo' },
};
-export const tokenValueEmpty = {
- type: 'filtered-search-term',
- value: { data: '' },
-};
-
-export const tokenValueEpic = {
- type: 'epic_iid',
- value: {
- operator: '=',
- data: '"foo"::&42',
- },
-};
-
export const mockHistoryItems = [
[tokenValueAuthor, tokenValueLabel, tokenValueMilestone, 'duo'],
[tokenValueAuthor, 'si'],
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
index a0126c2bd63..164235e4bb9 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
@@ -12,12 +12,12 @@ import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import {
mockRegularLabel,
mockLabels,
-} from 'jest/vue_shared/components/sidebar/labels_select_vue/mock_data';
+} from 'jest/sidebar/components/labels/labels_select_vue/mock_data';
import {
- DEFAULT_NONE_ANY,
+ OPTIONS_NONE_ANY,
OPERATOR_IS,
- OPERATOR_IS_NOT,
+ OPERATOR_NOT,
} from '~/vue_shared/components/filtered_search_bar/constants';
import {
getRecentlyUsedSuggestions,
@@ -76,7 +76,7 @@ const mockProps = {
active: false,
suggestions: [],
suggestionsLoading: false,
- defaultSuggestions: DEFAULT_NONE_ANY,
+ defaultSuggestions: OPTIONS_NONE_ANY,
getActiveTokenValue: (labels, data) => labels.find((label) => label.title === data),
cursorPosition: 'start',
};
@@ -301,13 +301,13 @@ describe('BaseToken', () => {
describe('with default suggestions', () => {
describe.each`
- operator | shouldRenderFilteredSearchSuggestion
- ${OPERATOR_IS} | ${true}
- ${OPERATOR_IS_NOT} | ${false}
+ operator | shouldRenderFilteredSearchSuggestion
+ ${OPERATOR_IS} | ${true}
+ ${OPERATOR_NOT} | ${false}
`('when operator is $operator', ({ shouldRenderFilteredSearchSuggestion, operator }) => {
beforeEach(() => {
const props = {
- defaultSuggestions: DEFAULT_NONE_ANY,
+ defaultSuggestions: OPTIONS_NONE_ANY,
value: { data: '', operator },
};
@@ -322,7 +322,7 @@ describe('BaseToken', () => {
if (shouldRenderFilteredSearchSuggestion) {
expect(filteredSearchSuggestions.map((c) => c.props())).toMatchObject(
- DEFAULT_NONE_ANY.map((opt) => ({ value: opt.value })),
+ OPTIONS_NONE_ANY.map((opt) => ({ value: opt.value })),
);
} else {
expect(filteredSearchSuggestions).toHaveLength(0);
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 05b42011fe1..311d5a13280 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
@@ -11,7 +11,7 @@ import waitForPromises from 'helpers/wait_for_promises';
import { createAlert } from '~/flash';
import axios from '~/lib/utils/axios_utils';
-import { DEFAULT_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
+import { OPTIONS_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
import BranchToken from '~/vue_shared/components/filtered_search_bar/tokens/branch_token.vue';
import { mockBranches, mockBranchToken } from '../mock_data';
@@ -112,7 +112,7 @@ describe('BranchToken', () => {
});
describe('template', () => {
- const defaultBranches = DEFAULT_NONE_ANY;
+ const defaultBranches = OPTIONS_NONE_ANY;
async function showSuggestions() {
const tokenSegments = wrapper.findAllComponents(GlFilteredSearchTokenSegment);
const suggestionsSegment = tokenSegments.at(2);
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_contact_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_contact_token_spec.js
index 5b744521979..7be7035a0f2 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_contact_token_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_contact_token_spec.js
@@ -10,7 +10,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import { createAlert } from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
-import { DEFAULT_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
+import { OPTIONS_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
import CrmContactToken from '~/vue_shared/components/filtered_search_bar/tokens/crm_contact_token.vue';
import searchCrmContactsQuery from '~/vue_shared/components/filtered_search_bar/queries/search_crm_contacts.query.graphql';
@@ -187,7 +187,7 @@ describe('CrmContactToken', () => {
});
describe('template', () => {
- const defaultContacts = DEFAULT_NONE_ANY;
+ const defaultContacts = OPTIONS_NONE_ANY;
it('renders base-token component', () => {
mountComponent({
@@ -250,7 +250,7 @@ describe('CrmContactToken', () => {
expect(wrapper.findComponent(GlDropdownDivider).exists()).toBe(false);
});
- it('renders `DEFAULT_NONE_ANY` as default suggestions', () => {
+ it('renders `OPTIONS_NONE_ANY` as default suggestions', () => {
mountComponent({
active: true,
config: { ...mockCrmContactToken },
@@ -262,8 +262,8 @@ describe('CrmContactToken', () => {
const suggestions = wrapper.findAllComponents(GlFilteredSearchSuggestion);
- expect(suggestions).toHaveLength(DEFAULT_NONE_ANY.length);
- DEFAULT_NONE_ANY.forEach((contact, index) => {
+ expect(suggestions).toHaveLength(OPTIONS_NONE_ANY.length);
+ OPTIONS_NONE_ANY.forEach((contact, index) => {
expect(suggestions.at(index).text()).toBe(contact.text);
});
});
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_organization_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_organization_token_spec.js
index 3a3e96032e8..ecd3e8a04f1 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_organization_token_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/crm_organization_token_spec.js
@@ -10,7 +10,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import { createAlert } from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
-import { DEFAULT_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
+import { OPTIONS_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
import CrmOrganizationToken from '~/vue_shared/components/filtered_search_bar/tokens/crm_organization_token.vue';
import searchCrmOrganizationsQuery from '~/vue_shared/components/filtered_search_bar/queries/search_crm_organizations.query.graphql';
@@ -186,7 +186,7 @@ describe('CrmOrganizationToken', () => {
});
describe('template', () => {
- const defaultOrganizations = DEFAULT_NONE_ANY;
+ const defaultOrganizations = OPTIONS_NONE_ANY;
it('renders base-token component', () => {
mountComponent({
@@ -249,7 +249,7 @@ describe('CrmOrganizationToken', () => {
expect(wrapper.findComponent(GlDropdownDivider).exists()).toBe(false);
});
- it('renders `DEFAULT_NONE_ANY` as default suggestions', () => {
+ it('renders `OPTIONS_NONE_ANY` as default suggestions', () => {
mountComponent({
active: true,
config: { ...mockCrmOrganizationToken },
@@ -261,8 +261,8 @@ describe('CrmOrganizationToken', () => {
const suggestions = wrapper.findAllComponents(GlFilteredSearchSuggestion);
- expect(suggestions).toHaveLength(DEFAULT_NONE_ANY.length);
- DEFAULT_NONE_ANY.forEach((organization, index) => {
+ expect(suggestions).toHaveLength(OPTIONS_NONE_ANY.length);
+ OPTIONS_NONE_ANY.forEach((organization, index) => {
expect(suggestions.at(index).text()).toBe(organization.text);
});
});
diff --git a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/emoji_token_spec.js b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/emoji_token_spec.js
index e8436d2db17..773df01ada7 100644
--- a/spec/frontend/vue_shared/components/filtered_search_bar/tokens/emoji_token_spec.js
+++ b/spec/frontend/vue_shared/components/filtered_search_bar/tokens/emoji_token_spec.js
@@ -12,9 +12,9 @@ import { createAlert } from '~/flash';
import axios from '~/lib/utils/axios_utils';
import {
- DEFAULT_LABEL_NONE,
- DEFAULT_LABEL_ANY,
- DEFAULT_NONE_ANY,
+ OPTION_NONE,
+ OPTION_ANY,
+ OPTIONS_NONE_ANY,
} from '~/vue_shared/components/filtered_search_bar/constants';
import EmojiToken from '~/vue_shared/components/filtered_search_bar/tokens/emoji_token.vue';
@@ -118,7 +118,7 @@ describe('EmojiToken', () => {
});
describe('template', () => {
- const defaultEmojis = DEFAULT_NONE_ANY;
+ const defaultEmojis = OPTIONS_NONE_ANY;
beforeEach(async () => {
wrapper = createComponent({
@@ -181,7 +181,7 @@ describe('EmojiToken', () => {
expect(wrapper.findComponent(GlDropdownDivider).exists()).toBe(false);
});
- it('renders `DEFAULT_LABEL_NONE` and `DEFAULT_LABEL_ANY` as default suggestions', async () => {
+ it('renders `OPTION_NONE` and `OPTION_ANY` as default suggestions', async () => {
wrapper = createComponent({
active: true,
config: { ...mockReactionEmojiToken },
@@ -195,8 +195,8 @@ describe('EmojiToken', () => {
const suggestions = wrapper.findAllComponents(GlFilteredSearchSuggestion);
expect(suggestions).toHaveLength(2);
- expect(suggestions.at(0).text()).toBe(DEFAULT_LABEL_NONE.text);
- expect(suggestions.at(1).text()).toBe(DEFAULT_LABEL_ANY.text);
+ expect(suggestions.at(0).text()).toBe(OPTION_NONE.text);
+ expect(suggestions.at(1).text()).toBe(OPTION_ANY.text);
});
});
});
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 8ca12afacec..9d96123c17f 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
@@ -10,11 +10,11 @@ import waitForPromises from 'helpers/wait_for_promises';
import {
mockRegularLabel,
mockLabels,
-} from 'jest/vue_shared/components/sidebar/labels_select_vue/mock_data';
+} from 'jest/sidebar/components/labels/labels_select_vue/mock_data';
import { createAlert } from '~/flash';
import axios from '~/lib/utils/axios_utils';
-import { DEFAULT_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
+import { OPTIONS_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
import LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue';
@@ -141,7 +141,7 @@ describe('LabelToken', () => {
});
describe('template', () => {
- const defaultLabels = DEFAULT_NONE_ANY;
+ const defaultLabels = OPTIONS_NONE_ANY;
beforeEach(async () => {
wrapper = createComponent({ value: { data: `"${mockRegularLabel.title}"` } });
@@ -209,7 +209,7 @@ describe('LabelToken', () => {
expect(wrapper.findComponent(GlDropdownDivider).exists()).toBe(false);
});
- it('renders `DEFAULT_NONE_ANY` as default suggestions', () => {
+ it('renders `OPTIONS_NONE_ANY` as default suggestions', () => {
wrapper = createComponent({
active: true,
config: { ...mockLabelToken },
@@ -221,8 +221,8 @@ describe('LabelToken', () => {
const suggestions = wrapper.findAllComponents(GlFilteredSearchSuggestion);
- expect(suggestions).toHaveLength(DEFAULT_NONE_ANY.length);
- DEFAULT_NONE_ANY.forEach((label, index) => {
+ expect(suggestions).toHaveLength(OPTIONS_NONE_ANY.length);
+ OPTIONS_NONE_ANY.forEach((label, index) => {
expect(suggestions.at(index).text()).toBe(label.text);
});
});
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/user_token_spec.js
index 5371b9af475..32cb74d5f80 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/user_token_spec.js
@@ -11,11 +11,11 @@ import waitForPromises from 'helpers/wait_for_promises';
import { createAlert } from '~/flash';
import axios from '~/lib/utils/axios_utils';
-import { DEFAULT_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
-import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue';
+import { OPTIONS_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
+import UserToken from '~/vue_shared/components/filtered_search_bar/tokens/user_token.vue';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
-import { mockAuthorToken, mockAuthors } from '../mock_data';
+import { mockAuthorToken, mockUsers } from '../mock_data';
jest.mock('~/flash');
const defaultStubs = {
@@ -28,7 +28,7 @@ const defaultStubs = {
},
};
-const mockPreloadedAuthors = [
+const mockPreloadedUsers = [
{
id: 13,
name: 'Administrator',
@@ -46,7 +46,7 @@ function createComponent(options = {}) {
data = {},
listeners = {},
} = options;
- return mount(AuthorToken, {
+ return mount(UserToken, {
propsData: {
config,
value,
@@ -66,7 +66,7 @@ function createComponent(options = {}) {
});
}
-describe('AuthorToken', () => {
+describe('UserToken', () => {
const originalGon = window.gon;
const currentUserLength = 1;
let mock;
@@ -85,40 +85,40 @@ describe('AuthorToken', () => {
});
describe('methods', () => {
- describe('fetchAuthors', () => {
+ describe('fetchUsers', () => {
beforeEach(() => {
wrapper = createComponent();
});
- it('calls `config.fetchAuthors` with provided searchTerm param', () => {
- jest.spyOn(wrapper.vm.config, 'fetchAuthors');
+ it('calls `config.fetchUsers` with provided searchTerm param', () => {
+ jest.spyOn(wrapper.vm.config, 'fetchUsers');
- getBaseToken().vm.$emit('fetch-suggestions', mockAuthors[0].username);
+ getBaseToken().vm.$emit('fetch-suggestions', mockUsers[0].username);
- expect(wrapper.vm.config.fetchAuthors).toHaveBeenCalledWith(
+ expect(wrapper.vm.config.fetchUsers).toHaveBeenCalledWith(
mockAuthorToken.fetchPath,
- mockAuthors[0].username,
+ mockUsers[0].username,
);
});
- it('sets response to `authors` when request is succesful', () => {
- jest.spyOn(wrapper.vm.config, 'fetchAuthors').mockResolvedValue(mockAuthors);
+ it('sets response to `users` when request is successful', () => {
+ jest.spyOn(wrapper.vm.config, 'fetchUsers').mockResolvedValue(mockUsers);
getBaseToken().vm.$emit('fetch-suggestions', 'root');
return waitForPromises().then(() => {
- expect(getBaseToken().props('suggestions')).toEqual(mockAuthors);
+ expect(getBaseToken().props('suggestions')).toEqual(mockUsers);
});
});
// TODO: rm when completed https://gitlab.com/gitlab-org/gitlab/-/issues/345756
describe('when there are null users presents', () => {
- const mockAuthorsWithNullUser = mockAuthors.concat([null]);
+ const mockUsersWithNullUser = mockUsers.concat([null]);
beforeEach(() => {
jest
- .spyOn(wrapper.vm.config, 'fetchAuthors')
- .mockResolvedValue({ data: mockAuthorsWithNullUser });
+ .spyOn(wrapper.vm.config, 'fetchUsers')
+ .mockResolvedValue({ data: mockUsersWithNullUser });
getBaseToken().vm.$emit('fetch-suggestions', 'root');
});
@@ -126,7 +126,7 @@ describe('AuthorToken', () => {
describe('when res.data is present', () => {
it('filters the successful response when null values are present', () => {
return waitForPromises().then(() => {
- expect(getBaseToken().props('suggestions')).toEqual(mockAuthors);
+ expect(getBaseToken().props('suggestions')).toEqual(mockUsers);
});
});
});
@@ -134,14 +134,14 @@ describe('AuthorToken', () => {
describe('when response is an array', () => {
it('filters the successful response when null values are present', () => {
return waitForPromises().then(() => {
- expect(getBaseToken().props('suggestions')).toEqual(mockAuthors);
+ expect(getBaseToken().props('suggestions')).toEqual(mockUsers);
});
});
});
});
it('calls `createAlert` with flash error message when request fails', () => {
- jest.spyOn(wrapper.vm.config, 'fetchAuthors').mockRejectedValue({});
+ jest.spyOn(wrapper.vm.config, 'fetchUsers').mockRejectedValue({});
getBaseToken().vm.$emit('fetch-suggestions', 'root');
@@ -153,7 +153,7 @@ describe('AuthorToken', () => {
});
it('sets `loading` to false when request completes', async () => {
- jest.spyOn(wrapper.vm.config, 'fetchAuthors').mockRejectedValue({});
+ jest.spyOn(wrapper.vm.config, 'fetchUsers').mockRejectedValue({});
getBaseToken().vm.$emit('fetch-suggestions', 'root');
@@ -174,23 +174,23 @@ describe('AuthorToken', () => {
it('renders base-token component', () => {
wrapper = createComponent({
- value: { data: mockAuthors[0].username },
- data: { authors: mockAuthors },
+ value: { data: mockUsers[0].username },
+ data: { users: mockUsers },
});
const baseTokenEl = getBaseToken();
expect(baseTokenEl.exists()).toBe(true);
expect(baseTokenEl.props()).toMatchObject({
- suggestions: mockAuthors,
- getActiveTokenValue: wrapper.vm.getActiveAuthor,
+ suggestions: mockUsers,
+ getActiveTokenValue: wrapper.vm.getActiveUser,
});
});
it('renders token item when value is selected', async () => {
wrapper = createComponent({
- value: { data: mockAuthors[0].username },
- data: { authors: mockAuthors },
+ value: { data: mockUsers[0].username },
+ data: { users: mockUsers },
stubs: { Portal: true },
});
@@ -201,20 +201,20 @@ describe('AuthorToken', () => {
const tokenValue = tokenSegments.at(2);
- expect(tokenValue.findComponent(GlAvatar).props('src')).toBe(mockAuthors[0].avatar_url);
- expect(tokenValue.text()).toBe(mockAuthors[0].name); // "Administrator"
+ expect(tokenValue.findComponent(GlAvatar).props('src')).toBe(mockUsers[0].avatar_url);
+ expect(tokenValue.text()).toBe(mockUsers[0].name); // "Administrator"
});
- it('renders token value with correct avatarUrl from author object', async () => {
+ it('renders token value with correct avatarUrl from user object', async () => {
const getAvatarEl = () =>
wrapper.findAllComponents(GlFilteredSearchTokenSegment).at(2).findComponent(GlAvatar);
wrapper = createComponent({
- value: { data: mockAuthors[0].username },
+ value: { data: mockUsers[0].username },
data: {
- authors: [
+ users: [
{
- ...mockAuthors[0],
+ ...mockUsers[0],
},
],
},
@@ -223,15 +223,15 @@ describe('AuthorToken', () => {
await nextTick();
- expect(getAvatarEl().props('src')).toBe(mockAuthors[0].avatar_url);
+ expect(getAvatarEl().props('src')).toBe(mockUsers[0].avatar_url);
// setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
// eslint-disable-next-line no-restricted-syntax
wrapper.setData({
- authors: [
+ users: [
{
- ...mockAuthors[0],
- avatarUrl: mockAuthors[0].avatar_url,
+ ...mockUsers[0],
+ avatarUrl: mockUsers[0].avatar_url,
avatar_url: undefined,
},
],
@@ -239,14 +239,14 @@ describe('AuthorToken', () => {
await nextTick();
- expect(getAvatarEl().props('src')).toBe(mockAuthors[0].avatar_url);
+ expect(getAvatarEl().props('src')).toBe(mockUsers[0].avatar_url);
});
- it('renders provided defaultAuthors as suggestions', async () => {
- const defaultAuthors = DEFAULT_NONE_ANY;
+ it('renders provided defaultUsers as suggestions', async () => {
+ const defaultUsers = OPTIONS_NONE_ANY;
wrapper = createComponent({
active: true,
- config: { ...mockAuthorToken, defaultAuthors, preloadedAuthors: mockPreloadedAuthors },
+ config: { ...mockAuthorToken, defaultUsers, preloadedUsers: mockPreloadedUsers },
stubs: { Portal: true },
});
@@ -254,16 +254,16 @@ describe('AuthorToken', () => {
const suggestions = wrapper.findAllComponents(GlFilteredSearchSuggestion);
- expect(suggestions).toHaveLength(defaultAuthors.length + currentUserLength);
- defaultAuthors.forEach((label, index) => {
+ expect(suggestions).toHaveLength(defaultUsers.length + currentUserLength);
+ defaultUsers.forEach((label, index) => {
expect(suggestions.at(index).text()).toBe(label.text);
});
});
- it('does not render divider when no defaultAuthors', async () => {
+ it('does not render divider when no defaultUsers', async () => {
wrapper = createComponent({
active: true,
- config: { ...mockAuthorToken, defaultAuthors: [] },
+ config: { ...mockAuthorToken, defaultUsers: [] },
stubs: { Portal: true },
});
const tokenSegments = wrapper.findAllComponents(GlFilteredSearchTokenSegment);
@@ -274,10 +274,10 @@ describe('AuthorToken', () => {
expect(wrapper.findComponent(GlDropdownDivider).exists()).toBe(false);
});
- it('renders `DEFAULT_NONE_ANY` as default suggestions', async () => {
+ it('renders `OPTIONS_NONE_ANY` as default suggestions', async () => {
wrapper = createComponent({
active: true,
- config: { ...mockAuthorToken, preloadedAuthors: mockPreloadedAuthors },
+ config: { ...mockAuthorToken, preloadedUsers: mockPreloadedUsers },
stubs: { Portal: true },
});
@@ -286,8 +286,8 @@ describe('AuthorToken', () => {
const suggestions = wrapper.findAllComponents(GlFilteredSearchSuggestion);
expect(suggestions).toHaveLength(2 + currentUserLength);
- expect(suggestions.at(0).text()).toBe(DEFAULT_NONE_ANY[0].text);
- expect(suggestions.at(1).text()).toBe(DEFAULT_NONE_ANY[1].text);
+ expect(suggestions.at(0).text()).toBe(OPTIONS_NONE_ANY[0].text);
+ expect(suggestions.at(1).text()).toBe(OPTIONS_NONE_ANY[1].text);
});
it('emits listeners in the base-token', () => {
@@ -308,8 +308,8 @@ describe('AuthorToken', () => {
active: true,
config: {
...mockAuthorToken,
- preloadedAuthors: mockPreloadedAuthors,
- defaultAuthors: [],
+ preloadedUsers: mockPreloadedUsers,
+ defaultUsers: [],
},
stubs: { Portal: true },
});