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
71c115c8
Commit
71c115c8
authored
Jan 25, 2021
by
Miguel Rincon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use vue test utils in MR Widget Status Icon spec
parent
a2973bc3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
22 deletions
+33
-22
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_status_icon.vue
...merge_request_widget/components/mr_widget_status_icon.vue
+1
-2
spec/frontend/vue_mr_widget/components/mr_widget_status_icon_spec.js
...nd/vue_mr_widget/components/mr_widget_status_icon_spec.js
+29
-17
spec/frontend/vue_mr_widget/components/states/mr_widget_failed_to_merge_spec.js
...idget/components/states/mr_widget_failed_to_merge_spec.js
+3
-3
No files found.
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_status_icon.vue
View file @
71c115c8
...
...
@@ -43,10 +43,9 @@ export default {
<gl-button
v-if=
"showDisabledButton"
type=
"button"
category=
"primary"
variant=
"success"
class=
"js-
disabled-merge-button"
data-testid=
"
disabled-merge-button"
:disabled=
"true"
>
{{
s__
(
'
mrWidget|Merge
'
)
}}
...
...
spec/frontend/vue_mr_widget/components/mr_widget_status_icon_spec.js
View file @
71c115c8
import
Vue
from
'
vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
mrStatusIcon
from
'
~/vue_merge_request_widget/components/mr_widget_status_icon.vue
'
;
describe
(
'
MR widget status icon component
'
,
()
=>
{
let
vm
;
let
Component
;
let
wrapper
;
beforeEach
(()
=>
{
Component
=
Vue
.
extend
(
mrStatusIcon
);
});
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findDisabledMergeButton
=
()
=>
wrapper
.
find
(
'
[data-testid="disabled-merge-button"]
'
);
const
createWrapper
=
(
props
,
mountFn
=
shallowMount
)
=>
{
wrapper
=
mountFn
(
mrStatusIcon
,
{
propsData
:
{
...
props
,
},
});
};
afterEach
(()
=>
{
vm
.
$
destroy
();
wrapper
.
destroy
();
});
describe
(
'
while loading
'
,
()
=>
{
it
(
'
renders loading icon
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
'
loading
'
});
createWrapper
(
{
status
:
'
loading
'
});
expect
(
vm
.
$el
.
querySelector
(
'
.mr-widget-icon span
'
).
classList
).
toContain
(
'
gl-spinner
'
);
expect
(
findLoadingIcon
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
with status icon
'
,
()
=>
{
it
(
'
renders ci status icon
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
'
failed
'
});
it
(
'
renders success status icon
'
,
()
=>
{
createWrapper
({
status
:
'
success
'
},
mount
);
expect
(
wrapper
.
find
(
'
[data-testid="status_success-icon"]
'
).
exists
()).
toBe
(
true
);
});
it
(
'
renders failed status icon
'
,
()
=>
{
createWrapper
({
status
:
'
failed
'
},
mount
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-ci-status-icon-failed
'
)).
not
.
toBeNull
(
);
expect
(
wrapper
.
find
(
'
[data-testid="status_failed-icon"]
'
).
exists
()).
toBe
(
true
);
});
});
describe
(
'
with disabled button
'
,
()
=>
{
it
(
'
renders a disabled button
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
'
failed
'
,
showDisabledButton
:
true
});
createWrapper
(
{
status
:
'
failed
'
,
showDisabledButton
:
true
});
expect
(
vm
.
$el
.
querySelector
(
'
.js-disabled-merge-button
'
).
textContent
.
trim
()).
toEqual
(
'
Merge
'
);
expect
(
findDisabledMergeButton
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
without disabled button
'
,
()
=>
{
it
(
'
does not render a disabled button
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
'
failed
'
});
createWrapper
(
{
status
:
'
failed
'
});
expect
(
vm
.
$el
.
querySelector
(
'
.js-disabled-merge-button
'
)).
toBeNull
(
);
expect
(
findDisabledMergeButton
().
exists
()).
toBe
(
false
);
});
});
});
spec/frontend/vue_mr_widget/components/states/mr_widget_failed_to_merge_spec.js
View file @
71c115c8
...
...
@@ -113,9 +113,9 @@ describe('MRWidgetFailedToMerge', () => {
describe
(
'
while it is not regresing
'
,
()
=>
{
it
(
'
renders warning icon and disabled merge button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-ci-status-icon-warning
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-disabled-merge-button
'
).
getAttribute
(
'
disabled
'
)).
toEqual
(
'
disabled
'
,
);
expect
(
vm
.
$el
.
querySelector
(
'
[data-testid="disabled-merge-button"]
'
).
getAttribute
(
'
disabled
'
)
,
)
.
toEqual
(
'
disabled
'
)
;
});
it
(
'
renders given error
'
,
()
=>
{
...
...
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