MDL-69134 competencies: Behat fails randomly opening dialogues
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 25 Jun 2020 01:01:58 +0000 (09:01 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 8 Jul 2020 01:21:51 +0000 (09:21 +0800)
15 files changed:
admin/tool/lp/amd/build/dialogue.min.js
admin/tool/lp/amd/build/dialogue.min.js.map
admin/tool/lp/amd/build/grade_dialogue.min.js
admin/tool/lp/amd/build/grade_dialogue.min.js.map
admin/tool/lp/amd/build/grade_user_competency_inline.min.js
admin/tool/lp/amd/build/grade_user_competency_inline.min.js.map
admin/tool/lp/amd/src/dialogue.js
admin/tool/lp/amd/src/grade_dialogue.js
admin/tool/lp/amd/src/grade_user_competency_inline.js
report/competency/amd/build/grading_popup.min.js
report/competency/amd/build/grading_popup.min.js.map
report/competency/amd/build/user_course_navigation.min.js
report/competency/amd/build/user_course_navigation.min.js.map
report/competency/amd/src/grading_popup.js
report/competency/amd/src/user_course_navigation.js

index b2f77e0..6e0c86c 100644 (file)
Binary files a/admin/tool/lp/amd/build/dialogue.min.js and b/admin/tool/lp/amd/build/dialogue.min.js differ
index 7045a6f..881dda1 100644 (file)
Binary files a/admin/tool/lp/amd/build/dialogue.min.js.map and b/admin/tool/lp/amd/build/dialogue.min.js.map differ
index 806eeeb..9637bc9 100644 (file)
Binary files a/admin/tool/lp/amd/build/grade_dialogue.min.js and b/admin/tool/lp/amd/build/grade_dialogue.min.js differ
index 6af7b51..472ffa8 100644 (file)
Binary files a/admin/tool/lp/amd/build/grade_dialogue.min.js.map and b/admin/tool/lp/amd/build/grade_dialogue.min.js.map differ
index ade6899..45c0800 100644 (file)
Binary files a/admin/tool/lp/amd/build/grade_user_competency_inline.min.js and b/admin/tool/lp/amd/build/grade_user_competency_inline.min.js differ
index 1095c0f..4cc60b6 100644 (file)
Binary files a/admin/tool/lp/amd/build/grade_user_competency_inline.min.js.map and b/admin/tool/lp/amd/build/grade_user_competency_inline.min.js.map differ
index 04a570f..b96e262 100644 (file)
@@ -35,6 +35,8 @@ define(['core/yui'], function(Y) {
      * @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).
      */
     var dialogue = function(title, content, afterShow, afterHide, wide) {
+        M.util.js_pending('tool_lp/dialogue:dialogue');
+
         this.yuiDialogue = null;
         var parent = this;
 
@@ -59,6 +61,10 @@ define(['core/yui'], function(Y) {
                 width: width
             });
 
+            parent.yuiDialogue.before('visibleChange', function() {
+                M.util.js_pending('tool_lp/dialogue:before:visibleChange');
+            });
+
             parent.yuiDialogue.after('visibleChange', function(e) {
                 if (e.newVal) {
                     // Delay the callback call to the next tick, otherwise it can happen that it is
@@ -67,18 +73,25 @@ define(['core/yui'], function(Y) {
                         Y.soon(function() {
                             afterShow(parent);
                             parent.yuiDialogue.centerDialogue();
+                            M.util.js_complete('tool_lp/dialogue:before:visibleChange');
                         });
+                    } else {
+                        M.util.js_complete('tool_lp/dialogue:before:visibleChange');
                     }
                 } else {
                     if ((typeof afterHide !== 'undefined')) {
                         Y.soon(function() {
                             afterHide(parent);
+                            M.util.js_complete('tool_lp/dialogue:before:visibleChange');
                         });
+                    } else {
+                        M.util.js_complete('tool_lp/dialogue:before:visibleChange');
                     }
                 }
             });
 
             parent.yuiDialogue.show();
+            M.util.js_complete('tool_lp/dialogue:dialogue');
         });
     };
 
index 80ef97c..3b92add 100644 (file)
@@ -102,6 +102,7 @@ define(['jquery',
      * @return {Promise}
      */
     Grade.prototype.display = function() {
+        M.util.js_pending('tool_lp/grade_dialogue:display');
         return $.when(
             Str.get_string('rate', 'tool_lp'),
             this._render()
@@ -110,7 +111,10 @@ define(['jquery',
             this._popup = new Dialogue(
                 title,
                 templateResult[0],
-                this._afterRender.bind(this)
+                function() {
+                    this._afterRender();
+                    M.util.js_complete('tool_lp/grade_dialogue:display');
+                }.bind(this)
             );
 
             return this._popup;
index 81e4f35..9b32017 100644 (file)
@@ -94,6 +94,7 @@ define(['jquery',
         var options = [],
             self = this;
 
+        M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');
         var promise = ScaleValues.get_values(self._scaleId);
         promise.then(function(scalevalues) {
             options.push({
@@ -134,6 +135,7 @@ define(['jquery',
         .then(function(dialogue) {
             self._dialogue = dialogue;
 
+            M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');
             return;
         })
         .fail(notification.exception);
index d8d20a9..6a20c2d 100644 (file)
Binary files a/report/competency/amd/build/grading_popup.min.js and b/report/competency/amd/build/grading_popup.min.js differ
index f32b8c2..c7f243c 100644 (file)
Binary files a/report/competency/amd/build/grading_popup.min.js.map and b/report/competency/amd/build/grading_popup.min.js.map differ
index 43984a4..7aeba24 100644 (file)
Binary files a/report/competency/amd/build/user_course_navigation.min.js and b/report/competency/amd/build/user_course_navigation.min.js differ
index f2dcf64..c971332 100644 (file)
Binary files a/report/competency/amd/build/user_course_navigation.min.js.map and b/report/competency/amd/build/user_course_navigation.min.js.map differ
index e395d51..a38fd92 100644 (file)
@@ -59,10 +59,9 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
             args: {userid: userId, competencyid: competencyId, courseid: courseId},
         }]);
 
-        $.when.apply($, requests).then(function(context) {
-            this._contextLoaded.bind(this)(context);
-            return;
-        }.bind(this)).catch(notification.exception);
+        $.when(requests[0], requests[1])
+        .then(this._contextLoaded.bind(this))
+        .catch(notification.exception);
     };
 
     /**
@@ -70,23 +69,37 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
      *
      * @method _contextLoaded
      * @param {Object} context
+     * @returns {Promise}
      */
     GradingPopup.prototype._contextLoaded = function(context) {
-        var self = this;
-
         // We have to display user info in popup.
         context.displayuser = true;
-        templates.render('tool_lp/user_competency_summary_in_course', context).done(function(html, js) {
-            str.get_string('usercompetencysummary', 'report_competency').done(function(title) {
-                (new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));
-            }).fail(notification.exception);
-        }).fail(notification.exception);
+
+        M.util.js_pending('report_competency/grading_popup:_contextLoaded');
+
+        return $.when(
+            str.get_string('usercompetencysummary', 'report_competency'),
+            templates.render('tool_lp/user_competency_summary_in_course', context)
+        )
+        .then(function(title, templateData) {
+            return new Dialogue(
+                title,
+                templateData[0],
+                function() {
+                    templates.runTemplateJS(templateData[1]);
+                    M.util.js_complete('report_competency/grading_popup:_contextLoaded');
+                },
+                this._refresh.bind(this),
+                true
+            );
+        }.bind(this));
     };
 
     /**
      * Refresh the page.
      *
      * @method _refresh
+     * @returns {Promise}
      */
     GradingPopup.prototype._refresh = function() {
         var region = $(this._regionSelector);
@@ -99,7 +112,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
             moduleId = 0;
         }
 
-        ajax.call([{
+        return ajax.call([{
             methodname: 'report_competency_data_for_report',
             args: {courseid: courseId, userid: userId, moduleid: moduleId},
             done: this._pageContextLoaded.bind(this),
@@ -114,10 +127,13 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
      * @param {Object} context
      */
     GradingPopup.prototype._pageContextLoaded = function(context) {
-        var self = this;
-        templates.render('report_competency/report', context).done(function(html, js) {
-            templates.replaceNode(self._regionSelector, html, js);
-        }).fail(notification.exception);
+        templates.render('report_competency/report', context)
+        .then(function(html, js) {
+            templates.replaceNode(this._regionSelector, html, js);
+
+            return;
+        }.bind(this))
+        .catch(notification.exception);
     };
 
     /** @type {String} The selector for the region with the user competencies */
index ae2bbc5..146094b 100644 (file)
@@ -50,6 +50,8 @@ define(['jquery'], function($) {
      * @param {Event} e the event
      */
     UserCourseNavigation.prototype._userChanged = function(e) {
+        // Note: This change causes a page reload and is intentionally not paired with a js_complete call.
+        M.util.js_pending('report_competency/user_course_navigation:_userChanged');
         var newUserId = $(e.target).val();
         var queryStr = '?user=' + newUserId + '&id=' + this._courseId + '&mod=' + this._moduleId;
         document.location = this._baseUrl + queryStr;
@@ -62,6 +64,8 @@ define(['jquery'], function($) {
      * @param {Event} e the event
      */
     UserCourseNavigation.prototype._moduleChanged = function(e) {
+        // Note: This change causes a page reload and is intentionally not paired with a js_complete call.
+        M.util.js_pending('report_competency/user_course_navigation:_moduleChanged');
         var newModuleId = $(e.target).val();
         var queryStr = '?mod=' + newModuleId + '&id=' + this._courseId + '&user=' + this._userId;
         document.location = this._baseUrl + queryStr;