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
Show 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 {
...
@@ -105,7 +105,7 @@ export default {
<section
class=
"header-main-content"
>
<section
class=
"header-main-content"
>
<ci-icon-badge
:status=
"status"
/>
<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-if=
"shouldRenderTriggeredLabel"
>
{{
__
(
'
triggered
'
)
}}
</
template
>
<
template
v-else
>
{{
__
(
'
created
'
)
}}
</
template
>
<
template
v-else
>
{{
__
(
'
created
'
)
}}
</
template
>
...
@@ -142,7 +142,7 @@ export default {
...
@@ -142,7 +142,7 @@ export default {
</
template
>
</
template
>
</section>
</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>
<slot></slot>
</section>
</section>
<gl-button
<gl-button
...
...
spec/frontend/vue_shared/components/header_ci_component_spec.js
View file @
9d8aec12
import
Vue
from
'
vue
'
;
import
{
GlButton
,
GlLink
}
from
'
@gitlab/ui
'
;
import
mountComponent
,
{
mountComponentWithSlots
}
from
'
helpers/vue_mount_component_helper
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
headerCi
from
'
~/vue_shared/components/header_ci_component.vue
'
;
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
'
,
()
=>
{
describe
(
'
Header CI Component
'
,
()
=>
{
let
HeaderCi
;
let
wrapper
;
let
vm
;
let
props
;
beforeEach
(()
=>
{
const
defaultProps
=
{
HeaderCi
=
Vue
.
extend
(
headerCi
);
props
=
{
status
:
{
status
:
{
group
:
'
failed
'
,
group
:
'
failed
'
,
icon
:
'
status_failed
'
,
icon
:
'
status_failed
'
,
...
@@ -29,65 +28,76 @@ describe('Header CI Component', () => {
...
@@ -29,65 +28,76 @@ describe('Header CI Component', () => {
},
},
hasSidebarButton
:
true
,
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
(()
=>
{
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
const
findActionButtons
=
()
=>
vm
.
$el
.
querySelector
(
'
[data-testid="headerButtons"]
'
);
describe
(
'
render
'
,
()
=>
{
describe
(
'
render
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
HeaderCi
,
props
);
createComponent
(
);
});
});
it
(
'
should render status badge
'
,
()
=>
{
it
(
'
should render status badge
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.ci-failed
'
)).
toBeDefined
();
expect
(
findIconBadge
().
exists
()).
toBe
(
true
);
expect
(
vm
.
$el
.
querySelector
(
'
.ci-status-icon-failed svg
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.ci-failed
'
).
getAttribute
(
'
href
'
)).
toEqual
(
props
.
status
.
details_path
,
);
});
});
it
(
'
should render item name and id
'
,
()
=>
{
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
'
,
()
=>
{
it
(
'
should render timeago date
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
time
'
)).
toBeDefined
(
);
expect
(
findTimeAgo
().
exists
()).
toBe
(
true
);
});
});
it
(
'
should render user icon and name
'
,
()
=>
{
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
'
,
()
=>
{
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
'
,
()
=>
{
it
(
'
should not render header action buttons when
slot is
empty
'
,
()
=>
{
expect
(
findActionButtons
()
).
toBeNull
(
);
expect
(
findActionButtons
()
.
exists
()).
toBe
(
false
);
});
});
});
});
describe
(
'
slot
'
,
()
=>
{
describe
(
'
slot
'
,
()
=>
{
it
(
'
should render header action buttons
'
,
()
=>
{
it
(
'
should render header action buttons
'
,
()
=>
{
vm
=
mountComponentWithSlots
(
HeaderCi
,
{
props
,
slots
:
{
default
:
'
Test Actions
'
}
});
createComponent
({},
{
slots
:
{
default
:
'
Test Actions
'
}
});
const
buttons
=
findActionButtons
();
expect
(
buttons
).
not
.
toBeNull
(
);
expect
(
findActionButtons
().
exists
()).
toBe
(
true
);
expect
(
buttons
.
textContent
).
toEqual
(
'
Test Actions
'
);
expect
(
findActionButtons
().
text
()).
toBe
(
'
Test Actions
'
);
});
});
});
});
describe
(
'
shouldRenderTriggeredLabel
'
,
()
=>
{
describe
(
'
shouldRenderTriggeredLabel
'
,
()
=>
{
it
(
'
should render
ed
created keyword when the shouldRenderTriggeredLabel is false
'
,
()
=>
{
it
(
'
should render created keyword when the shouldRenderTriggeredLabel is false
'
,
()
=>
{
vm
=
mountComponent
(
HeaderCi
,
{
...
props
,
shouldRenderTriggeredLabel
:
false
});
createComponent
({
shouldRenderTriggeredLabel
:
false
});
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
created
'
);
expect
(
wrapper
.
text
()
).
toContain
(
'
created
'
);
expect
(
vm
.
$el
.
textContent
).
not
.
toContain
(
'
triggered
'
);
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