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
7693ca8e
Commit
7693ca8e
authored
Sep 26, 2019
by
Winnie Hellmann
Committed by
Mike Greiling
Sep 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate confidential_issue_sidebar_spec.js to Jest
parent
c033d038
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
10 deletions
+31
-10
spec/frontend/helpers/tracking_helper.js
spec/frontend/helpers/tracking_helper.js
+25
-0
spec/frontend/sidebar/confidential_issue_sidebar_spec.js
spec/frontend/sidebar/confidential_issue_sidebar_spec.js
+6
-10
No files found.
spec/frontend/helpers/tracking_helper.js
0 → 100644
View file @
7693ca8e
import
Tracking
from
'
~/tracking
'
;
export
default
Tracking
;
let
document
;
let
handlers
;
export
function
mockTracking
(
category
=
'
_category_
'
,
documentOverride
,
spyMethod
)
{
document
=
documentOverride
||
window
.
document
;
window
.
snowplow
=
()
=>
{};
Tracking
.
bindDocument
(
category
,
document
);
return
spyMethod
?
spyMethod
(
Tracking
,
'
event
'
)
:
null
;
}
export
function
unmockTracking
()
{
window
.
snowplow
=
undefined
;
handlers
.
forEach
(
event
=>
document
.
removeEventListener
(
event
.
name
,
event
.
func
));
}
export
function
triggerEvent
(
selectorOrEl
,
eventName
=
'
click
'
)
{
const
event
=
new
Event
(
eventName
,
{
bubbles
:
true
});
const
el
=
typeof
selectorOrEl
===
'
string
'
?
document
.
querySelector
(
selectorOrEl
)
:
selectorOrEl
;
el
.
dispatchEvent
(
event
);
}
spec/
javascripts
/sidebar/confidential_issue_sidebar_spec.js
→
spec/
frontend
/sidebar/confidential_issue_sidebar_spec.js
View file @
7693ca8e
import
Vue
from
'
vue
'
;
import
confidentialIssueSidebar
from
'
~/sidebar/components/confidential/confidential_issue_sidebar.vue
'
;
import
{
mockTracking
,
triggerEvent
}
from
'
spec/
helpers/tracking_helper
'
;
import
{
mockTracking
,
triggerEvent
}
from
'
helpers/tracking_helper
'
;
describe
(
'
Confidential Issue Sidebar Block
'
,
()
=>
{
let
vm1
;
...
...
@@ -37,40 +37,36 @@ describe('Confidential Issue Sidebar Block', () => {
expect
(
vm2
.
$el
.
innerHTML
.
includes
(
'
Not confidential
'
)).
toBe
(
true
);
});
it
(
'
displays the edit form when editable
'
,
done
=>
{
it
(
'
displays the edit form when editable
'
,
()
=>
{
expect
(
vm1
.
edit
).
toBe
(
false
);
vm1
.
$el
.
querySelector
(
'
.confidential-edit
'
).
click
();
expect
(
vm1
.
edit
).
toBe
(
true
);
setTimeout
(()
=>
{
return
Vue
.
nextTick
().
then
(()
=>
{
expect
(
vm1
.
$el
.
innerHTML
.
includes
(
'
You are going to turn off the confidentiality.
'
)).
toBe
(
true
,
);
done
();
});
});
it
(
'
displays the edit form when opened from collapsed state
'
,
done
=>
{
it
(
'
displays the edit form when opened from collapsed state
'
,
()
=>
{
expect
(
vm1
.
edit
).
toBe
(
false
);
vm1
.
$el
.
querySelector
(
'
.sidebar-collapsed-icon
'
).
click
();
expect
(
vm1
.
edit
).
toBe
(
true
);
setTimeout
(()
=>
{
return
Vue
.
nextTick
().
then
(()
=>
{
expect
(
vm1
.
$el
.
innerHTML
.
includes
(
'
You are going to turn off the confidentiality.
'
)).
toBe
(
true
,
);
done
();
});
});
it
(
'
tracks the event when "Edit" is clicked
'
,
()
=>
{
const
spy
=
mockTracking
(
'
_category_
'
,
vm1
.
$el
,
spyOn
);
const
spy
=
mockTracking
(
'
_category_
'
,
vm1
.
$el
,
jest
.
spyOn
);
triggerEvent
(
'
.confidential-edit
'
);
expect
(
spy
).
toHaveBeenCalledWith
(
'
_category_
'
,
'
click_edit_button
'
,
{
...
...
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