Fix more failing tests
This commit is contained in:
parent
56e28070b2
commit
850c6aa2bd
|
@ -365,9 +365,8 @@
|
|||
test_utils.createContacts(_converse, 'current');
|
||||
test_utils.openControlBox();
|
||||
test_utils.waitUntil(function () {
|
||||
return $(_converse.rosterview.el).find('.roster-group').length;
|
||||
}, 300)
|
||||
.then(function () {
|
||||
return $(_converse.rosterview.el).find('.roster-group').length;
|
||||
}, 300).then(function () {
|
||||
spyOn(_converse, 'emit');
|
||||
spyOn(_converse.chatboxviews, 'trimChats');
|
||||
_converse.chatboxes.browserStorage._clear();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
var Strophe = converse.env.Strophe;
|
||||
var $iq = converse.env.$iq;
|
||||
var $pres = converse.env.$pres;
|
||||
var u = converse.env.utils;
|
||||
// See: https://xmpp.org/rfcs/rfc3921.html
|
||||
|
||||
describe("A sent presence stanza", function () {
|
||||
|
@ -56,21 +57,34 @@
|
|||
spyOn(view.model, 'sendPresence').and.callThrough();
|
||||
spyOn(_converse.connection, 'send').and.callThrough();
|
||||
|
||||
view.el.querySelector('a.change-xmpp-status-message').click();
|
||||
var msg = 'My custom status';
|
||||
view.el.querySelector('input.custom-xmpp-status').value = msg;
|
||||
view.el.querySelector('[type="submit"]').click();
|
||||
expect(view.model.sendPresence).toHaveBeenCalled();
|
||||
var cbview = _converse.chatboxviews.get('controlbox');
|
||||
cbview.el.querySelector('.change-status').click()
|
||||
var modal = _converse.xmppstatusview.status_modal;
|
||||
test_utils.waitUntil(function () {
|
||||
return u.isVisible(modal.el);
|
||||
}, 1000).then(function () {
|
||||
var msg = 'My custom status';
|
||||
modal.el.querySelector('input[name="status_message"]').value = msg;
|
||||
modal.el.querySelector('[type="submit"]').click();
|
||||
expect(view.model.sendPresence).toHaveBeenCalled();
|
||||
expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
|
||||
.toBe("<presence xmlns='jabber:client'><status>My custom status</status><priority>0</priority></presence>")
|
||||
|
||||
expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
|
||||
.toBe("<presence xmlns='jabber:client'><status>My custom status</status><priority>0</priority></presence>")
|
||||
|
||||
view.el.querySelector('a.choose-xmpp-status').click();
|
||||
view.el.querySelectorAll('.dropdown dd ul li a')[1].click(); // Change status to "dnd"
|
||||
|
||||
expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
|
||||
.toBe("<presence xmlns='jabber:client'><show>dnd</show><status>My custom status</status><priority>0</priority></presence>")
|
||||
done();
|
||||
return test_utils.waitUntil(function () {
|
||||
return modal.el.getAttribute('aria-hidden') === "true";
|
||||
});
|
||||
}).then(function () {
|
||||
cbview.el.querySelector('.change-status').click()
|
||||
return test_utils.waitUntil(function () {
|
||||
return modal.el.getAttribute('aria-hidden') === "false";
|
||||
}, 1000);
|
||||
}).then(function () {
|
||||
modal.el.querySelector('label[for="radio-busy"]').click(); // Change status to "dnd"
|
||||
modal.el.querySelector('[type="submit"]').click();
|
||||
expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
|
||||
.toBe("<presence xmlns='jabber:client'><show>dnd</show><status>My custom status</status><priority>0</priority></presence>")
|
||||
done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
var $iq = converse.env.$iq;
|
||||
var $pres = converse.env.$pres;
|
||||
var _ = converse.env._;
|
||||
var u = converse.env.utils;
|
||||
// See:
|
||||
// https://xmpp.org/rfcs/rfc3921.html
|
||||
|
||||
|
@ -54,7 +55,7 @@
|
|||
{ roster_groups: false },
|
||||
function (done, _converse) {
|
||||
|
||||
var contact, sent_stanza, IQ_id, stanza;
|
||||
var contact, sent_stanza, IQ_id, stanza, modal;
|
||||
test_utils.waitUntilDiscoConfirmed(_converse, 'localhost', [], ['vcard-temp'])
|
||||
.then(function () {
|
||||
return test_utils.waitUntil(function () {
|
||||
|
@ -65,8 +66,8 @@
|
|||
* the interaction between roster items and subscription states.
|
||||
*/
|
||||
test_utils.openControlBox(_converse);
|
||||
var panel = _converse.chatboxviews.get('controlbox').contactspanel;
|
||||
spyOn(panel, "addContactFromForm").and.callThrough();
|
||||
var cbview = _converse.chatboxviews.get('controlbox');
|
||||
|
||||
spyOn(_converse.roster, "addAndSubscribe").and.callThrough();
|
||||
spyOn(_converse.roster, "addContact").and.callThrough();
|
||||
spyOn(_converse.roster, "sendContactAddIQ").and.callThrough();
|
||||
|
@ -77,21 +78,18 @@
|
|||
sent_stanza = iq;
|
||||
IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
||||
});
|
||||
panel.delegateEvents(); // Rebind all events so that our spy gets called
|
||||
|
||||
/* Add a new contact through the UI */
|
||||
var form = panel.el.querySelector('form.add-xmpp-contact');
|
||||
expect(_.isNull(form)).toBeTruthy();
|
||||
|
||||
// Click the "Add a contact" link.
|
||||
panel.el.querySelector('.toggle-xmpp-contact-form').click();
|
||||
|
||||
// Check that the form appears
|
||||
form = panel.el.querySelector('form.add-xmpp-contact');
|
||||
expect(form.parentElement.offsetHeight).not.toBe(0);
|
||||
expect(_.includes(form.parentElement.classList, 'collapsed')).toBeFalsy();
|
||||
cbview.el.querySelector('.add-contact').click()
|
||||
modal = _converse.rosterview.add_contact_modal;
|
||||
return test_utils.waitUntil(function () {
|
||||
return u.isVisible(modal.el);
|
||||
}, 1000);
|
||||
}).then(function () {
|
||||
spyOn(modal, "addContactFromForm").and.callThrough();
|
||||
modal.delegateEvents();
|
||||
|
||||
// Fill in the form and submit
|
||||
var form = modal.el.querySelector('form.add-xmpp-contact');
|
||||
form.querySelector('input').value = 'contact@example.org';
|
||||
form.querySelector('[type="submit"]').click();
|
||||
|
||||
|
@ -100,15 +98,10 @@
|
|||
* subscription, the user's client SHOULD perform a "roster set"
|
||||
* for the new roster item.
|
||||
*/
|
||||
expect(panel.addContactFromForm).toHaveBeenCalled();
|
||||
expect(modal.addContactFromForm).toHaveBeenCalled();
|
||||
expect(_converse.roster.addAndSubscribe).toHaveBeenCalled();
|
||||
expect(_converse.roster.addContact).toHaveBeenCalled();
|
||||
|
||||
// The form should not be visible anymore (by virtue of its
|
||||
// parent being collapsed)
|
||||
expect(form.parentElement.offsetHeight).toBe(0);
|
||||
expect(_.includes(form.parentElement.classList, 'collapsed')).toBeTrue;
|
||||
|
||||
/* _converse request consists of sending an IQ
|
||||
* stanza of type='set' containing a <query/> element qualified by
|
||||
* the 'jabber:iq:roster' namespace, which in turn contains an
|
||||
|
|
|
@ -128,7 +128,6 @@
|
|||
|
||||
_converse.AddContactModal = _converse.BootstrapModal.extend({
|
||||
events: {
|
||||
'click a.subscribe-to-user': 'addContactFromList',
|
||||
'submit form': 'addContactFromForm',
|
||||
'submit form.search-xmpp-contact': 'searchContacts'
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input {[ if (o.status === 'busy') { ]} checked="checked" {[ } ]}
|
||||
type="radio" id="radio-busy" value="busy" name="chat_status" class="custom-control-input">
|
||||
type="radio" id="radio-busy" value="dnd" name="chat_status" class="custom-control-input">
|
||||
<label class="custom-control-label" for="radio-busy">
|
||||
<span class="fa fa-minus-circle"></span> {{{o.label_busy}}}</label>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user