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
06b2e76d
Commit
06b2e76d
authored
Feb 04, 2021
by
pburdette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor sidebar detail row
Refactor the component and the related spec.
parent
60b1bcdc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
46 deletions
+41
-46
app/assets/javascripts/jobs/components/sidebar_detail_row.vue
...assets/javascripts/jobs/components/sidebar_detail_row.vue
+8
-7
spec/frontend/jobs/components/sidebar_detail_row_spec.js
spec/frontend/jobs/components/sidebar_detail_row_spec.js
+33
-39
No files found.
app/assets/javascripts/jobs/components/sidebar_detail_row.vue
View file @
06b2e76d
...
...
@@ -34,12 +34,13 @@ export default {
};
</
script
>
<
template
>
<p
class=
"build-detail-row"
>
<span
v-if=
"hasTitle"
class=
"font-weight-bold"
>
{{
title
}}
:
</span>
{{
value
}}
<span
v-if=
"hasHelpURL"
class=
"help-button float-right"
>
<gl-link
:href=
"helpUrl"
target=
"_blank"
rel=
"noopener noreferrer nofollow"
>
<p
class=
"gl-display-flex gl-justify-content-space-between gl-mb-2"
>
<span
v-if=
"hasTitle"
><b>
{{
title
}}
</b
>
:
{{
value
}}
</span
>
<gl-link
v-if=
"hasHelpURL"
:href=
"helpUrl"
target=
"_blank"
rel=
"noopener noreferrer nofollow"
>
<gl-icon
name=
"question-o"
/>
</gl-link>
</span>
</p>
</
template
>
spec/frontend/jobs/components/sidebar_detail_row_spec.js
View file @
06b2e76d
import
Vue
from
'
vue
'
;
import
sidebarDetailRow
from
'
~/jobs/components/sidebar_detail_row.vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlLink
}
from
'
@gitlab/ui
'
;
import
SidebarDetailRow
from
'
~/jobs/components/sidebar_detail_row.vue
'
;
describe
(
'
Sidebar detail row
'
,
()
=>
{
let
SidebarDetailRow
;
let
vm
;
let
wrapper
;
beforeEach
(()
=>
{
SidebarDetailRow
=
Vue
.
extend
(
sidebarDetailRow
)
;
})
;
const
title
=
'
this is the title
'
;
const
value
=
'
this is the value
'
;
const
helpUrl
=
'
/help/ci/runners/README.html
'
;
afterEach
(()
=>
{
vm
.
$destroy
();
});
const
findHelpLink
=
()
=>
wrapper
.
find
(
GlLink
);
it
(
'
should render no title
'
,
(
)
=>
{
vm
=
new
SidebarDetailRow
(
{
const
createComponent
=
(
props
)
=>
{
wrapper
=
shallowMount
(
SidebarDetailRow
,
{
propsData
:
{
value
:
'
this is the value
'
,
...
props
,
},
}).
$mount
();
});
};
expect
(
vm
.
$el
.
textContent
.
replace
(
/
\s
+/g
,
'
'
).
trim
()).
toEqual
(
'
this is the value
'
);
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
describe
(
'
with title/value and without helpUrl
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
new
SidebarDetailRow
({
propsData
:
{
title
:
'
this is the title
'
,
value
:
'
this is the value
'
,
},
}).
$mount
();
createComponent
({
title
,
value
});
});
it
(
'
should render provided title and value
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
.
replace
(
/
\s
+/g
,
'
'
).
trim
()).
toEqual
(
'
this is the title: this is the value
'
,
);
it
(
'
should render the provided title and value
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toBe
(
`
${
title
}
:
${
value
}
`
);
});
describe
(
'
when helpUrl not provided
'
,
()
=>
{
it
(
'
should not render help
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.help-button
'
)).
toBeNull
();
it
(
'
should not render the help link
'
,
()
=>
{
expect
(
findHelpLink
().
exists
()).
toBe
(
false
);
});
});
describe
(
'
when helpUrl provided
'
,
()
=>
{
beforeEach
(()
=>
{
vm
=
new
SidebarDetailRow
({
propsData
:
{
helpUrl
:
'
help url
'
,
value
:
'
foo
'
,
},
}).
$mount
();
createComponent
({
helpUrl
,
title
,
value
,
});
});
it
(
'
should render help
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.help-button a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
'
help url
'
);
it
(
'
should render the help link
'
,
()
=>
{
expect
(
findHelpLink
().
exists
()).
toBe
(
true
);
expect
(
findHelpLink
().
attributes
(
'
href
'
)).
toBe
(
helpUrl
);
});
});
});
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