Commit a95bb5b2 authored by JC Brand's avatar JC Brand

Refactor tests so that IQ_ids always contains only XML stanzas

parent 7e515dd4
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
$msg = converse.env.$msg, $msg = converse.env.$msg,
$iq = converse.env.$iq, $iq = converse.env.$iq,
u = converse.env.utils, u = converse.env.utils,
Strophe = converse.env.Strophe; Strophe = converse.env.Strophe,
sizzle = converse.env.sizzle;
describe("The Controlbox", function () { describe("The Controlbox", function () {
...@@ -232,22 +233,21 @@ ...@@ -232,22 +233,21 @@
expect(modal.name_auto_complete).toBe(undefined); expect(modal.name_auto_complete).toBe(undefined);
await test_utils.waitUntil(() => u.isVisible(modal.el), 1000); await test_utils.waitUntil(() => u.isVisible(modal.el), 1000);
const sendIQ = _converse.connection.sendIQ;
let sent_stanza;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq;
sendIQ.bind(this)(iq, callback, errback);
});
expect(!_.isNull(modal.el.querySelector('form.add-xmpp-contact'))).toBeTruthy(); expect(!_.isNull(modal.el.querySelector('form.add-xmpp-contact'))).toBeTruthy();
const input_jid = modal.el.querySelector('input[name="jid"]'); const input_jid = modal.el.querySelector('input[name="jid"]');
const input_name = modal.el.querySelector('input[name="name"]'); const input_name = modal.el.querySelector('input[name="name"]');
input_jid.value = 'someone@localhost'; input_jid.value = 'someone@localhost';
modal.el.querySelector('button[type="submit"]').click(); modal.el.querySelector('button[type="submit"]').click();
await test_utils.waitUntil(() => sent_stanza.nodeTree.matches('iq'));
expect(sent_stanza.toLocaleString()).toEqual( const IQ_stanzas = _converse.connection.IQ_stanzas;
`<iq id="${sent_stanza.nodeTree.getAttribute('id')}" type="set" xmlns="jabber:client">`+ const sent_stanza = await test_utils.waitUntil(
() => IQ_stanzas.filter(s => sizzle(`query[xmlns="${Strophe.NS.ROSTER}"]`, s).length).pop()
);
expect(Strophe.serialize(sent_stanza)).toEqual(
`<iq id="${sent_stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:roster"><item jid="someone@localhost"/></query>`+ `<query xmlns="jabber:iq:roster"><item jid="someone@localhost"/></query>`+
`</iq>`); `</iq>`
);
done(); done();
})); }));
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
const IQ_ids = _converse.connection.IQ_ids; const IQ_ids = _converse.connection.IQ_ids;
test_utils.waitUntil(function () { test_utils.waitUntil(function () {
return _.filter(IQ_stanzas, function (iq) { return _.filter(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); return iq.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]');
}).length > 0; }).length > 0;
}, 300).then(function () { }, 300).then(function () {
/* <iq type='result' /* <iq type='result'
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
* </iq> * </iq>
*/ */
var stanza = _.find(IQ_stanzas, function (iq) { var stanza = _.find(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); return iq.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]');
}); });
var info_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)]; var info_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)];
stanza = $iq({ stanza = $iq({
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
// Converse.js sees that the entity has a disco#items feature, // Converse.js sees that the entity has a disco#items feature,
// so it will make a query for it. // so it will make a query for it.
return _.filter(IQ_stanzas, function (iq) { return _.filter(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector('query[xmlns="http://jabber.org/protocol/disco#items"]'); return iq.querySelector('query[xmlns="http://jabber.org/protocol/disco#items"]');
}).length > 0; }).length > 0;
}, 300).then(function () { }, 300).then(function () {
/* <iq type='result' /* <iq type='result'
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
* </iq> * </iq>
*/ */
var stanza = _.find(IQ_stanzas, function (iq) { var stanza = _.find(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]'); return iq.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]');
}); });
var items_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)]; var items_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)];
stanza = $iq({ stanza = $iq({
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -29,11 +29,10 @@ ...@@ -29,11 +29,10 @@
_converse.bare_jid, _converse.bare_jid,
[{'category': 'account', 'type':'registered'}], [{'category': 'account', 'type':'registered'}],
['urn:xmpp:push:0'], [], 'info'); ['urn:xmpp:push:0'], [], 'info');
const node = await test_utils.waitUntil(() => const stanza = await test_utils.waitUntil(() =>
_.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop() _.filter(IQ_stanzas, iq => iq.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop()
); );
const stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toEqual(
expect(node.toLocaleString()).toEqual(
`<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+ `<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
'<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+ '<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+
'</iq>' '</iq>'
...@@ -71,17 +70,17 @@ ...@@ -71,17 +70,17 @@
[{'category': 'account', 'type':'registered'}], [{'category': 'account', 'type':'registered'}],
['urn:xmpp:push:0'], [], 'info'); ['urn:xmpp:push:0'], [], 'info');
const stanza = await test_utils.waitUntil( const stanza = await test_utils.waitUntil(
() => _.filter(IQ_stanzas, (iq) => iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop() () => _.filter(IQ_stanzas, (iq) => iq.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop()
); );
expect(stanza.toLocaleString()).toEqual( expect(Strophe.serialize(stanza)).toEqual(
`<iq id="${stanza.nodeTree.getAttribute('id')}" to="chat.shakespeare.lit" type="set" xmlns="jabber:client">`+ `<iq id="${stanza.getAttribute('id')}" to="chat.shakespeare.lit" type="set" xmlns="jabber:client">`+
'<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+ '<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+
'</iq>' '</iq>'
); );
_converse.connection._dataRecv(test_utils.createRequest($iq({ _converse.connection._dataRecv(test_utils.createRequest($iq({
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'result', 'type': 'result',
'id': stanza.nodeTree.getAttribute('id') 'id': stanza.getAttribute('id')
}))); })));
await test_utils.waitUntil(() => _.includes(_converse.session.get('push_enabled'), 'chat.shakespeare.lit')); await test_utils.waitUntil(() => _.includes(_converse.session.get('push_enabled'), 'chat.shakespeare.lit'));
done(); done();
...@@ -105,11 +104,10 @@ ...@@ -105,11 +104,10 @@
_converse.bare_jid, _converse.bare_jid,
[{'category': 'account', 'type':'registered'}], [{'category': 'account', 'type':'registered'}],
['urn:xmpp:push:0'], [], 'info'); ['urn:xmpp:push:0'], [], 'info');
const node = await test_utils.waitUntil( const stanza = await test_utils.waitUntil(
() => _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq[type="set"] disable[xmlns="urn:xmpp:push:0"]')).pop() () => _.filter(IQ_stanzas, iq => iq.querySelector('iq[type="set"] disable[xmlns="urn:xmpp:push:0"]')).pop()
); );
const stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toEqual(
expect(node.toLocaleString()).toEqual(
`<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+ `<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
'<disable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+ '<disable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>'+
'</iq>' '</iq>'
...@@ -147,11 +145,10 @@ ...@@ -147,11 +145,10 @@
[{'category': 'account', 'type':'registered'}], [{'category': 'account', 'type':'registered'}],
['urn:xmpp:push:0'], [], 'info'); ['urn:xmpp:push:0'], [], 'info');
const node = await test_utils.waitUntil( const stanza = await test_utils.waitUntil(
() => _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop() () => _.filter(IQ_stanzas, iq => iq.querySelector('iq[type="set"] enable[xmlns="urn:xmpp:push:0"]')).pop()
); );
const stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toEqual(
expect(node.toLocaleString()).toEqual(
`<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+ `<iq id="${stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
'<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0">'+ '<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0">'+
'<x type="submit" xmlns="jabber:x:data">'+ '<x type="submit" xmlns="jabber:x:data">'+
......
...@@ -32,11 +32,10 @@ ...@@ -32,11 +32,10 @@
}); });
return test_utils.waitUntil(() => _.filter( return test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq).length
).pop()); ).pop());
}).then(node => { }).then(stanza => {
const stanza = node.nodeTree; expect(Strophe.serialize(stanza))
expect(node.toLocaleString())
.toBe(`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" `+ .toBe(`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" `+
`type="get" xmlns="jabber:client">`+ `type="get" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:register"/></iq>`); `<query xmlns="jabber:iq:register"/></iq>`);
...@@ -56,11 +55,10 @@ ...@@ -56,11 +55,10 @@
_converse.connection._dataRecv(test_utils.createRequest(result)); _converse.connection._dataRecv(test_utils.createRequest(result));
return test_utils.waitUntil(() => _.filter( return test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq).length
).pop()); ).pop());
}).then(node => { }).then(stanza => {
const stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+ `<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:register">`+ `<query xmlns="jabber:iq:register">`+
`<x type="submit" xmlns="jabber:x:data">`+ `<x type="submit" xmlns="jabber:x:data">`+
...@@ -87,11 +85,11 @@ ...@@ -87,11 +85,11 @@
const room_jid = 'coven@chat.shakespeare.lit'; const room_jid = 'coven@chat.shakespeare.lit';
_converse.api.rooms.open(room_jid, {'nick': 'romeo'}) _converse.api.rooms.open(room_jid, {'nick': 'romeo'})
.then(() => { .then(() => {
return test_utils.waitUntil(() => _.get(_.filter( return test_utils.waitUntil(() => _.filter(
IQ_stanzas, IQ_stanzas,
iq => iq.nodeTree.querySelector( iq => iq.querySelector(
`iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]` `iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).pop(), 'nodeTree')); )).pop());
}).then(stanza => { }).then(stanza => {
const features_stanza = $iq({ const features_stanza = $iq({
'from': room_jid, 'from': room_jid,
...@@ -127,11 +125,10 @@ ...@@ -127,11 +125,10 @@
_converse.connection._dataRecv(test_utils.createRequest(presence)); _converse.connection._dataRecv(test_utils.createRequest(presence));
return test_utils.waitUntil(() => _.filter( return test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq).length
).pop()); ).pop());
}).then(node => { }).then(stanza => {
const stanza = node.nodeTree; expect(Strophe.serialize(stanza))
expect(node.toLocaleString())
.toBe(`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" `+ .toBe(`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" `+
`type="get" xmlns="jabber:client">`+ `type="get" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:register"/></iq>`); `<query xmlns="jabber:iq:register"/></iq>`);
...@@ -151,11 +148,10 @@ ...@@ -151,11 +148,10 @@
_converse.connection._dataRecv(test_utils.createRequest(result)); _converse.connection._dataRecv(test_utils.createRequest(result));
return test_utils.waitUntil(() => _.filter( return test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq).length
).pop()); ).pop());
}).then(node => { }).then(stanza => {
const stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+ `<iq from="dummy@localhost/resource" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:register">`+ `<query xmlns="jabber:iq:register">`+
`<x type="submit" xmlns="jabber:x:data">`+ `<x type="submit" xmlns="jabber:x:data">`+
......
...@@ -153,11 +153,11 @@ ...@@ -153,11 +153,11 @@
const room_jid = 'coven@chat.shakespeare.lit'; const room_jid = 'coven@chat.shakespeare.lit';
test_utils.openControlBox(); test_utils.openControlBox();
await _converse.api.rooms.open(room_jid, {'nick': 'some1'}); await _converse.api.rooms.open(room_jid, {'nick': 'some1'});
const last_stanza = await test_utils.waitUntil(() => _.get(_.filter( const last_stanza = await test_utils.waitUntil(() => _.filter(
IQ_stanzas, IQ_stanzas,
iq => iq.nodeTree.querySelector( iq => iq.querySelector(
`iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]` `iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).pop(), 'nodeTree')); )).pop());
const view = _converse.chatboxviews.get(room_jid); const view = _converse.chatboxviews.get(room_jid);
const IQ_id = last_stanza.getAttribute('id'); const IQ_id = last_stanza.getAttribute('id');
const features_stanza = $iq({ const features_stanza = $iq({
......
...@@ -37,18 +37,18 @@ ...@@ -37,18 +37,18 @@
spyOn(_converse.api, "trigger").and.callThrough(); spyOn(_converse.api, "trigger").and.callThrough();
const IQs = _converse.connection.IQ_stanzas; const IQs = _converse.connection.IQ_stanzas;
const node = await test_utils.waitUntil( const stanza = await test_utils.waitUntil(
() => _.filter(IQs, iq => iq.nodeTree.querySelector('iq query[xmlns="jabber:iq:roster"]')).pop()); () => _.filter(IQs, iq => iq.querySelector('iq query[xmlns="jabber:iq:roster"]')).pop());
expect(_converse.api.trigger.calls.all().map(c => c.args[0]).includes('rosterContactsFetched')).toBeFalsy(); expect(_converse.api.trigger.calls.all().map(c => c.args[0]).includes('rosterContactsFetched')).toBeFalsy();
expect(node.toLocaleString()).toBe( expect(Strophe.serialize(stanza)).toBe(
`<iq id="${node.nodeTree.getAttribute('id')}" type="get" xmlns="jabber:client">`+ `<iq id="${stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:roster"/>`+ `<query xmlns="jabber:iq:roster"/>`+
`</iq>`); `</iq>`);
const result = $iq({ const result = $iq({
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'result', 'type': 'result',
'id': node.nodeTree.getAttribute('id') 'id': stanza.getAttribute('id')
}).c('query', { }).c('query', {
'xmlns': 'jabber:iq:roster' 'xmlns': 'jabber:iq:roster'
}).c('item', {'jid': 'nurse@example.com'}).up() }).c('item', {'jid': 'nurse@example.com'}).up()
...@@ -64,12 +64,11 @@ ...@@ -64,12 +64,11 @@
async function (done, _converse) { async function (done, _converse) {
const IQ_stanzas = _converse.connection.IQ_stanzas; const IQ_stanzas = _converse.connection.IQ_stanzas;
let node = await test_utils.waitUntil( let stanza = await test_utils.waitUntil(
() => _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq query[xmlns="jabber:iq:roster"]')).pop() () => _.filter(IQ_stanzas, iq => iq.querySelector('iq query[xmlns="jabber:iq:roster"]')).pop()
); );
let stanza = node.nodeTree;
expect(_converse.roster.data.get('version')).toBeUndefined(); expect(_converse.roster.data.get('version')).toBeUndefined();
expect(node.toLocaleString()).toBe( expect(Strophe.serialize(stanza)).toBe(
`<iq id="${stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+ `<iq id="${stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
`<query xmlns="jabber:iq:roster"/>`+ `<query xmlns="jabber:iq:roster"/>`+
`</iq>`); `</iq>`);
...@@ -89,9 +88,8 @@ ...@@ -89,9 +88,8 @@
expect(_converse.roster.models.length).toBe(2); expect(_converse.roster.models.length).toBe(2);
_converse.roster.fetchFromServer(); _converse.roster.fetchFromServer();
node = _converse.connection.IQ_stanzas.pop(); stanza = _converse.connection.IQ_stanzas.pop();
stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq id="${stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+ `<iq id="${stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
`<query ver="ver7" xmlns="jabber:iq:roster"/>`+ `<query ver="ver7" xmlns="jabber:iq:roster"/>`+
`</iq>`); `</iq>`);
......
...@@ -117,6 +117,9 @@ ...@@ -117,6 +117,9 @@
c.IQ_stanzas = []; c.IQ_stanzas = [];
c.IQ_ids = []; c.IQ_ids = [];
c.sendIQ = function (iq, callback, errback) { c.sendIQ = function (iq, callback, errback) {
if (!_.isElement(iq)) {
iq = iq.nodeTree;
}
this.IQ_stanzas.push(iq); this.IQ_stanzas.push(iq);
const id = sendIQ.bind(this)(iq, callback, errback); const id = sendIQ.bind(this)(iq, callback, errback);
this.IQ_ids.push(id); this.IQ_ids.push(id);
......
...@@ -19,14 +19,14 @@ ...@@ -19,14 +19,14 @@
const iq = await utils.waitUntil(() => { const iq = await utils.waitUntil(() => {
return _.filter( return _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
(iq) => sizzle(`iq[to="${entity_jid}"] query[xmlns="http://jabber.org/protocol/disco#${type}"]`, iq.nodeTree).length (iq) => sizzle(`iq[to="${entity_jid}"] query[xmlns="http://jabber.org/protocol/disco#${type}"]`, iq).length
).pop(); ).pop();
}, 300); }, 300);
const stanza = $iq({ const stanza = $iq({
'type': 'result', 'type': 'result',
'from': entity_jid, 'from': entity_jid,
'to': 'dummy@localhost/resource', 'to': 'dummy@localhost/resource',
'id': iq.nodeTree.getAttribute('id'), 'id': iq.getAttribute('id'),
}).c('query', {'xmlns': 'http://jabber.org/protocol/disco#'+type}); }).c('query', {'xmlns': 'http://jabber.org/protocol/disco#'+type});
_.forEach(identities, function (identity) { _.forEach(identities, function (identity) {
...@@ -123,11 +123,11 @@ ...@@ -123,11 +123,11 @@
const stanzas = _converse.connection.IQ_stanzas; const stanzas = _converse.connection.IQ_stanzas;
await _converse.api.rooms.open(room_jid); await _converse.api.rooms.open(room_jid);
const view = _converse.chatboxviews.get(room_jid); const view = _converse.chatboxviews.get(room_jid);
let stanza = await utils.waitUntil(() => _.get(_.filter( let stanza = await utils.waitUntil(() => _.filter(
stanzas, stanzas,
iq => iq.nodeTree.querySelector( iq => iq.querySelector(
`iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]` `iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).pop(), 'nodeTree')); )).pop());
const features_stanza = $iq({ const features_stanza = $iq({
'from': room_jid, 'from': room_jid,
...@@ -164,14 +164,14 @@ ...@@ -164,14 +164,14 @@
const iq = await utils.waitUntil(() => _.filter( const iq = await utils.waitUntil(() => _.filter(
stanzas, stanzas,
s => sizzle(`iq[to="${room_jid}"] query[node="x-roomuser-item"]`, s.nodeTree).length s => sizzle(`iq[to="${room_jid}"] query[node="x-roomuser-item"]`, s).length
).pop()); ).pop());
// We remove the stanza, otherwise we might get stale stanzas returned in our filter above. // We remove the stanza, otherwise we might get stale stanzas returned in our filter above.
stanzas.splice(stanzas.indexOf(iq), 1) stanzas.splice(stanzas.indexOf(iq), 1)
// The XMPP server returns the reserved nick for this user. // The XMPP server returns the reserved nick for this user.
const IQ_id = iq.nodeTree.getAttribute('id'); const IQ_id = iq.getAttribute('id');
stanza = $iq({ stanza = $iq({
'type': 'result', 'type': 'result',
'id': IQ_id, 'id': IQ_id,
...@@ -266,13 +266,13 @@ ...@@ -266,13 +266,13 @@
const iq = await utils.waitUntil(() => const iq = await utils.waitUntil(() =>
_.filter( _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => sizzle(`iq[type="get"] query[xmlns="${Strophe.NS.ROSTER}"]`, iq.nodeTree).length iq => sizzle(`iq[type="get"] query[xmlns="${Strophe.NS.ROSTER}"]`, iq).length
).pop()); ).pop());
const result = $iq({ const result = $iq({
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'result', 'type': 'result',
'id': iq.nodeTree.getAttribute('id') 'id': iq.getAttribute('id')
}).c('query', { }).c('query', {
'xmlns': 'jabber:iq:roster' 'xmlns': 'jabber:iq:roster'
}); });
......
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