MDL-66226 core_message: wrap promise chains in pending for behat

Fixes random failures by forcing behat to wait for the pane to render.
This commit is contained in:
Jake Dallimore 2019-10-04 09:24:19 +08:00
parent 545e8988c3
commit c11baac4b4
3 changed files with 12 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,6 +27,7 @@ define(
'core/notification',
'core/pubsub',
'core/str',
'core/pending',
'core/templates',
'core/user_date',
'core_message/message_repository',
@ -42,6 +43,7 @@ function(
Notification,
PubSub,
Str,
Pending,
Templates,
UserDate,
MessageRepository,
@ -204,6 +206,7 @@ function(
// Helper to format the last message for rendering.
// Returns a promise which resolves to either a string, or null
// (such as in the event of an empty personal space).
var pending = new Pending();
var formatMessagePreview = function(lastMessage) {
if (!lastMessage) {
return new Promise(function(resolve) {
@ -309,7 +312,13 @@ function(
});
return Templates.render(TEMPLATES.CONVERSATIONS_LIST, {conversations: formattedConversations});
}).catch(Notification.exception);
}).then(function(html, js) {
pending.resolve();
return $.Deferred().resolve(html, js);
}).catch(function(error) {
pending.resolve();
Notification.exception(error);
});
};
/**