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
fe2ef898
Commit
fe2ef898
authored
Mar 30, 2020
by
Coung Ngo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Health Status code
Make changes as a result of reviewer comments
parent
7d9a2a7f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
31 deletions
+79
-31
ee/app/assets/javascripts/sidebar/components/status/sidebar_status.vue
.../javascripts/sidebar/components/status/sidebar_status.vue
+1
-1
ee/app/assets/javascripts/sidebar/components/status/status.vue
...p/assets/javascripts/sidebar/components/status/status.vue
+2
-2
ee/spec/frontend/sidebar/components/status/sidebar_status_spec.js
...frontend/sidebar/components/status/sidebar_status_spec.js
+72
-24
ee/spec/frontend/sidebar/components/status/status_spec.js
ee/spec/frontend/sidebar/components/status/status_spec.js
+4
-4
No files found.
ee/app/assets/javascripts/sidebar/components/status/sidebar_status.vue
View file @
fe2ef898
...
...
@@ -31,6 +31,6 @@ export default {
:is-editable=
"mediator.store.editable"
:is-fetching=
"mediator.store.isFetching.status"
:status=
"mediator.store.status"
@
on
FormSubmit
=
"handleFormSubmission"
@
on
StatusChange
=
"handleFormSubmission"
/>
</
template
>
ee/app/assets/javascripts/sidebar/components/status/status.vue
View file @
fe2ef898
...
...
@@ -73,7 +73,7 @@ export default {
},
methods
:
{
handleFormSubmission
()
{
this
.
$emit
(
'
on
FormSubmit
'
,
this
.
selectedStatus
);
this
.
$emit
(
'
on
StatusChange
'
,
this
.
selectedStatus
);
this
.
hideForm
();
},
hideForm
()
{
...
...
@@ -84,7 +84,7 @@ export default {
this
.
isFormShowing
=
!
this
.
isFormShowing
;
},
removeStatus
()
{
this
.
$emit
(
'
on
FormSubmit
'
,
null
);
this
.
$emit
(
'
on
StatusChange
'
,
null
);
},
},
};
...
...
ee/spec/frontend/sidebar/components/status/sidebar_status_spec.js
View file @
fe2ef898
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
mount
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
SidebarStatus
from
'
ee/sidebar/components/status/sidebar_status.vue
'
;
import
Status
from
'
ee/sidebar/components/status/status.vue
'
;
const
getStatusText
=
wrapper
=>
wrapper
.
find
(
'
.value
'
).
text
();
describe
(
'
SidebarStatus
'
,
()
=>
{
const
mediator
=
{
store
:
{
isFetching
:
{
status
:
true
,
},
status
:
''
,
},
};
const
handleFormSubmissionMock
=
jest
.
fn
();
const
wrapper
=
shallowMount
(
SidebarStatus
,
{
propsData
:
{
mediator
,
},
methods
:
{
handleFormSubmission
:
handleFormSubmissionMock
,
},
let
wrapper
;
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
it
(
'
renders Status component
'
,
()
=>
{
expect
(
wrapper
.
contains
(
Status
)).
toBe
(
true
);
describe
(
'
Status child component
'
,
()
=>
{
let
handleFormSubmissionMock
;
beforeEach
(()
=>
{
const
mediator
=
{
store
:
{
isFetching
:
{
status
:
true
,
},
status
:
''
,
},
};
handleFormSubmissionMock
=
jest
.
fn
();
wrapper
=
shallowMount
(
SidebarStatus
,
{
propsData
:
{
mediator
,
},
methods
:
{
handleFormSubmission
:
handleFormSubmissionMock
,
},
});
});
it
(
'
renders Status component
'
,
()
=>
{
expect
(
wrapper
.
contains
(
Status
)).
toBe
(
true
);
});
it
(
'
calls handleFormSubmission when receiving an onStatusChange event from Status component
'
,
()
=>
{
wrapper
.
find
(
Status
).
vm
.
$emit
(
'
onStatusChange
'
,
'
onTrack
'
);
expect
(
handleFormSubmissionMock
).
toHaveBeenCalledWith
(
'
onTrack
'
);
});
});
it
(
'
calls handleFormSubmission when receiving an onFormSubmit event from Status component
'
,
()
=>
{
wrapper
.
find
(
Status
).
vm
.
$emit
(
'
onFormSubmit
'
,
'
onTrack
'
);
it
(
'
removes status when user clicks on "remove status"
'
,
()
=>
{
const
mediator
=
{
store
:
{
editable
:
true
,
isFetching
:
{
status
:
false
,
},
status
:
'
onTrack
'
,
},
updateStatus
(
status
)
{
const
newMediator
=
{
...
this
};
newMediator
.
store
.
status
=
status
;
wrapper
.
setProps
({
mediator
:
newMediator
});
return
Promise
.
resolve
();
},
};
wrapper
=
mount
(
SidebarStatus
,
{
propsData
:
{
mediator
,
},
});
expect
(
getStatusText
(
wrapper
)).
toContain
(
'
On track
'
);
wrapper
.
find
(
'
button.btn-link
'
).
trigger
(
'
click
'
);
expect
(
handleFormSubmissionMock
).
toHaveBeenCalledWith
(
'
onTrack
'
);
return
Vue
.
nextTick
().
then
(()
=>
{
expect
(
getStatusText
(
wrapper
)).
toContain
(
'
None
'
);
});
});
});
ee/spec/frontend/sidebar/components/status/status_spec.js
View file @
fe2ef898
...
...
@@ -112,7 +112,7 @@ describe('Status', () => {
expect
(
getRemoveStatusButton
(
wrapper
).
exists
()).
toBe
(
true
);
});
it
(
'
emits an on
FormSubmit
event with argument null when clicked
'
,
()
=>
{
it
(
'
emits an on
StatusChange
event with argument null when clicked
'
,
()
=>
{
const
props
=
{
isEditable
:
true
,
status
:
healthStatus
.
AT_RISK
,
...
...
@@ -122,7 +122,7 @@ describe('Status', () => {
getRemoveStatusButton
(
wrapper
).
trigger
(
'
click
'
);
expect
(
wrapper
.
emitted
().
on
FormSubmit
[
0
]).
toEqual
([
null
]);
expect
(
wrapper
.
emitted
().
on
StatusChange
[
0
]).
toEqual
([
null
]);
});
});
...
...
@@ -267,7 +267,7 @@ describe('Status', () => {
// Test that "onTrack", "needsAttention", and "atRisk" values are emitted when form is submitted
it
.
each
(
Object
.
values
(
healthStatus
))(
'
emits on
FormSubmit
event with argument "%s" when user selects the option and submits form
'
,
'
emits on
StatusChange
event with argument "%s" when user selects the option and submits form
'
,
status
=>
{
getEditForm
(
wrapper
)
.
find
(
`input[value="
${
status
}
"]`
)
...
...
@@ -275,7 +275,7 @@ describe('Status', () => {
return
Vue
.
nextTick
().
then
(()
=>
{
getEditForm
(
wrapper
).
trigger
(
'
submit
'
);
expect
(
wrapper
.
emitted
().
on
FormSubmit
[
0
]).
toEqual
([
status
]);
expect
(
wrapper
.
emitted
().
on
StatusChange
[
0
]).
toEqual
([
status
]);
});
},
);
...
...
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