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();
|
chatview.delegateEvents();
|
||||||
|
|
||||||
controlview.el.querySelector('.close-chatbox-button').click();
|
controlview.el.querySelector('.close-chatbox-button').click();
|
||||||
|
|
||||||
expect(controlview.close).toHaveBeenCalled();
|
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).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();
|
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).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||||
expect(_converse.api.trigger.calls.count(), 2);
|
|
||||||
done();
|
done();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -381,6 +380,7 @@
|
|||||||
spyOn(_converse.api, "trigger").and.callThrough();
|
spyOn(_converse.api, "trigger").and.callThrough();
|
||||||
|
|
||||||
test_utils.closeControlBox();
|
test_utils.closeControlBox();
|
||||||
|
await new Promise(resolve => _converse.api.listen.once('chatBoxClosed', resolve));
|
||||||
expect(_converse.api.trigger).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
expect(_converse.api.trigger).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||||
expect(_converse.chatboxes.length).toEqual(1);
|
expect(_converse.chatboxes.length).toEqual(1);
|
||||||
expect(_converse.chatboxes.pluck('id')).toEqual(['controlbox']);
|
expect(_converse.chatboxes.pluck('id')).toEqual(['controlbox']);
|
||||||
|
@ -297,7 +297,7 @@ converse.plugins.add('converse-controlbox', {
|
|||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
return this.model.save(
|
return this.model.save(
|
||||||
{'closed': true},
|
{'closed': true},
|
||||||
{'success': resolve, 'error': reject}
|
{'success': resolve, 'error': reject, 'wait': true}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -341,9 +341,7 @@ converse.plugins.add('converse-controlbox', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
show () {
|
show () {
|
||||||
_converse.controlboxtoggle.hide(
|
_converse.controlboxtoggle.hide(() => this.onControlBoxToggleHidden());
|
||||||
this.onControlBoxToggleHidden.bind(this)
|
|
||||||
);
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user