controlbox: Wait when saving while closing
Otherwise we run into race conditions while testing
This commit is contained in:
parent
8aaa1a6417
commit
831e59c1a7
@ -321,15 +321,14 @@
|
||||
chatview.delegateEvents();
|
||||
|
||||
controlview.el.querySelector('.close-chatbox-button').click();
|
||||
|
||||
expect(controlview.close).toHaveBeenCalled();
|
||||
await new Promise(resolve => _converse.api.listen.once('chatBoxClosed', resolve));
|
||||
expect(_converse.api.trigger).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||
expect(_converse.api.trigger.calls.count(), 1);
|
||||
chatview.el.querySelector('.close-chatbox-button').click();
|
||||
|
||||
chatview.el.querySelector('.close-chatbox-button').click();
|
||||
expect(chatview.close).toHaveBeenCalled();
|
||||
await new Promise(resolve => _converse.api.listen.once('chatBoxClosed', resolve));
|
||||
expect(_converse.api.trigger).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||
expect(_converse.api.trigger.calls.count(), 2);
|
||||
done();
|
||||
}));
|
||||
|
||||
@ -381,6 +380,7 @@
|
||||
spyOn(_converse.api, "trigger").and.callThrough();
|
||||
|
||||
test_utils.closeControlBox();
|
||||
await new Promise(resolve => _converse.api.listen.once('chatBoxClosed', resolve));
|
||||
expect(_converse.api.trigger).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||
expect(_converse.chatboxes.length).toEqual(1);
|
||||
expect(_converse.chatboxes.pluck('id')).toEqual(['controlbox']);
|
||||
|
@ -297,7 +297,7 @@ converse.plugins.add('converse-controlbox', {
|
||||
await new Promise((resolve, reject) => {
|
||||
return this.model.save(
|
||||
{'closed': true},
|
||||
{'success': resolve, 'error': reject}
|
||||
{'success': resolve, 'error': reject, 'wait': true}
|
||||
);
|
||||
});
|
||||
} else {
|
||||
@ -341,9 +341,7 @@ converse.plugins.add('converse-controlbox', {
|
||||
},
|
||||
|
||||
show () {
|
||||
_converse.controlboxtoggle.hide(
|
||||
this.onControlBoxToggleHidden.bind(this)
|
||||
);
|
||||
_converse.controlboxtoggle.hide(() => this.onControlBoxToggleHidden());
|
||||
return this;
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user