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
bee1489a
Commit
bee1489a
authored
Aug 18, 2020
by
Zack Cuddy
Committed by
Ezekiel Kigbo
Aug 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo Node Form - Use debounce prop
This replaces the lodash debounce implementation with the debounce prop.
parent
dfdfb82d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
29 deletions
+14
-29
ee/app/assets/javascripts/geo_node_form/components/geo_node_form_namespaces.vue
...pts/geo_node_form/components/geo_node_form_namespaces.vue
+3
-4
ee/spec/frontend/geo_node_form/components/geo_node_form_namespaces_spec.js
...geo_node_form/components/geo_node_form_namespaces_spec.js
+11
-25
No files found.
ee/app/assets/javascripts/geo_node_form/components/geo_node_form_namespaces.vue
View file @
bee1489a
<
script
>
<
script
>
import
{
GlIcon
,
GlSearchBoxByType
,
GlDeprecatedDropdown
,
GlDeprecatedButton
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlSearchBoxByType
,
GlDeprecatedDropdown
,
GlDeprecatedButton
}
from
'
@gitlab/ui
'
;
import
{
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
debounce
}
from
'
lodash
'
;
import
{
__
,
n__
}
from
'
~/locale
'
;
import
{
__
,
n__
}
from
'
~/locale
'
;
import
{
SELECTIVE_SYNC_NAMESPACES
}
from
'
../constants
'
;
import
{
SELECTIVE_SYNC_NAMESPACES
}
from
'
../constants
'
;
...
@@ -37,9 +36,9 @@ export default {
...
@@ -37,9 +36,9 @@ export default {
},
},
},
},
watch
:
{
watch
:
{
namespaceSearch
:
debounce
(
function
debounceSearch
()
{
namespaceSearch
()
{
this
.
fetchSyncNamespaces
(
this
.
namespaceSearch
);
this
.
fetchSyncNamespaces
(
this
.
namespaceSearch
);
},
500
),
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
fetchSyncNamespaces
'
]),
...
mapActions
([
'
fetchSyncNamespaces
'
]),
...
@@ -60,7 +59,7 @@ export default {
...
@@ -60,7 +59,7 @@ export default {
<
template
>
<
template
>
<gl-deprecated-dropdown
:text=
"dropdownTitle"
@
show=
"fetchSyncNamespaces(namespaceSearch)"
>
<gl-deprecated-dropdown
:text=
"dropdownTitle"
@
show=
"fetchSyncNamespaces(namespaceSearch)"
>
<gl-search-box-by-type
v-model=
"namespaceSearch"
class=
"m-2"
/>
<gl-search-box-by-type
v-model=
"namespaceSearch"
class=
"m-2"
:debounce=
"500"
/>
<li
v-for=
"namespace in synchronizationNamespaces"
:key=
"namespace.id"
>
<li
v-for=
"namespace in synchronizationNamespaces"
:key=
"namespace.id"
>
<gl-deprecated-button
class=
"d-flex align-items-center"
@
click=
"toggleNamespace(namespace)"
>
<gl-deprecated-button
class=
"d-flex align-items-center"
@
click=
"toggleNamespace(namespace)"
>
<gl-icon
:class=
"[
{ invisible: !isSelected(namespace) }]" name="mobile-issue-close" />
<gl-icon
:class=
"[
{ invisible: !isSelected(namespace) }]" name="mobile-issue-close" />
...
...
ee/spec/frontend/geo_node_form/components/geo_node_form_namespaces_spec.js
View file @
bee1489a
...
@@ -56,10 +56,16 @@ describe('GeoNodeFormNamespaces', () => {
...
@@ -56,10 +56,16 @@ describe('GeoNodeFormNamespaces', () => {
expect
(
findGlDropdown
().
exists
()).
toBe
(
true
);
expect
(
findGlDropdown
().
exists
()).
toBe
(
true
);
});
});
it
(
'
renders findGlDropdownSearch
'
,
()
=>
{
describe
(
'
findGlDropdownSearch
'
,
()
=>
{
it
(
'
renders always
'
,
()
=>
{
expect
(
findGlDropdownSearch
().
exists
()).
toBe
(
true
);
expect
(
findGlDropdownSearch
().
exists
()).
toBe
(
true
);
});
});
it
(
'
has debounce prop
'
,
()
=>
{
expect
(
findGlDropdownSearch
().
attributes
(
'
debounce
'
)).
toBe
(
'
500
'
);
});
});
describe
(
'
findDropdownItems
'
,
()
=>
{
describe
(
'
findDropdownItems
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
delete
actionSpies
.
isSelected
;
delete
actionSpies
.
isSelected
;
...
@@ -79,37 +85,17 @@ describe('GeoNodeFormNamespaces', () => {
...
@@ -79,37 +85,17 @@ describe('GeoNodeFormNamespaces', () => {
});
});
});
});
// TODO: These specs should fixed once we have a proper mock for debounce
describe
(
'
watchers
'
,
()
=>
{
// https://gitlab.com/gitlab-org/gitlab/-/issues/213925
// eslint-disable-next-line jest/no-disabled-tests
describe
.
skip
(
'
watchers
'
,
()
=>
{
describe
(
'
namespaceSearch
'
,
()
=>
{
describe
(
'
namespaceSearch
'
,
()
=>
{
const
namespaceSearch
=
'
test search
'
;
const
namespaceSearch
=
'
test search
'
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
();
createComponent
();
wrapper
.
setData
({
findGlDropdownSearch
().
vm
.
$emit
(
'
input
'
,
namespaceSearch
);
namespaceSearch
,
});
});
});
it
(
'
should wait 500ms before calling fetchSyncNamespaces
'
,
()
=>
{
expect
(
actionSpies
.
fetchSyncNamespaces
).
not
.
toHaveBeenCalledWith
(
namespaceSearch
);
jest
.
advanceTimersByTime
(
500
);
// Debounce
it
(
'
calls fetchSyncNamespaces when input event is fired from GlSearchBoxByType
'
,
()
=>
{
expect
(
actionSpies
.
fetchSyncNamespaces
).
toHaveBeenCalledWith
(
namespaceSearch
);
expect
(
actionSpies
.
fetchSyncNamespaces
).
toHaveBeenCalledWith
(
namespaceSearch
);
expect
(
actionSpies
.
fetchSyncNamespaces
).
toHaveBeenCalledTimes
(
1
);
});
it
(
'
should call fetchSyncNamespaces once with the latest search term
'
,
()
=>
{
expect
(
actionSpies
.
fetchSyncNamespaces
).
not
.
toHaveBeenCalledWith
(
namespaceSearch
);
wrapper
.
setData
({
namespaceSearch
:
'
test search2
'
,
});
jest
.
advanceTimersByTime
(
500
);
// Debounce
expect
(
actionSpies
.
fetchSyncNamespaces
).
toHaveBeenCalledWith
(
'
test search2
'
);
expect
(
actionSpies
.
fetchSyncNamespaces
).
toHaveBeenCalledTimes
(
1
);
});
});
});
});
});
});
...
...
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