Fix failing tests

This commit is contained in:
JC Brand 2017-12-03 12:21:57 +01:00
parent 393bbe020e
commit fc94127014
4 changed files with 469 additions and 404 deletions

View File

@ -10,6 +10,7 @@
} (this, function ($, jasmine, utils, converse, mock, test_utils) {
"use strict";
var _ = converse.env._;
var $iq = converse.env.$iq;
var $msg = converse.env.$msg;
var Strophe = converse.env.Strophe;
var moment = converse.env.moment;
@ -22,6 +23,12 @@
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp')
.then(function () {
return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname');
}, 300);
}).then(function () {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
@ -46,6 +53,7 @@
expect(_.includes(view.$el.find('.chat-msg-author:last').text(), '**Max Mustermann')).toBeTruthy();
expect(view.$el.find('.chat-msg-content:last').text()).toBe(' is as well');
done();
});
}));
it("is created when you click on a roster item",
@ -527,7 +535,8 @@
describe("A Chat Message", function () {
describe("when received from someone else", function () {
it("can be received which will open a chatbox and be displayed inside it",
it("will open a chatbox and be displayed inside it",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
@ -953,6 +962,13 @@
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
var contact, sent_stanza, IQ_id, stanza;
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp')
.then(function () {
return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname');
}, 300);
}).then(function () {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
@ -994,6 +1010,7 @@
var msg_txt = $chat_content.find('.chat-message').find('.chat-msg-content').text();
expect(msg_txt).toEqual(msgtext);
done();
});
}));
it("will be discarded if it's a malicious message meant to look like a carbon copy",
@ -1561,8 +1578,14 @@
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
var contact, sent_stanza, IQ_id, stanza;
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp')
.then(function () {
return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname');
}, 300);
}).then(function () {
test_utils.createContacts(_converse, 'current');
// Send a message from a different resource
spyOn(_converse, 'log');
var recipient_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@localhost';
@ -1596,6 +1619,7 @@
var status_text = $chat_content.find('.chat-info.chat-event').text();
expect(status_text).toBe('Typing from another device');
done();
});
}));
});
@ -1702,8 +1726,14 @@
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
var contact, sent_stanza, IQ_id, stanza;
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp')
.then(function () {
return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname');
}, 300);
}).then(function () {
test_utils.createContacts(_converse, 'current');
// Send a message from a different resource
spyOn(_converse, 'log');
var recipient_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@localhost';
@ -1737,6 +1767,7 @@
var status_text = $chat_content.find('.chat-info.chat-event').text();
expect(status_text).toBe('Stopped typing on the other device');
done();
});
}));
});

View File

@ -546,8 +546,16 @@
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp')
.then(function () {
return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname');
}, 300);
}).then(function () {
test_utils.createContacts(_converse, 'current');
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
return test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
}).then(function () {
var view = _converse.chatboxviews.get('lounge@localhost');
if (!view.$el.find('.chat-area').length) { view.renderChatArea(); }
var message = '/me is tired';

View File

@ -54,10 +54,16 @@
{ roster_groups: false },
function (done, _converse) {
var contact, sent_stanza, IQ_id, stanza;
test_utils.waitUntilFeatureSupportConfirmed(_converse, 'vcard-temp')
.then(function () {
return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname');
}, 300);
}).then(function () {
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
*/
var contact, stanza, sent_stanza, IQ_id;
test_utils.openControlBox(_converse);
var panel = _converse.chatboxviews.get('controlbox').contactspanel;
spyOn(panel, "addContactFromForm").and.callThrough();
@ -65,6 +71,7 @@
spyOn(_converse.roster, "addContact").and.callThrough();
spyOn(_converse.roster, "sendContactAddIQ").and.callThrough();
spyOn(_converse.api.vcard, "get").and.callThrough();
var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq;
@ -180,11 +187,10 @@
*
* <presence to='contact@example.org' type='subscribe'/>
*/
test_utils.waitUntil(function () {
return test_utils.waitUntil(function () {
return sent_stanzas.length == 1;
}, 300).then(function () {
}, 300);
}).then(function () {
expect(contact.subscribe).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec)
"<presence to='contact@example.org' type='subscribe' xmlns='jabber:client'>"+
@ -222,10 +228,11 @@
expect(_converse.roster.updateContact).toHaveBeenCalled();
// Check that the user is now properly shown as a pending
// contact in the roster.
test_utils.waitUntil(function () {
return $('a:contains("Pending contacts")').length;
}, 300).then(function () {
return test_utils.waitUntil(function () {
return $('a:contains("Pending contacts")').length;
}, 300);
}).then(function () {
var $header = $('a:contains("Pending contacts")');
expect($header.length).toBe(1);
expect($header.is(":visible")).toBeTruthy();
@ -368,7 +375,6 @@
expect($contacts.hasClass('both')).toBeTruthy();
done();
});
});
}));
it("Alternate Flow: Contact Declines Subscription Request",
@ -403,7 +409,7 @@
/* We now assume the contact declines the subscription
* requests.
*
/* Upon receiving the presence stanza of type "unsubscribed"
* Upon receiving the presence stanza of type "unsubscribed"
* addressed to the user, the user's server (1) MUST deliver
* that presence stanza to the user and (2) MUST initiate a
* roster push to all of the user's available resources that

View File

@ -11,7 +11,27 @@
if (typeof window.Promise === 'undefined') {
waitUntilPromise.setPromiseImplementation(Promise);
}
utils.waitUntil = waitUntilPromise['default'];
utils.waitUntil = waitUntilPromise.default;
utils.waitUntilFeatureSupportConfirmed = function (_converse, feature_name) {
var IQ_disco, stanza;
return utils.waitUntil(function () {
IQ_disco = _.filter(_converse.connection.IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector('query[xmlns="http://jabber.org/protocol/disco#info"]');
}).pop();
return !_.isUndefined(IQ_disco);
}, 300).then(function () {
var info_IQ_id = IQ_disco.nodeTree.getAttribute('id');
stanza = $iq({
'type': 'result',
'from': 'localhost',
'to': 'dummy@localhost/resource',
'id': info_IQ_id
}).c('query', {'xmlns': 'http://jabber.org/protocol/disco#info'})
.c('feature', {'var': feature_name});
_converse.connection._dataRecv(utils.createRequest(stanza));
});
}
utils.createRequest = function (iq) {
iq = typeof iq.tree == "function" ? iq.tree() : iq;