mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
tests: Delay loading old messages and starting get_updates until phantomjs thinks the page has loaded
This doesn't affect code when not in testing. It shaves 7 seconds off of casper test time on my machine. (imported from commit 7e27fa781bcf16f36d9c8f058427ba57c41068bd)
This commit is contained in:
committed by
Steve Howell
parent
f45f0b1df6
commit
bdee9721ec
@@ -493,7 +493,7 @@ exports.clear = function clear() {
|
|||||||
this.stored_messages = {};
|
this.stored_messages = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function () {
|
util.execute_early(function () {
|
||||||
// get the initial message list
|
// get the initial message list
|
||||||
function load_more(messages) {
|
function load_more(messages) {
|
||||||
|
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ setInterval(function () {
|
|||||||
watchdog_time = new_time;
|
watchdog_time = new_time;
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
$(function () {
|
util.execute_early(function () {
|
||||||
$(document).on('unsuspend', function () {
|
$(document).on('unsuspend', function () {
|
||||||
// Immediately poll for new events on unsuspend
|
// Immediately poll for new events on unsuspend
|
||||||
blueslip.log("Restarting get_events due to unsuspend");
|
blueslip.log("Restarting get_events due to unsuspend");
|
||||||
|
|||||||
@@ -345,6 +345,14 @@ if (typeof $ !== 'undefined') {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.execute_early = function (func) {
|
||||||
|
if (page_params.test_suite) {
|
||||||
|
$(document).one('phantom_page_loaded', func);
|
||||||
|
} else {
|
||||||
|
$(func);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
}());
|
}());
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
|
|||||||
@@ -62,6 +62,13 @@ exports.initialize_casper = function (viewport) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
casper.on('load.finished', function () {
|
||||||
|
casper.evaluateOrDie(function () {
|
||||||
|
$(document).trigger($.Event('phantom_page_loaded'));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
casper.evaluate(function () {
|
casper.evaluate(function () {
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ set_global('channel', {});
|
|||||||
set_global('home_msg_list', {
|
set_global('home_msg_list', {
|
||||||
selected_id: function () {return 1;}
|
selected_id: function () {return 1;}
|
||||||
});
|
});
|
||||||
|
set_global('page_params', {test_suite: false});
|
||||||
|
|
||||||
|
|
||||||
var server_events = require('js/server_events.js');
|
var server_events = require('js/server_events.js');
|
||||||
|
|
||||||
var setup = function (results) {
|
var setup = function (results) {
|
||||||
server_events.home_view_loaded();
|
server_events.home_view_loaded();
|
||||||
set_global('page_params', {});
|
|
||||||
global.blueslip.error = function (msg, more_info, stack) {
|
global.blueslip.error = function (msg, more_info, stack) {
|
||||||
results.msg = msg;
|
results.msg = msg;
|
||||||
results.more_info = more_info;
|
results.more_info = more_info;
|
||||||
|
|||||||
Reference in New Issue
Block a user