Commit 88e355f7 by Jeremy Bowman Committed by GitHub

Merge pull request #14757 from edx/jmbowman/PLAT-1198

PLAT-1198 Reduce risk of losing navigation events
parents 9d5b6d15 d1f25612
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
// `direction` can be 'previous' or 'next' // `direction` can be 'previous' or 'next'
Sequence.prototype._change_sequential = function(direction, event) { Sequence.prototype._change_sequential = function(direction, event) {
var analyticsEventName, isBottomNav, newPosition, offset, widgetPlacement; var analyticsEventName, isBottomNav, newPosition, offset, targetUrl, widgetPlacement;
// silently abort if direction is invalid. // silently abort if direction is invalid.
if (direction !== 'previous' && direction !== 'next') { if (direction !== 'previous' && direction !== 'next') {
...@@ -355,19 +355,27 @@ ...@@ -355,19 +355,27 @@
widgetPlacement = 'top'; widgetPlacement = 'top';
} }
if ((direction === 'next') && (this.position >= this.contents.length)) {
targetUrl = this.nextUrl;
} else if ((direction === 'previous') && (this.position === 1)) {
targetUrl = this.prevUrl;
}
// Formerly known as seq_next and seq_prev // Formerly known as seq_next and seq_prev
Logger.log(analyticsEventName, { Logger.log(analyticsEventName, {
id: this.id, id: this.id,
current_tab: this.position, current_tab: this.position,
tab_count: this.num_contents, tab_count: this.num_contents,
widget_placement: widgetPlacement widget_placement: widgetPlacement
}).always(function() {
if (targetUrl) {
// Wait to load the new page until we've attempted to log the event
window.location.href = targetUrl;
}
}); });
if ((direction === 'next') && (this.position >= this.contents.length)) { // If we're staying on the page, no need to wait for the event logging to finish
window.location.href = this.nextUrl; if (!targetUrl) {
} else if ((direction === 'previous') && (this.position === 1)) {
window.location.href = this.prevUrl;
} else {
// If the bottom nav is used, scroll to the top of the page on change. // If the bottom nav is used, scroll to the top of the page on change.
if (isBottomNav) { if (isBottomNav) {
$.scrollTo(0, 150); $.scrollTo(0, 150);
......
...@@ -131,7 +131,10 @@ class CoursewarePage(CoursePage): ...@@ -131,7 +131,10 @@ class CoursewarePage(CoursePage):
against the case where the page is still being loaded. against the case where the page is still being loaded.
""" """
active_tab = self._active_sequence_tab active_tab = self._active_sequence_tab
return active_tab and int(active_tab.attrs('data-element')[0]) == sequential_position try:
return active_tab and int(active_tab.attrs('data-element')[0]) == sequential_position
except IndexError:
return False
sequential_position_css = '#sequence-list #tab_{0}'.format(sequential_position - 1) sequential_position_css = '#sequence-list #tab_{0}'.format(sequential_position - 1)
self.q(css=sequential_position_css).first.click() self.q(css=sequential_position_css).first.click()
...@@ -181,7 +184,10 @@ class CoursewarePage(CoursePage): ...@@ -181,7 +184,10 @@ class CoursewarePage(CoursePage):
against the case where the page is still being loaded. against the case where the page is still being loaded.
""" """
active_tab = self._active_sequence_tab active_tab = self._active_sequence_tab
return active_tab and previous_tab_id != active_tab.attrs('data-id')[0] try:
return active_tab and previous_tab_id != active_tab.attrs('data-id')[0]
except IndexError:
return False
self.q( self.q(
css='.{} > .sequence-nav-button.{}'.format(top_or_bottom_class, next_or_previous_class) css='.{} > .sequence-nav-button.{}'.format(top_or_bottom_class, next_or_previous_class)
......
...@@ -5,7 +5,6 @@ End-to-end tests for the LMS. ...@@ -5,7 +5,6 @@ End-to-end tests for the LMS.
import json import json
from datetime import datetime, timedelta from datetime import datetime, timedelta
from unittest import skip
import ddt import ddt
from flaky import flaky from flaky import flaky
...@@ -441,7 +440,7 @@ class CoursewareMultipleVerticalsTest(CoursewareMultipleVerticalsTestBase): ...@@ -441,7 +440,7 @@ class CoursewareMultipleVerticalsTest(CoursewareMultipleVerticalsTestBase):
Test courseware with multiple verticals Test courseware with multiple verticals
""" """
@skip('Disable temporarily to get course bookmarks out') @flaky # PLAT-1198; should be fixed, but verify that failures stop before removing
def test_navigation_buttons(self): def test_navigation_buttons(self):
self.courseware_page.visit() self.courseware_page.visit()
......
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