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 {
...
@@ -43,10 +43,9 @@ export default {
<gl-button
<gl-button
v-if=
"showDisabledButton"
v-if=
"showDisabledButton"
type=
"button"
category=
"primary"
category=
"primary"
variant=
"success"
variant=
"success"
class=
"js-
disabled-merge-button"
data-testid=
"
disabled-merge-button"
:disabled=
"true"
:disabled=
"true"
>
>
{{
s__
(
'
mrWidget|Merge
'
)
}}
{{
s__
(
'
mrWidget|Merge
'
)
}}
...
...
spec/frontend/vue_mr_widget/components/mr_widget_status_icon_spec.js
View file @
71c115c8
import
Vue
from
'
vue
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
shallowMount
,
mount
}
from
'
@vue/test-utils
'
;
import
mrStatusIcon
from
'
~/vue_merge_request_widget/components/mr_widget_status_icon.vue
'
;
import
mrStatusIcon
from
'
~/vue_merge_request_widget/components/mr_widget_status_icon.vue
'
;
describe
(
'
MR widget status icon component
'
,
()
=>
{
describe
(
'
MR widget status icon component
'
,
()
=>
{
let
vm
;
let
wrapper
;
let
Component
;
beforeEach
(()
=>
{
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
Component
=
Vue
.
extend
(
mrStatusIcon
);
const
findDisabledMergeButton
=
()
=>
wrapper
.
find
(
'
[data-testid="disabled-merge-button"]
'
);
});
const
createWrapper
=
(
props
,
mountFn
=
shallowMount
)
=>
{
wrapper
=
mountFn
(
mrStatusIcon
,
{
propsData
:
{
...
props
,
},
});
};
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$
destroy
();
wrapper
.
destroy
();
});
});
describe
(
'
while loading
'
,
()
=>
{
describe
(
'
while loading
'
,
()
=>
{
it
(
'
renders loading icon
'
,
()
=>
{
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
'
,
()
=>
{
describe
(
'
with status icon
'
,
()
=>
{
it
(
'
renders ci status icon
'
,
()
=>
{
it
(
'
renders success status icon
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
'
failed
'
});
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
'
,
()
=>
{
describe
(
'
with disabled button
'
,
()
=>
{
it
(
'
renders a 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
'
,
()
=>
{
describe
(
'
without disabled button
'
,
()
=>
{
it
(
'
does not render a 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', () => {
...
@@ -113,9 +113,9 @@ describe('MRWidgetFailedToMerge', () => {
describe
(
'
while it is not regresing
'
,
()
=>
{
describe
(
'
while it is not regresing
'
,
()
=>
{
it
(
'
renders warning icon and disabled merge button
'
,
()
=>
{
it
(
'
renders warning icon and disabled merge button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-ci-status-icon-warning
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-ci-status-icon-warning
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-disabled-merge-button
'
).
getAttribute
(
'
disabled
'
)).
toEqual
(
expect
(
'
disabled
'
,
vm
.
$el
.
querySelector
(
'
[data-testid="disabled-merge-button"]
'
).
getAttribute
(
'
disabled
'
)
,
);
)
.
toEqual
(
'
disabled
'
)
;
});
});
it
(
'
renders given error
'
,
()
=>
{
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