Commit 5136b0c1 authored by JC Brand's avatar JC Brand

Fix two failing tests (and a bug)

parent e6ba62d8
...@@ -282,6 +282,7 @@ ...@@ -282,6 +282,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
var IQ_stanzas = _converse.connection.IQ_stanzas;
var sent_IQ, IQ_id; var sent_IQ, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
...@@ -326,11 +327,20 @@ ...@@ -326,11 +327,20 @@
* </iq> * </iq>
*/ */
test_utils.waitUntil(function () { test_utils.waitUntil(function () {
return sent_IQ.toLocaleString() === return _.filter(IQ_stanzas, function (iq) {
"<iq to='lounge@localhost' from='dummy@localhost/resource' "+ return iq.nodeTree.querySelector('query[node="x-roomuser-item"]');
"type='get' xmlns='jabber:client' id='"+IQ_id+"'>"+ }).length > 0;
"<query xmlns='http://jabber.org/protocol/disco#info' node='x-roomuser-item'/></iq>"
}, 300).then(function () { }, 300).then(function () {
const iq = _.filter(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector(`query[node="x-roomuser-item"]`);
}).pop();
const id = iq.nodeTree.getAttribute('id');
expect(iq.toLocaleString()).toBe(
"<iq to='lounge@localhost' from='dummy@localhost/resource' "+
"type='get' xmlns='jabber:client' id='"+id+"'>"+
"<query xmlns='http://jabber.org/protocol/disco#info' node='x-roomuser-item'/></iq>");
/* <iq xmlns="jabber:client" type="error" to="jordie.langen@chat.example.org/converse.js-11659299" from="myroom@conference.chat.example.org"> /* <iq xmlns="jabber:client" type="error" to="jordie.langen@chat.example.org/converse.js-11659299" from="myroom@conference.chat.example.org">
* <error type="cancel"> * <error type="cancel">
* <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/> * <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
...@@ -339,7 +349,7 @@ ...@@ -339,7 +349,7 @@
*/ */
var stanza = $iq({ var stanza = $iq({
'type': 'error', 'type': 'error',
'id': IQ_id, 'id': id,
'from': view.model.get('jid'), 'from': view.model.get('jid'),
'to': _converse.connection.jid 'to': _converse.connection.jid
}).c('error', {'type': 'cancel'}) }).c('error', {'type': 'cancel'})
...@@ -1248,6 +1258,7 @@ ...@@ -1248,6 +1258,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
var IQ_stanzas = _converse.connection.IQ_stanzas;
var sent_IQ, IQ_id; var sent_IQ, IQ_id;
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
...@@ -1284,11 +1295,19 @@ ...@@ -1284,11 +1295,19 @@
*/ */
test_utils.waitUntil(function () { test_utils.waitUntil(function () {
return sent_IQ.toLocaleString() === return _.filter(IQ_stanzas, function (iq) {
"<iq to='lounge@localhost' from='dummy@localhost/resource' "+ return iq.nodeTree.querySelector('query[node="x-roomuser-item"]');
"type='get' xmlns='jabber:client' id='"+IQ_id+"'>"+ }).length > 0;
"<query xmlns='http://jabber.org/protocol/disco#info' node='x-roomuser-item'/></iq>";
}, 300).then(function () { }, 300).then(function () {
const iq = _.filter(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector(`query[node="x-roomuser-item"]`);
}).pop();
const id = iq.nodeTree.getAttribute('id');
expect(iq.toLocaleString()).toBe(
"<iq to='lounge@localhost' from='dummy@localhost/resource' "+
"type='get' xmlns='jabber:client' id='"+id+"'>"+
"<query xmlns='http://jabber.org/protocol/disco#info' node='x-roomuser-item'/></iq>");
/* <iq from='coven@chat.shakespeare.lit' /* <iq from='coven@chat.shakespeare.lit'
* id='getnick1' * id='getnick1'
* to='hag66@shakespeare.lit/pda' * to='hag66@shakespeare.lit/pda'
......
...@@ -449,10 +449,11 @@ ...@@ -449,10 +449,11 @@
* based on the identified message stanza. * based on the identified message stanza.
*/ */
const attrs = this.getMessageAttributesFromStanza.apply(this, arguments) const attrs = this.getMessageAttributesFromStanza.apply(this, arguments)
if (u.isOnlyChatStateNotification(attrs) && attrs.delayed) { const is_csn = u.isOnlyChatStateNotification(attrs);
if (is_csn && attrs.delayed) {
// No need showing old CSNs // No need showing old CSNs
return; return;
} else if (!attrs.file && !attrs.message && !attrs.oob_url && attrs.type !== 'error') { } else if (!is_csn && !attrs.file && !attrs.message && !attrs.oob_url && attrs.type !== 'error') {
// TODO: handle <subject> messages (currently being done by ChatRoom) // TODO: handle <subject> messages (currently being done by ChatRoom)
return; return;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment