Commit 82dea974 by Brian Jacobel Committed by GitHub

Merge pull request #14791 from edx/bjacobel/course-outline-events

Add events to course outline, and add JS tests for that
parents d9ff4ed8 ee344980
...@@ -592,6 +592,7 @@ class CoursewareMultipleVerticalsTest(CoursewareMultipleVerticalsTestBase): ...@@ -592,6 +592,7 @@ class CoursewareMultipleVerticalsTest(CoursewareMultipleVerticalsTestBase):
selected_events selected_events
) )
# TODO: Delete as part of TNL-6546 / LEARNER-71
def test_link_clicked_events(self): def test_link_clicked_events(self):
""" """
Given that I am a user in the courseware Given that I am a user in the courseware
......
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
define([ define([
'jquery', 'jquery',
'logger',
'edx-ui-toolkit/js/utils/constants' 'edx-ui-toolkit/js/utils/constants'
], ],
function($, constants) { function($, Logger, constants) {
return function(root) { return function(root) {
// In the future this factory could instantiate a Backbone view or React component that handles events // In the future this factory could instantiate a Backbone view or React component that handles events
$(root).keydown(function(event) { $(root).keydown(function(event) {
...@@ -23,6 +24,16 @@ ...@@ -23,6 +24,16 @@
break; break;
} }
}); });
$('a:not([href^="#"])').click(function(event) {
Logger.log(
'edx.ui.lms.link_clicked',
{
current_url: window.location.href,
target_url: event.currentTarget.href
}
);
});
}; };
} }
); );
......
define([ define([
'jquery', 'jquery',
'logger',
'edx-ui-toolkit/js/utils/constants', 'edx-ui-toolkit/js/utils/constants',
'course_experience/js/course_outline_factory' 'course_experience/js/course_outline_factory'
], ],
function($, constants, CourseOutlineFactory) { function($, Logger, constants, CourseOutlineFactory) {
'use strict'; 'use strict';
describe('Course outline factory', function() { describe('Course outline factory', function() {
...@@ -81,6 +82,25 @@ define([ ...@@ -81,6 +82,25 @@ define([
}); });
}); });
}); });
describe('eventing', function() {
beforeEach(function() {
loadFixtures('course_experience/fixtures/course-outline-fragment.html');
CourseOutlineFactory('.block-tree');
spyOn(Logger, 'log');
});
it('sends an event when an outline section is clicked', function() {
$('a.focusable:contains("Homework - Labs and Demos")').click();
expect(Logger.log).toHaveBeenCalledWith('edx.ui.lms.link_clicked', {
target_url: window.location.origin +
'/courses/course-v1:edX+DemoX+Demo_Course/jump_to/block-v1:edX+DemoX+Demo_Course+type' +
'@sequential+block@graded_simulations',
current_url: window.location.toString()
});
});
});
}); });
} }
); );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment