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
8233e975
Commit
8233e975
authored
Oct 28, 2019
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs to data tracking event
parent
deb3e2e4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
6 deletions
+58
-6
app/assets/javascripts/pages/sessions/new/index.js
app/assets/javascripts/pages/sessions/new/index.js
+9
-6
spec/frontend/fixtures/static/signin_tabs.html
spec/frontend/fixtures/static/signin_tabs.html
+3
-0
spec/javascripts/signin_tabs_memoizer_spec.js
spec/javascripts/signin_tabs_memoizer_spec.js
+46
-0
No files found.
app/assets/javascripts/pages/sessions/new/index.js
View file @
8233e975
...
@@ -22,12 +22,15 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -22,12 +22,15 @@ document.addEventListener('DOMContentLoaded', () => {
preserveUrlFragment
(
window
.
location
.
hash
);
preserveUrlFragment
(
window
.
location
.
hash
);
});
});
if
(
gon
.
tracking_data
)
{
export
default
function
trackData
()
{
if
(
gon
.
tracking_data
)
{
const
tab
=
document
.
querySelector
(
"
.new-session-tabs a[href='#register-pane']
"
);
const
{
category
,
action
,
...
data
}
=
gon
.
tracking_data
;
const
{
category
,
action
,
...
data
}
=
gon
.
tracking_data
;
$
(
'
#signin-container a[data-toggle="tab"]
'
).
on
(
'
shown.bs.tab
'
,
e
=>
{
tab
.
addEventListener
(
'
click
'
,
()
=>
{
if
(
e
.
target
.
dataset
.
qaSelector
===
'
register_tab
'
)
{
Tracking
.
event
(
category
,
action
,
data
);
Tracking
.
event
(
category
,
action
,
data
);
}
});
});
}
}
}
trackData
();
spec/frontend/fixtures/static/signin_tabs.html
View file @
8233e975
...
@@ -5,4 +5,7 @@
...
@@ -5,4 +5,7 @@
<li>
<li>
<a
href=
"#login-pane"
>
Standard
</a>
<a
href=
"#login-pane"
>
Standard
</a>
</li>
</li>
<li>
<a
href=
"#register-pane"
>
Register
</a>
</li>
</ul>
</ul>
spec/javascripts/signin_tabs_memoizer_spec.js
View file @
8233e975
import
AccessorUtilities
from
'
~/lib/utils/accessor
'
;
import
AccessorUtilities
from
'
~/lib/utils/accessor
'
;
import
SigninTabsMemoizer
from
'
~/pages/sessions/new/signin_tabs_memoizer
'
;
import
SigninTabsMemoizer
from
'
~/pages/sessions/new/signin_tabs_memoizer
'
;
import
trackData
from
'
~/pages/sessions/new/index
'
;
import
Tracking
from
'
~/tracking
'
;
describe
(
'
SigninTabsMemoizer
'
,
()
=>
{
describe
(
'
SigninTabsMemoizer
'
,
()
=>
{
const
fixtureTemplate
=
'
static/signin_tabs.html
'
;
const
fixtureTemplate
=
'
static/signin_tabs.html
'
;
...
@@ -93,6 +95,50 @@ describe('SigninTabsMemoizer', () => {
...
@@ -93,6 +95,50 @@ describe('SigninTabsMemoizer', () => {
});
});
});
});
describe
(
'
trackData
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
Tracking
,
'
event
'
);
});
describe
(
'
with tracking data
'
,
()
=>
{
beforeEach
(()
=>
{
gon
.
tracking_data
=
{
category
:
'
Growth::Acquisition::Experiment::SignUpFlow
'
,
action
:
'
start
'
,
label
:
'
uuid
'
,
property
:
'
control_group
'
,
};
trackData
();
});
it
(
'
should track data when the "click" event of the register tab is triggered
'
,
()
=>
{
document
.
querySelector
(
'
a[href="#register-pane"]
'
).
click
();
expect
(
Tracking
.
event
).
toHaveBeenCalledWith
(
'
Growth::Acquisition::Experiment::SignUpFlow
'
,
'
start
'
,
{
label
:
'
uuid
'
,
property
:
'
control_group
'
,
},
);
});
});
describe
(
'
without tracking data
'
,
()
=>
{
beforeEach
(()
=>
{
gon
.
tracking_data
=
undefined
;
trackData
();
});
it
(
'
should not track data when the "click" event of the register tab is triggered
'
,
()
=>
{
document
.
querySelector
(
'
a[href="#register-pane"]
'
).
click
();
expect
(
Tracking
.
event
).
not
.
toHaveBeenCalled
();
});
});
});
describe
(
'
saveData
'
,
()
=>
{
describe
(
'
saveData
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
memo
=
{
memo
=
{
...
...
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