Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8e99ddca
Commit
8e99ddca
authored
Dec 13, 2021
by
Scott Stern
Committed by
Kushal Pandya
Dec 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add space logic to base token
parent
f92d82e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
5 deletions
+49
-5
app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/base_token.vue
...ared/components/filtered_search_bar/tokens/base_token.vue
+13
-2
ee/spec/frontend/vue_shared/components/filtered_search_bar/tokens/iteration_token_spec.js
...onents/filtered_search_bar/tokens/iteration_token_spec.js
+1
-1
spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
.../components/filtered_search_bar/tokens/base_token_spec.js
+34
-1
spec/frontend/vue_shared/components/filtered_search_bar/tokens/release_token_spec.js
...mponents/filtered_search_bar/tokens/release_token_spec.js
+1
-1
No files found.
app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/base_token.vue
View file @
8e99ddca
...
...
@@ -10,7 +10,11 @@ import {
import
{
debounce
}
from
'
lodash
'
;
import
{
DEBOUNCE_DELAY
,
FILTER_NONE_ANY
,
OPERATOR_IS_NOT
}
from
'
../constants
'
;
import
{
getRecentlyUsedSuggestions
,
setTokenValueToRecentlyUsed
}
from
'
../filtered_search_utils
'
;
import
{
getRecentlyUsedSuggestions
,
setTokenValueToRecentlyUsed
,
stripQuotes
,
}
from
'
../filtered_search_utils
'
;
export
default
{
components
:
{
...
...
@@ -163,7 +167,14 @@ export default {
this
.
searchKey
=
data
;
if
(
!
this
.
suggestionsLoading
&&
!
this
.
activeTokenValue
)
{
const
search
=
this
.
searchTerm
?
this
.
searchTerm
:
data
;
let
search
=
this
.
searchTerm
?
this
.
searchTerm
:
data
;
if
(
search
.
startsWith
(
'
"
'
)
&&
search
.
endsWith
(
'
"
'
))
{
search
=
stripQuotes
(
search
);
}
else
if
(
search
.
startsWith
(
'
"
'
))
{
search
=
search
.
slice
(
1
,
search
.
length
);
}
this
.
$emit
(
'
fetch-suggestions
'
,
search
);
}
},
DEBOUNCE_DELAY
),
...
...
ee/spec/frontend/vue_shared/components/filtered_search_bar/tokens/iteration_token_spec.js
View file @
8e99ddca
...
...
@@ -12,7 +12,7 @@ import { mockIterationToken, mockIterations } from '../mock_data';
jest
.
mock
(
'
~/flash
'
);
describe
(
'
IterationToken
'
,
()
=>
{
const
id
=
123
;
const
id
=
'
123
'
;
let
wrapper
;
const
createComponent
=
({
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/base_token_spec.js
View file @
8e99ddca
...
...
@@ -14,7 +14,13 @@ import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_t
import
{
mockLabelToken
}
from
'
../mock_data
'
;
jest
.
mock
(
'
~/vue_shared/components/filtered_search_bar/filtered_search_utils
'
);
jest
.
mock
(
'
~/vue_shared/components/filtered_search_bar/filtered_search_utils
'
,
()
=>
({
getRecentlyUsedSuggestions
:
jest
.
fn
(),
setTokenValueToRecentlyUsed
:
jest
.
fn
(),
stripQuotes
:
jest
.
requireActual
(
'
~/vue_shared/components/filtered_search_bar/filtered_search_utils
'
,
).
stripQuotes
,
}));
const
mockStorageKey
=
'
recent-tokens-label_name
'
;
...
...
@@ -231,6 +237,7 @@ describe('BaseToken', () => {
stubs
:
{
Portal
:
true
},
});
});
it
(
'
emits `fetch-suggestions` event on component after a delay when component emits `input` event
'
,
async
()
=>
{
jest
.
useFakeTimers
();
...
...
@@ -242,6 +249,32 @@ describe('BaseToken', () => {
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)).
toBeTruthy
();
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)[
2
]).
toEqual
([
'
foo
'
]);
});
describe
(
'
when search is started with a quote
'
,
()
=>
{
it
(
'
emits `fetch-suggestions` with filtered value
'
,
async
()
=>
{
jest
.
useFakeTimers
();
wrapperWithNoStubs
.
find
(
GlFilteredSearchToken
).
vm
.
$emit
(
'
input
'
,
{
data
:
'
"foo
'
});
await
wrapperWithNoStubs
.
vm
.
$nextTick
();
jest
.
runAllTimers
();
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)[
2
]).
toEqual
([
'
foo
'
]);
});
});
describe
(
'
when search starts and ends with a quote
'
,
()
=>
{
it
(
'
emits `fetch-suggestions` with filtered value
'
,
async
()
=>
{
jest
.
useFakeTimers
();
wrapperWithNoStubs
.
find
(
GlFilteredSearchToken
).
vm
.
$emit
(
'
input
'
,
{
data
:
'
"foo"
'
});
await
wrapperWithNoStubs
.
vm
.
$nextTick
();
jest
.
runAllTimers
();
expect
(
wrapperWithNoStubs
.
emitted
(
'
fetch-suggestions
'
)[
2
]).
toEqual
([
'
foo
'
]);
});
});
});
});
});
...
...
spec/frontend/vue_shared/components/filtered_search_bar/tokens/release_token_spec.js
View file @
8e99ddca
...
...
@@ -8,7 +8,7 @@ import { mockReleaseToken } from '../mock_data';
jest
.
mock
(
'
~/flash
'
);
describe
(
'
ReleaseToken
'
,
()
=>
{
const
id
=
123
;
const
id
=
'
123
'
;
let
wrapper
;
const
createComponent
=
({
config
=
mockReleaseToken
,
value
=
{
data
:
''
}
}
=
{})
=>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment