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
939beeb6
Commit
939beeb6
authored
Mar 10, 2020
by
Justin Boyson
Committed by
Martin Wortschack
Mar 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add check for window focus before polling
parent
dccaf488
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue
...avascripts/vue_merge_request_widget/mr_widget_options.vue
+2
-0
spec/frontend/vue_mr_widget/mr_widget_options_spec.js
spec/frontend/vue_mr_widget/mr_widget_options_spec.js
+27
-3
No files found.
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue
View file @
939beeb6
...
@@ -212,6 +212,8 @@ export default {
...
@@ -212,6 +212,8 @@ export default {
return
new
MRWidgetService
(
this
.
getServiceEndpoints
(
store
));
return
new
MRWidgetService
(
this
.
getServiceEndpoints
(
store
));
},
},
checkStatus
(
cb
,
isRebased
)
{
checkStatus
(
cb
,
isRebased
)
{
if
(
document
.
visibilityState
!==
'
visible
'
)
return
Promise
.
resolve
();
return
this
.
service
return
this
.
service
.
checkStatus
()
.
checkStatus
()
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
...
...
spec/frontend/vue_mr_widget/mr_widget_options_spec.js
View file @
939beeb6
...
@@ -259,16 +259,40 @@ describe('mrWidgetOptions', () => {
...
@@ -259,16 +259,40 @@ describe('mrWidgetOptions', () => {
describe
(
'
methods
'
,
()
=>
{
describe
(
'
methods
'
,
()
=>
{
describe
(
'
checkStatus
'
,
()
=>
{
describe
(
'
checkStatus
'
,
()
=>
{
it
(
'
should tell service to check status
'
,
()
=>
{
let
cb
;
let
isCbExecuted
;
beforeEach
(()
=>
{
jest
.
spyOn
(
vm
.
service
,
'
checkStatus
'
).
mockReturnValue
(
returnPromise
(
mockData
));
jest
.
spyOn
(
vm
.
service
,
'
checkStatus
'
).
mockReturnValue
(
returnPromise
(
mockData
));
jest
.
spyOn
(
vm
.
mr
,
'
setData
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
vm
.
mr
,
'
setData
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
vm
,
'
handleNotification
'
).
mockImplementation
(()
=>
{});
jest
.
spyOn
(
vm
,
'
handleNotification
'
).
mockImplementation
(()
=>
{});
let
isCbExecuted
=
false
;
isCbExecuted
=
false
;
c
onst
c
b
=
()
=>
{
cb
=
()
=>
{
isCbExecuted
=
true
;
isCbExecuted
=
true
;
};
};
});
it
(
'
should not tell service to check status if document is not visible
'
,
()
=>
{
Object
.
defineProperty
(
document
,
'
visibilityState
'
,
{
value
:
'
hidden
'
,
configurable
:
true
,
});
vm
.
checkStatus
(
cb
);
return
vm
.
$nextTick
().
then
(()
=>
{
expect
(
vm
.
service
.
checkStatus
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
mr
.
setData
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
handleNotification
).
not
.
toHaveBeenCalled
();
expect
(
isCbExecuted
).
toBeFalsy
();
Object
.
defineProperty
(
document
,
'
visibilityState
'
,
{
value
:
'
visible
'
,
configurable
:
true
,
});
});
});
it
(
'
should tell service to check status if document is visible
'
,
()
=>
{
vm
.
checkStatus
(
cb
);
vm
.
checkStatus
(
cb
);
return
vm
.
$nextTick
().
then
(()
=>
{
return
vm
.
$nextTick
().
then
(()
=>
{
...
...
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