From 1748938e15027b2e9f646565b7be01417e49a8a6 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 3 Sep 2015 15:01:05 +0800 Subject: [PATCH] MDL-51311 javascript: Teach Behat to wait for pending JQuery ajax --- lib/amd/build/first.min.js | 2 +- lib/amd/src/first.js | 11 ++++++++++- tag/tests/behat/edit_tag.feature | 2 -- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/amd/build/first.min.js b/lib/amd/build/first.min.js index 9dc3a61a1a6..7d7c42d7eb0 100644 --- a/lib/amd/build/first.min.js +++ b/lib/amd/build/first.min.js @@ -1 +1 @@ -define(function(){}); \ No newline at end of file +define(["jquery"],function(a){a(document).bind("ajaxStart",function(){M.util.js_pending("jq")}).bind("ajaxStop",function(){M.util.js_complete("jq")})}); \ No newline at end of file diff --git a/lib/amd/src/first.js b/lib/amd/src/first.js index 704c0c58306..72646f00bc8 100644 --- a/lib/amd/src/first.js +++ b/lib/amd/src/first.js @@ -18,10 +18,19 @@ * Because every module is returned from a request for any other module, this * forces the loading of all modules with a single request. * + * This function also sets up the listeners for ajax requests so we can tell + * if any requests are still in progress. + * * @module core/first * @package core * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 2.9 */ -define(function() { }); +define(['jquery'], function($) { + $(document).bind("ajaxStart", function(){ + M.util.js_pending('jq'); + }).bind("ajaxStop", function(){ + M.util.js_complete('jq'); + }); +}); diff --git a/tag/tests/behat/edit_tag.feature b/tag/tests/behat/edit_tag.feature index 3058ecfb607..1a717babf18 100644 --- a/tag/tests/behat/edit_tag.feature +++ b/tag/tests/behat/edit_tag.feature @@ -140,8 +140,6 @@ Feature: Users can edit tags to add description or rename And I click on "Edit tag name" "link" in the "Cat" "table_row" And I set the field "New name for tag Cat" to "Kitten" And I press key "13" in the field "New name for tag Cat" - # TODO MDL-51311 : replace with "And I wait until the page is ready". - And I wait "2" seconds Then I should not see "Cat" And "New name for tag" "field" should not be visible And I wait until "Kitten" "link" exists