|
@@ -11,6 +11,7 @@
|
|
var $iq = converse.env.$iq;
|
|
var $iq = converse.env.$iq;
|
|
var $pres = converse.env.$pres;
|
|
var $pres = converse.env.$pres;
|
|
var _ = converse.env._;
|
|
var _ = converse.env._;
|
|
|
|
+ var u = converse.env.utils;
|
|
// See:
|
|
// See:
|
|
// https://xmpp.org/rfcs/rfc3921.html
|
|
// https://xmpp.org/rfcs/rfc3921.html
|
|
|
|
|
|
@@ -54,7 +55,7 @@
|
|
{ roster_groups: false },
|
|
{ roster_groups: false },
|
|
function (done, _converse) {
|
|
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'])
|
|
test_utils.waitUntilDiscoConfirmed(_converse, 'localhost', [], ['vcard-temp'])
|
|
.then(function () {
|
|
.then(function () {
|
|
return test_utils.waitUntil(function () {
|
|
return test_utils.waitUntil(function () {
|
|
@@ -65,8 +66,8 @@
|
|
* the interaction between roster items and subscription states.
|
|
* the interaction between roster items and subscription states.
|
|
*/
|
|
*/
|
|
test_utils.openControlBox(_converse);
|
|
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, "addAndSubscribe").and.callThrough();
|
|
spyOn(_converse.roster, "addContact").and.callThrough();
|
|
spyOn(_converse.roster, "addContact").and.callThrough();
|
|
spyOn(_converse.roster, "sendContactAddIQ").and.callThrough();
|
|
spyOn(_converse.roster, "sendContactAddIQ").and.callThrough();
|
|
@@ -77,21 +78,18 @@
|
|
sent_stanza = iq;
|
|
sent_stanza = iq;
|
|
IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
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
|
|
// Fill in the form and submit
|
|
|
|
+ var form = modal.el.querySelector('form.add-xmpp-contact');
|
|
form.querySelector('input').value = 'contact@example.org';
|
|
form.querySelector('input').value = 'contact@example.org';
|
|
form.querySelector('[type="submit"]').click();
|
|
form.querySelector('[type="submit"]').click();
|
|
|
|
|
|
@@ -100,15 +98,10 @@
|
|
* subscription, the user's client SHOULD perform a "roster set"
|
|
* subscription, the user's client SHOULD perform a "roster set"
|
|
* for the new roster item.
|
|
* for the new roster item.
|
|
*/
|
|
*/
|
|
- expect(panel.addContactFromForm).toHaveBeenCalled();
|
|
|
|
|
|
+ expect(modal.addContactFromForm).toHaveBeenCalled();
|
|
expect(_converse.roster.addAndSubscribe).toHaveBeenCalled();
|
|
expect(_converse.roster.addAndSubscribe).toHaveBeenCalled();
|
|
expect(_converse.roster.addContact).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
|
|
/* _converse request consists of sending an IQ
|
|
* stanza of type='set' containing a <query/> element qualified by
|
|
* stanza of type='set' containing a <query/> element qualified by
|
|
* the 'jabber:iq:roster' namespace, which in turn contains an
|
|
* the 'jabber:iq:roster' namespace, which in turn contains an
|