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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
f73b2c8e
Commit
f73b2c8e
authored
Jun 02, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
component specs
parent
2d6022e0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
262 additions
and
8 deletions
+262
-8
app/assets/javascripts/ide/components/jobs/detail.vue
app/assets/javascripts/ide/components/jobs/detail.vue
+5
-8
spec/javascripts/ide/components/jobs/detail/description_spec.js
...avascripts/ide/components/jobs/detail/description_spec.js
+28
-0
spec/javascripts/ide/components/jobs/detail/scroll_button_spec.js
...ascripts/ide/components/jobs/detail/scroll_button_spec.js
+59
-0
spec/javascripts/ide/components/jobs/detail_spec.js
spec/javascripts/ide/components/jobs/detail_spec.js
+170
-0
No files found.
app/assets/javascripts/ide/components/jobs/detail.vue
View file @
f73b2c8e
...
...
@@ -33,9 +33,6 @@ export default {
isScrolledToTop
()
{
return
this
.
scrollPos
===
scrollPositions
.
top
;
},
jobId
()
{
return
`#
${
this
.
detailJob
.
id
}
`
;
},
},
mounted
()
{
this
.
getTrace
();
...
...
@@ -43,15 +40,15 @@ export default {
methods
:
{
...
mapActions
(
'
pipelines
'
,
[
'
fetchJobTrace
'
,
'
setDetailJob
'
]),
scrollDown
()
{
this
.
$refs
.
buildTrace
.
scrollTo
(
0
,
this
.
$refs
.
buildTrace
.
scrollHeight
);
if
(
this
.
$refs
.
buildTrace
)
this
.
$refs
.
buildTrace
.
scrollTo
(
0
,
this
.
$refs
.
buildTrace
.
scrollHeight
);
},
scrollUp
()
{
this
.
$refs
.
buildTrace
.
scrollTo
(
0
,
0
);
if
(
this
.
$refs
.
buildTrace
)
this
.
$refs
.
buildTrace
.
scrollTo
(
0
,
0
);
},
scrollBuildLog
:
_
.
throttle
(
function
buildLogScrollDebounce
()
{
const
scrollTop
=
this
.
$refs
.
buildTrace
.
scrollTop
;
const
offsetHeight
=
this
.
$refs
.
buildTrace
.
offsetHeight
;
const
scrollHeight
=
this
.
$refs
.
buildTrace
.
scrollHeight
;
const
{
scrollTop
}
=
this
.
$refs
.
buildTrace
;
const
{
offsetHeight
,
scrollHeight
}
=
this
.
$refs
.
buildTrace
;
if
(
scrollTop
+
offsetHeight
===
scrollHeight
)
{
this
.
scrollPos
=
scrollPositions
.
bottom
;
...
...
spec/javascripts/ide/components/jobs/detail/description_spec.js
0 → 100644
View file @
f73b2c8e
import
Vue
from
'
vue
'
;
import
Description
from
'
~/ide/components/jobs/detail/description.vue
'
;
import
mountComponent
from
'
../../../../helpers/vue_mount_component_helper
'
;
import
{
jobs
}
from
'
../../../mock_data
'
;
describe
(
'
IDE job description
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
Description
);
let
vm
;
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
job
:
jobs
[
0
],
});
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
it
(
'
renders job details
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
#1
'
);
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
test
'
);
});
it
(
'
renders CI icon
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.ci-status-icon .ic-status_passed_borderless
'
)).
not
.
toBe
(
null
);
});
});
spec/javascripts/ide/components/jobs/detail/scroll_button_spec.js
0 → 100644
View file @
f73b2c8e
import
Vue
from
'
vue
'
;
import
ScrollButton
from
'
~/ide/components/jobs/detail/scroll_button.vue
'
;
import
mountComponent
from
'
../../../../helpers/vue_mount_component_helper
'
;
describe
(
'
IDE job log scroll button
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
ScrollButton
);
let
vm
;
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
direction
:
'
up
'
,
disabled
:
false
,
});
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
iconName
'
,
()
=>
{
[
'
up
'
,
'
down
'
].
forEach
(
direction
=>
{
it
(
`returns icon name for
${
direction
}
`
,
()
=>
{
vm
.
direction
=
direction
;
expect
(
vm
.
iconName
).
toBe
(
`scroll_
${
direction
}
`
);
});
});
});
describe
(
'
tooltipTitle
'
,
()
=>
{
it
(
'
returns title for up
'
,
()
=>
{
expect
(
vm
.
tooltipTitle
).
toBe
(
'
Scroll to top
'
);
});
it
(
'
returns title for down
'
,
()
=>
{
vm
.
direction
=
'
down
'
;
expect
(
vm
.
tooltipTitle
).
toBe
(
'
Scroll to bottom
'
);
});
});
it
(
'
emits click event on click
'
,
()
=>
{
spyOn
(
vm
,
'
$emit
'
);
vm
.
$el
.
querySelector
(
'
.btn-scroll
'
).
click
();
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
click
'
);
});
it
(
'
disables button when disabled is true
'
,
done
=>
{
vm
.
disabled
=
true
;
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.btn-scroll
'
).
hasAttribute
(
'
disabled
'
)).
toBe
(
true
);
done
();
});
});
});
spec/javascripts/ide/components/jobs/detail_spec.js
0 → 100644
View file @
f73b2c8e
import
Vue
from
'
vue
'
;
import
JobDetail
from
'
~/ide/components/jobs/detail.vue
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
{
createComponentWithStore
}
from
'
../../../helpers/vue_mount_component_helper
'
;
import
{
jobs
}
from
'
../../mock_data
'
;
describe
(
'
IDE jobs detail view
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
JobDetail
);
let
vm
;
beforeEach
(()
=>
{
const
store
=
createStore
();
store
.
state
.
pipelines
.
detailJob
=
{
...
jobs
[
0
],
isLoading
:
true
,
output
:
'
testing
'
,
rawPath
:
`
${
gl
.
TEST_HOST
}
/raw`
,
};
vm
=
createComponentWithStore
(
Component
,
store
);
spyOn
(
vm
,
'
fetchJobTrace
'
).
and
.
returnValue
(
Promise
.
resolve
());
vm
=
vm
.
$mount
();
spyOn
(
vm
.
$refs
.
buildTrace
,
'
scrollTo
'
);
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
it
(
'
calls fetchJobTrace on mount
'
,
()
=>
{
expect
(
vm
.
fetchJobTrace
).
toHaveBeenCalled
();
});
it
(
'
scrolls to bottom on mount
'
,
done
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
$refs
.
buildTrace
.
scrollTo
).
toHaveBeenCalled
();
done
();
});
});
it
(
'
renders job output
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.bash
'
).
textContent
).
toContain
(
'
testing
'
);
});
it
(
'
renders loading icon
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.build-loader-animation
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.build-loader-animation
'
).
style
.
display
).
toBe
(
''
);
});
it
(
'
hide loading icon when isLoading is false
'
,
done
=>
{
vm
.
$store
.
state
.
pipelines
.
detailJob
.
isLoading
=
false
;
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.build-loader-animation
'
).
style
.
display
).
toBe
(
'
none
'
);
done
();
});
});
it
(
'
resets detailJob when clicking header button
'
,
()
=>
{
spyOn
(
vm
,
'
setDetailJob
'
);
vm
.
$el
.
querySelector
(
'
.btn
'
).
click
();
expect
(
vm
.
setDetailJob
).
toHaveBeenCalledWith
(
null
);
});
it
(
'
renders raw path link
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.controllers-buttons
'
).
getAttribute
(
'
href
'
)).
toBe
(
`
${
gl
.
TEST_HOST
}
/raw`
,
);
});
describe
(
'
scroll buttons
'
,
()
=>
{
it
(
'
triggers scrollDown when clicking down button
'
,
done
=>
{
spyOn
(
vm
,
'
scrollDown
'
);
vm
.
$el
.
querySelectorAll
(
'
.btn-scroll
'
)[
1
].
click
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
scrollDown
).
toHaveBeenCalled
();
done
();
});
});
it
(
'
triggers scrollUp when clicking up button
'
,
done
=>
{
spyOn
(
vm
,
'
scrollUp
'
);
vm
.
scrollPos
=
1
;
vm
.
$nextTick
()
.
then
(()
=>
vm
.
$el
.
querySelector
(
'
.btn-scroll
'
).
click
())
.
then
(()
=>
vm
.
$nextTick
())
.
then
(()
=>
{
expect
(
vm
.
scrollUp
).
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
scrollDown
'
,
()
=>
{
it
(
'
scrolls build trace to bottom
'
,
()
=>
{
spyOnProperty
(
vm
.
$refs
.
buildTrace
,
'
scrollHeight
'
).
and
.
returnValue
(
1000
);
vm
.
scrollDown
();
expect
(
vm
.
$refs
.
buildTrace
.
scrollTo
).
toHaveBeenCalledWith
(
0
,
1000
);
});
});
describe
(
'
scrollUp
'
,
()
=>
{
it
(
'
scrolls build trace to top
'
,
()
=>
{
vm
.
scrollUp
();
expect
(
vm
.
$refs
.
buildTrace
.
scrollTo
).
toHaveBeenCalledWith
(
0
,
0
);
});
});
describe
(
'
scrollBuildLog
'
,
()
=>
{
beforeEach
(()
=>
{
spyOnProperty
(
vm
.
$refs
.
buildTrace
,
'
offsetHeight
'
).
and
.
returnValue
(
100
);
spyOnProperty
(
vm
.
$refs
.
buildTrace
,
'
scrollHeight
'
).
and
.
returnValue
(
200
);
});
it
(
'
sets scrollPos to bottom when at the bottom
'
,
done
=>
{
spyOnProperty
(
vm
.
$refs
.
buildTrace
,
'
scrollTop
'
).
and
.
returnValue
(
100
);
vm
.
scrollBuildLog
();
setTimeout
(()
=>
{
expect
(
vm
.
scrollPos
).
toBe
(
1
);
done
();
});
});
it
(
'
sets scrollPos to top when at the top
'
,
done
=>
{
spyOnProperty
(
vm
.
$refs
.
buildTrace
,
'
scrollTop
'
).
and
.
returnValue
(
0
);
vm
.
scrollPos
=
1
;
vm
.
scrollBuildLog
();
setTimeout
(()
=>
{
expect
(
vm
.
scrollPos
).
toBe
(
0
);
done
();
});
});
it
(
'
resets scrollPos when not at top or bottom
'
,
done
=>
{
spyOnProperty
(
vm
.
$refs
.
buildTrace
,
'
scrollTop
'
).
and
.
returnValue
(
10
);
vm
.
scrollBuildLog
();
setTimeout
(()
=>
{
expect
(
vm
.
scrollPos
).
toBe
(
''
);
done
();
});
});
});
});
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