mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FEATURE: Extend clicking tracking to the user profile page. (#4203)
* Extend clicking tracking to the user profile page. Added qunit tests Fixed click-track-test so it uses the correct data attribute for topic_id in its fixture * Added a second excerpt to verify test pulls from the appropriate one.
This commit is contained in:
@ -17,7 +17,7 @@ module("lib:click-track", {
|
||||
sandbox.stub(win, "focus");
|
||||
|
||||
fixture().html(
|
||||
`<div id="topic" id="1337">
|
||||
`<div id="topic" data-topic-id="1337">
|
||||
<article data-post-id="42" data-user-id="3141">
|
||||
<a href="http://www.google.com">google.com</a>
|
||||
<a class="lightbox back quote-other-topic" href="http://www.google.com">google.com</a>
|
||||
@ -132,7 +132,7 @@ test("right clicks change the href", function() {
|
||||
test("right clicks are tracked", function() {
|
||||
Discourse.SiteSettings.track_external_right_clicks = true;
|
||||
trackRightClick();
|
||||
equal(fixture('a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42");
|
||||
equal(fixture('a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337");
|
||||
});
|
||||
|
||||
test("preventDefault is not called for right clicks", function() {
|
||||
@ -191,11 +191,11 @@ test("tracks custom urls when opening in another window", function() {
|
||||
var clickEvent = generateClickEventOn('a');
|
||||
sandbox.stub(Discourse.User, "currentProp").withArgs('external_links_in_new_tab').returns(true);
|
||||
ok(!track(clickEvent));
|
||||
ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42', '_blank'));
|
||||
ok(windowOpen.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337', '_blank'));
|
||||
});
|
||||
|
||||
test("tracks custom urls when opening in another window", function() {
|
||||
var clickEvent = generateClickEventOn('a');
|
||||
ok(!track(clickEvent));
|
||||
ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42'));
|
||||
ok(redirectTo.calledWith('/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337'));
|
||||
});
|
||||
|
Reference in New Issue
Block a user