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
9d8aec12
Commit
9d8aec12
authored
Feb 16, 2021
by
Payton Burdette
Committed by
Tim Zallmann
Feb 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port header ci spec
Move the header ci spec to vue test utils.
parent
7c9add3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
56 deletions
+66
-56
app/assets/javascripts/vue_shared/components/header_ci_component.vue
...javascripts/vue_shared/components/header_ci_component.vue
+2
-2
spec/frontend/vue_shared/components/header_ci_component_spec.js
...rontend/vue_shared/components/header_ci_component_spec.js
+64
-54
No files found.
app/assets/javascripts/vue_shared/components/header_ci_component.vue
View file @
9d8aec12
...
...
@@ -105,7 +105,7 @@ export default {
<section
class=
"header-main-content"
>
<ci-icon-badge
:status=
"status"
/>
<strong>
{{
itemName
}}
#
{{
itemId
}}
</strong>
<strong
data-testid=
"ci-header-item-text"
>
{{
itemName
}}
#
{{
itemId
}}
</strong>
<template
v-if=
"shouldRenderTriggeredLabel"
>
{{
__
(
'
triggered
'
)
}}
</
template
>
<
template
v-else
>
{{
__
(
'
created
'
)
}}
</
template
>
...
...
@@ -142,7 +142,7 @@ export default {
</
template
>
</section>
<section
v-if=
"$slots.default"
data-testid=
"
headerB
uttons"
class=
"gl-display-flex"
>
<section
v-if=
"$slots.default"
data-testid=
"
ci-header-action-b
uttons"
class=
"gl-display-flex"
>
<slot></slot>
</section>
<gl-button
...
...
spec/frontend/vue_shared/components/header_ci_component_spec.js
View file @
9d8aec12
import
Vue
from
'
vue
'
;
import
mountComponent
,
{
mountComponentWithSlots
}
from
'
helpers/vue_mount_component_helper
'
;
import
headerCi
from
'
~/vue_shared/components/header_ci_component.vue
'
;
import
{
GlButton
,
GlLink
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
CiIconBadge
from
'
~/vue_shared/components/ci_badge_link.vue
'
;
import
HeaderCi
from
'
~/vue_shared/components/header_ci_component.vue
'
;
import
TimeagoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
describe
(
'
Header CI Component
'
,
()
=>
{
let
HeaderCi
;
let
vm
;
let
props
;
beforeEach
(()
=>
{
HeaderCi
=
Vue
.
extend
(
headerCi
);
props
=
{
status
:
{
group
:
'
failed
'
,
icon
:
'
status_failed
'
,
label
:
'
failed
'
,
text
:
'
failed
'
,
details_path
:
'
path
'
,
},
itemName
:
'
job
'
,
itemId
:
123
,
time
:
'
2017-05-08T14:57:39.781Z
'
,
user
:
{
web_url
:
'
path
'
,
name
:
'
Foo
'
,
username
:
'
foobar
'
,
email
:
'
foo@bar.com
'
,
avatar_url
:
'
link
'
,
},
hasSidebarButton
:
true
,
};
});
let
wrapper
;
const
defaultProps
=
{
status
:
{
group
:
'
failed
'
,
icon
:
'
status_failed
'
,
label
:
'
failed
'
,
text
:
'
failed
'
,
details_path
:
'
path
'
,
},
itemName
:
'
job
'
,
itemId
:
123
,
time
:
'
2017-05-08T14:57:39.781Z
'
,
user
:
{
web_url
:
'
path
'
,
name
:
'
Foo
'
,
username
:
'
foobar
'
,
email
:
'
foo@bar.com
'
,
avatar_url
:
'
link
'
,
},
hasSidebarButton
:
true
,
};
const
findIconBadge
=
()
=>
wrapper
.
findComponent
(
CiIconBadge
);
const
findTimeAgo
=
()
=>
wrapper
.
findComponent
(
TimeagoTooltip
);
const
findUserLink
=
()
=>
wrapper
.
findComponent
(
GlLink
);
const
findSidebarToggleBtn
=
()
=>
wrapper
.
findComponent
(
GlButton
);
const
findActionButtons
=
()
=>
wrapper
.
findByTestId
(
'
ci-header-action-buttons
'
);
const
findHeaderItemText
=
()
=>
wrapper
.
findByTestId
(
'
ci-header-item-text
'
);
const
createComponent
=
(
props
,
slots
)
=>
{
wrapper
=
extendedWrapper
(
shallowMount
(
HeaderCi
,
{
propsData
:
{
...
defaultProps
,
...
props
,
},
...
slots
,
}),
);
};
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
const
findActionButtons
=
()
=>
vm
.
$el
.
querySelector
(
'
[data-testid="headerButtons"]
'
);
describe
(
'
render
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
HeaderCi
,
props
);
createComponent
(
);
});
it
(
'
should render status badge
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.ci-failed
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.ci-status-icon-failed svg
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.ci-failed
'
).
getAttribute
(
'
href
'
)).
toEqual
(
props
.
status
.
details_path
,
);
expect
(
findIconBadge
().
exists
()).
toBe
(
true
);
});
it
(
'
should render item name and id
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
strong
'
).
textContent
.
trim
()).
toEqual
(
'
job #123
'
);
expect
(
findHeaderItemText
().
text
()).
toBe
(
'
job #123
'
);
});
it
(
'
should render timeago date
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
time
'
)).
toBeDefined
(
);
expect
(
findTimeAgo
().
exists
()).
toBe
(
true
);
});
it
(
'
should render user icon and name
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-user-link
'
).
innerText
.
trim
()).
toContain
(
p
rops
.
user
.
name
);
expect
(
findUserLink
().
text
()).
toContain
(
defaultP
rops
.
user
.
name
);
});
it
(
'
should render sidebar toggle button
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-sidebar-build-toggle
'
)).
not
.
toBeNull
(
);
expect
(
findSidebarToggleBtn
().
exists
()).
toBe
(
true
);
});
it
(
'
should not render header action buttons when empty
'
,
()
=>
{
expect
(
findActionButtons
()
).
toBeNull
(
);
it
(
'
should not render header action buttons when
slot is
empty
'
,
()
=>
{
expect
(
findActionButtons
()
.
exists
()).
toBe
(
false
);
});
});
describe
(
'
slot
'
,
()
=>
{
it
(
'
should render header action buttons
'
,
()
=>
{
vm
=
mountComponentWithSlots
(
HeaderCi
,
{
props
,
slots
:
{
default
:
'
Test Actions
'
}
});
const
buttons
=
findActionButtons
();
createComponent
({},
{
slots
:
{
default
:
'
Test Actions
'
}
});
expect
(
buttons
).
not
.
toBeNull
(
);
expect
(
buttons
.
textContent
).
toEqual
(
'
Test Actions
'
);
expect
(
findActionButtons
().
exists
()).
toBe
(
true
);
expect
(
findActionButtons
().
text
()).
toBe
(
'
Test Actions
'
);
});
});
describe
(
'
shouldRenderTriggeredLabel
'
,
()
=>
{
it
(
'
should render
ed
created keyword when the shouldRenderTriggeredLabel is false
'
,
()
=>
{
vm
=
mountComponent
(
HeaderCi
,
{
...
props
,
shouldRenderTriggeredLabel
:
false
});
it
(
'
should render created keyword when the shouldRenderTriggeredLabel is false
'
,
()
=>
{
createComponent
({
shouldRenderTriggeredLabel
:
false
});
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
created
'
);
expect
(
vm
.
$el
.
textContent
).
not
.
toContain
(
'
triggered
'
);
expect
(
wrapper
.
text
()
).
toContain
(
'
created
'
);
expect
(
wrapper
.
text
()
).
not
.
toContain
(
'
triggered
'
);
});
});
});
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