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
79e488af
Commit
79e488af
authored
Mar 05, 2021
by
Payton Burdette
Committed by
David O'Regan
Mar 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor jobs container spec
Refactor the spec to use Vue test utils.
parent
111fdf24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
28 deletions
+44
-28
app/assets/javascripts/jobs/components/job_container_item.vue
...assets/javascripts/jobs/components/job_container_item.vue
+1
-1
spec/frontend/jobs/components/jobs_container_spec.js
spec/frontend/jobs/components/jobs_container_spec.js
+43
-27
No files found.
app/assets/javascripts/jobs/components/job_container_item.vue
View file @
79e488af
...
@@ -63,7 +63,7 @@ export default {
...
@@ -63,7 +63,7 @@ export default {
<span
class=
"text-truncate w-100"
>
{{
job
.
name
?
job
.
name
:
job
.
id
}}
</span>
<span
class=
"text-truncate w-100"
>
{{
job
.
name
?
job
.
name
:
job
.
id
}}
</span>
<gl-icon
v-if=
"job.retried"
name=
"retry"
class=
"js-retry-icon"
/>
<gl-icon
v-if=
"job.retried"
name=
"retry"
/>
</gl-link>
</gl-link>
</div>
</div>
</
template
>
</
template
>
spec/frontend/jobs/components/jobs_container_spec.js
View file @
79e488af
import
Vue
from
'
vue
'
;
import
{
GlLink
}
from
'
@gitlab/ui
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
component
from
'
~/jobs/components/jobs_container.vue
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
JobsContainer
from
'
~/jobs/components/jobs_container.vue
'
;
describe
(
'
Jobs List block
'
,
()
=>
{
describe
(
'
Jobs List block
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
component
);
let
wrapper
;
let
vm
;
const
retried
=
{
const
retried
=
{
status
:
{
status
:
{
...
@@ -52,80 +52,96 @@ describe('Jobs List block', () => {
...
@@ -52,80 +52,96 @@ describe('Jobs List block', () => {
tooltip
:
'
build - passed
'
,
tooltip
:
'
build - passed
'
,
};
};
const
findAllJobs
=
()
=>
wrapper
.
findAllComponents
(
GlLink
);
const
findJob
=
()
=>
findAllJobs
().
at
(
0
);
const
findArrowIcon
=
()
=>
wrapper
.
findByTestId
(
'
arrow-right-icon
'
);
const
findRetryIcon
=
()
=>
wrapper
.
findByTestId
(
'
retry-icon
'
);
const
createComponent
=
(
props
)
=>
{
wrapper
=
extendedWrapper
(
mount
(
JobsContainer
,
{
propsData
:
{
...
props
,
},
}),
);
};
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
renders list of jobs
'
,
()
=>
{
it
(
'
renders
a
list of jobs
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
(
{
jobs
:
[
job
,
retried
,
active
],
jobs
:
[
job
,
retried
,
active
],
jobId
:
12313
,
jobId
:
12313
,
});
});
expect
(
vm
.
$el
.
querySelectorAll
(
'
a
'
).
length
).
toEqual
(
3
);
expect
(
findAllJobs
()).
toHaveLength
(
3
);
});
});
it
(
'
renders
arrow right
when job id matches `jobId`
'
,
()
=>
{
it
(
'
renders
the arrow right icon
when job id matches `jobId`
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
(
{
jobs
:
[
active
],
jobs
:
[
active
],
jobId
:
active
.
id
,
jobId
:
active
.
id
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
a .js-arrow-right
'
)).
not
.
toBeNull
(
);
expect
(
findArrowIcon
().
exists
()).
toBe
(
true
);
});
});
it
(
'
does not render
arrow right when
job is not active
'
,
()
=>
{
it
(
'
does not render
the arrow right icon when the
job is not active
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
(
{
jobs
:
[
job
],
jobs
:
[
job
],
jobId
:
active
.
id
,
jobId
:
active
.
id
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
a .js-arrow-right
'
)).
toBeNull
(
);
expect
(
findArrowIcon
().
exists
()).
toBe
(
false
);
});
});
it
(
'
renders job name when present
'
,
()
=>
{
it
(
'
renders
the
job name when present
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
(
{
jobs
:
[
job
],
jobs
:
[
job
],
jobId
:
active
.
id
,
jobId
:
active
.
id
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
textContent
.
trim
()).
toContain
(
job
.
name
);
expect
(
findJob
().
text
()).
toBe
(
job
.
name
);
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
textContent
.
trim
()).
not
.
toContain
(
job
.
id
);
expect
(
findJob
().
text
()).
not
.
toContain
(
job
.
id
);
});
});
it
(
'
renders job id when job name is not available
'
,
()
=>
{
it
(
'
renders job id when job name is not available
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
(
{
jobs
:
[
retried
],
jobs
:
[
retried
],
jobId
:
active
.
id
,
jobId
:
active
.
id
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
textContent
.
trim
()).
toContain
(
retried
.
id
);
expect
(
findJob
().
text
()).
toBe
(
retried
.
id
.
toString
()
);
});
});
it
(
'
links to the job page
'
,
()
=>
{
it
(
'
links to the job page
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
(
{
jobs
:
[
job
],
jobs
:
[
job
],
jobId
:
active
.
id
,
jobId
:
active
.
id
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
job
.
status
.
details_path
);
expect
(
findJob
().
attributes
(
'
href
'
)).
toBe
(
job
.
status
.
details_path
);
});
});
it
(
'
renders retry icon when job was retried
'
,
()
=>
{
it
(
'
renders retry icon when job was retried
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
(
{
jobs
:
[
retried
],
jobs
:
[
retried
],
jobId
:
active
.
id
,
jobId
:
active
.
id
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
.js-retry-icon
'
)).
not
.
toBeNull
(
);
expect
(
findRetryIcon
().
exists
()).
toBe
(
true
);
});
});
it
(
'
does not render retry icon when job was not retried
'
,
()
=>
{
it
(
'
does not render retry icon when job was not retried
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
(
{
jobs
:
[
job
],
jobs
:
[
job
],
jobId
:
active
.
id
,
jobId
:
active
.
id
,
});
});
expect
(
vm
.
$el
.
querySelector
(
'
.js-retry-icon
'
)).
toBeNull
(
);
expect
(
findRetryIcon
().
exists
()).
toBe
(
false
);
});
});
});
});
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