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
d82da588
Commit
d82da588
authored
Oct 28, 2019
by
Paul Gascou-Vaillancourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate issue boards specs to Jest & VTU
Migrated boards specs that rely on tooltips to Jest & Vue Test Utils
parent
eafd98ec
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
388 additions
and
0 deletions
+388
-0
spec/frontend/boards/components/issue_time_estimate_spec.js
spec/frontend/boards/components/issue_time_estimate_spec.js
+81
-0
spec/frontend/boards/issue_card_spec.js
spec/frontend/boards/issue_card_spec.js
+307
-0
No files found.
spec/
javascripts
/boards/components/issue_time_estimate_spec.js
→
spec/
frontend
/boards/components/issue_time_estimate_spec.js
View file @
d82da588
import
Vue
from
'
vue
'
;
import
IssueTimeEstimate
from
'
~/boards/components/issue_time_estimate.vue
'
;
import
boardsStore
from
'
~/boards/stores/boards_store
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
describe
(
'
Issue Time Estimate component
'
,
()
=>
{
let
vm
;
let
wrapper
;
beforeEach
(()
=>
{
boardsStore
.
create
();
});
afterEach
(()
=>
{
vm
.
$
destroy
();
wrapper
.
destroy
();
});
describe
(
'
when limitToHours is false
'
,
()
=>
{
beforeEach
(()
=>
{
boardsStore
.
timeTracking
.
limitToHours
=
false
;
const
Component
=
Vue
.
extend
(
IssueTimeEstimate
);
vm
=
mountComponent
(
Component
,
{
estimate
:
374460
,
wrapper
=
shallowMount
(
IssueTimeEstimate
,
{
propsData
:
{
estimate
:
374460
,
},
sync
:
false
,
});
});
it
(
'
renders the correct time estimate
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
time
'
).
textContent
.
trim
()).
toEqual
(
'
2w 3d 1m
'
);
expect
(
wrapper
.
find
(
'
time
'
)
.
text
()
.
trim
(),
).
toEqual
(
'
2w 3d 1m
'
);
});
it
(
'
renders expanded time estimate in tooltip
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-issue-time-estimate
'
).
textContent
).
toContain
(
'
2 weeks 3 days 1 minute
'
,
);
expect
(
wrapper
.
find
(
'
.js-issue-time-estimate
'
).
text
()).
toContain
(
'
2 weeks 3 days 1 minute
'
);
});
it
(
'
prevents tooltip xss
'
,
done
=>
{
const
alertSpy
=
spyOn
(
window
,
'
alert
'
);
vm
.
estimate
=
'
Foo <script>alert("XSS")</script>
'
;
vm
.
$nextTick
(()
=>
{
const
alertSpy
=
jest
.
spyOn
(
window
,
'
alert
'
);
wrapper
.
setProps
({
estimate
:
'
Foo <script>alert("XSS")</script>
'
});
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
alertSpy
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
$el
.
querySelector
(
'
time
'
).
textContent
.
trim
()).
toEqual
(
'
0m
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-issue-time-estimate
'
).
textContent
).
toContain
(
'
0m
'
);
expect
(
wrapper
.
find
(
'
time
'
)
.
text
()
.
trim
(),
).
toEqual
(
'
0m
'
);
expect
(
wrapper
.
find
(
'
.js-issue-time-estimate
'
).
text
()).
toContain
(
'
0m
'
);
done
();
});
});
...
...
@@ -50,21 +57,25 @@ describe('Issue Time Estimate component', () => {
describe
(
'
when limitToHours is true
'
,
()
=>
{
beforeEach
(()
=>
{
boardsStore
.
timeTracking
.
limitToHours
=
true
;
const
Component
=
Vue
.
extend
(
IssueTimeEstimate
);
vm
=
mountComponent
(
Component
,
{
estimate
:
374460
,
wrapper
=
shallowMount
(
IssueTimeEstimate
,
{
propsData
:
{
estimate
:
374460
,
},
sync
:
false
,
});
});
it
(
'
renders the correct time estimate
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
time
'
).
textContent
.
trim
()).
toEqual
(
'
104h 1m
'
);
expect
(
wrapper
.
find
(
'
time
'
)
.
text
()
.
trim
(),
).
toEqual
(
'
104h 1m
'
);
});
it
(
'
renders expanded time estimate in tooltip
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-issue-time-estimate
'
).
textContent
).
toContain
(
'
104 hours 1 minute
'
,
);
expect
(
wrapper
.
find
(
'
.js-issue-time-estimate
'
).
text
()).
toContain
(
'
104 hours 1 minute
'
);
});
});
});
spec/
javascripts
/boards/issue_card_spec.js
→
spec/
frontend
/boards/issue_card_spec.js
View file @
d82da588
This diff is collapsed.
Click to expand it.
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