Add events to course outline, and add JS tests
This commit is contained in:
@@ -592,6 +592,7 @@ class CoursewareMultipleVerticalsTest(CoursewareMultipleVerticalsTestBase):
|
||||
selected_events
|
||||
)
|
||||
|
||||
# TODO: Delete as part of TNL-6546 / LEARNER-71
|
||||
def test_link_clicked_events(self):
|
||||
"""
|
||||
Given that I am a user in the courseware
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'logger',
|
||||
'edx-ui-toolkit/js/utils/constants'
|
||||
],
|
||||
function($, constants) {
|
||||
function($, Logger, constants) {
|
||||
return function(root) {
|
||||
// In the future this factory could instantiate a Backbone view or React component that handles events
|
||||
$(root).keydown(function(event) {
|
||||
@@ -23,6 +24,16 @@
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$('a:not([href^="#"])').click(function(event) {
|
||||
Logger.log(
|
||||
'edx.ui.lms.link_clicked',
|
||||
{
|
||||
current_url: window.location.href,
|
||||
target_url: event.currentTarget.href
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
define([
|
||||
'jquery',
|
||||
'logger',
|
||||
'edx-ui-toolkit/js/utils/constants',
|
||||
'course_experience/js/course_outline_factory'
|
||||
],
|
||||
function($, constants, CourseOutlineFactory) {
|
||||
function($, Logger, constants, CourseOutlineFactory) {
|
||||
'use strict';
|
||||
|
||||
describe('Course outline factory', function() {
|
||||
@@ -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()
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user