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,27 +233,26 @@ ...@@ -232,27 +233,26 @@
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(
`<query xmlns="jabber:iq:roster"><item jid="someone@localhost"/></query>`+ () => IQ_stanzas.filter(s => sizzle(`query[xmlns="${Strophe.NS.ROSTER}"]`, s).length).pop()
`</iq>`); );
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>`+
`</iq>`
);
done(); done();
})); }));
it("integrates with xhr_user_search_url to search for contacts", it("integrates with xhr_user_search_url to search for contacts",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched'], null, ['rosterGroupsFetched'],
{ 'xhr_user_search_url': 'http://example.org/?' }, { 'xhr_user_search_url': 'http://example.org/?' },
......
...@@ -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({
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
await test_utils.waitUntilDiscoConfirmed(_converse, _converse.bare_jid, [], []); await test_utils.waitUntilDiscoConfirmed(_converse, _converse.bare_jid, [], []);
await test_utils.waitUntil(() => _.filter( await test_utils.waitUntil(() => _.filter(
IQ_stanzas, IQ_stanzas,
iq => iq.nodeTree.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]')).length iq => iq.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]')).length
); );
/* <iq type='result' /* <iq type='result'
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
* </iq> * </iq>
*/ */
let stanza = _.find(IQ_stanzas, function (iq) { let stanza = _.find(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector( return iq.querySelector(
'iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); 'iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]');
}); });
const info_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)]; const info_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)];
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
// so it will make a query for it. // so it will make a query for it.
await test_utils.waitUntil(() => _.filter( await test_utils.waitUntil(() => _.filter(
IQ_stanzas, IQ_stanzas,
iq => iq.nodeTree.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]') iq => iq.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]')
).length ).length
); );
/* <iq from='montague.tld' /* <iq from='montague.tld'
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
* </iq> * </iq>
*/ */
stanza = _.find(IQ_stanzas, function (iq) { 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"]');
}); });
const items_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)]; const items_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)];
stanza = $iq({ stanza = $iq({
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
// Converse.js sees that the entity has a disco#info feature, // Converse.js sees that the entity has a disco#info 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('iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); return iq.querySelector('iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]');
}).length > 0; }).length > 0;
}, 300); }, 300);
}); });
...@@ -113,12 +113,12 @@ ...@@ -113,12 +113,12 @@
stanza = await test_utils.waitUntil(() => stanza = await test_utils.waitUntil(() =>
_.filter( _.filter(
IQ_stanzas, IQ_stanzas,
iq => iq.nodeTree.querySelector('iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]') iq => iq.querySelector('iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]')
).pop() ).pop()
); );
const IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)]; const IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)];
expect(stanza.toLocaleString()).toBe( expect(Strophe.serialize(stanza)).toBe(
`<iq from="dummy@localhost/resource" id="`+IQ_id+`" to="upload.localhost" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost/resource" id="`+IQ_id+`" to="upload.localhost" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`+ `<query xmlns="http://jabber.org/protocol/disco#info"/>`+
`</iq>`); `</iq>`);
...@@ -274,11 +274,11 @@ ...@@ -274,11 +274,11 @@
view.model.sendFiles([file]); view.model.sendFiles([file]);
await new Promise((resolve, reject) => view.once('messageInserted', resolve)); await new Promise((resolve, reject) => view.once('messageInserted', resolve));
await test_utils.waitUntil(() => _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq[to="upload.montague.tld"] request')).length); await test_utils.waitUntil(() => _.filter(IQ_stanzas, iq => iq.querySelector('iq[to="upload.montague.tld"] request')).length);
const iq = IQ_stanzas.pop(); const iq = IQ_stanzas.pop();
expect(iq.toLocaleString()).toBe( expect(Strophe.serialize(iq)).toBe(
`<iq from="dummy@localhost/resource" `+ `<iq from="dummy@localhost/resource" `+
`id="${iq.nodeTree.getAttribute("id")}" `+ `id="${iq.getAttribute("id")}" `+
`to="upload.montague.tld" `+ `to="upload.montague.tld" `+
`type="get" `+ `type="get" `+
`xmlns="jabber:client">`+ `xmlns="jabber:client">`+
...@@ -293,7 +293,7 @@ ...@@ -293,7 +293,7 @@
const stanza = u.toStanza(` const stanza = u.toStanza(`
<iq from="upload.montague.tld" <iq from="upload.montague.tld"
id="${iq.nodeTree.getAttribute("id")}" id="${iq.getAttribute("id")}"
to="dummy@localhost/resource" to="dummy@localhost/resource"
type="result"> type="result">
<slot xmlns="urn:xmpp:http:upload:0"> <slot xmlns="urn:xmpp:http:upload:0">
...@@ -381,11 +381,11 @@ ...@@ -381,11 +381,11 @@
view.model.sendFiles([file]); view.model.sendFiles([file]);
await new Promise((resolve, reject) => view.once('messageInserted', resolve)); await new Promise((resolve, reject) => view.once('messageInserted', resolve));
await test_utils.waitUntil(() => _.filter(IQ_stanzas, iq => iq.nodeTree.querySelector('iq[to="upload.montague.tld"] request')).length); await test_utils.waitUntil(() => _.filter(IQ_stanzas, iq => iq.querySelector('iq[to="upload.montague.tld"] request')).length);
const iq = IQ_stanzas.pop(); const iq = IQ_stanzas.pop();
expect(iq.toLocaleString()).toBe( expect(Strophe.serialize(iq)).toBe(
`<iq from="dummy@localhost/resource" `+ `<iq from="dummy@localhost/resource" `+
`id="${iq.nodeTree.getAttribute("id")}" `+ `id="${iq.getAttribute("id")}" `+
`to="upload.montague.tld" `+ `to="upload.montague.tld" `+
`type="get" `+ `type="get" `+
`xmlns="jabber:client">`+ `xmlns="jabber:client">`+
...@@ -399,7 +399,7 @@ ...@@ -399,7 +399,7 @@
const message = base_url+"/logo/conversejs-filled.svg"; const message = base_url+"/logo/conversejs-filled.svg";
const stanza = u.toStanza(` const stanza = u.toStanza(`
<iq from='upload.montague.tld' <iq from='upload.montague.tld'
id="${iq.nodeTree.getAttribute('id')}" id="${iq.getAttribute('id')}"
to='dummy@localhost/resource' to='dummy@localhost/resource'
type='result'> type='result'>
<slot xmlns='urn:xmpp:http:upload:0'> <slot xmlns='urn:xmpp:http:upload:0'>
...@@ -466,15 +466,14 @@ ...@@ -466,15 +466,14 @@
await test_utils.waitUntilDiscoConfirmed(_converse, _converse.bare_jid, [], []); await test_utils.waitUntilDiscoConfirmed(_converse, _converse.bare_jid, [], []);
await test_utils.waitUntil(() => _.filter( await test_utils.waitUntil(() => _.filter(
IQ_stanzas, IQ_stanzas,
iq => iq.nodeTree.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]')).length iq => iq.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]')).length
); );
var stanza = _.find(IQ_stanzas, function (iq) { let stanza = _.find(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector( return iq.querySelector(
'iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); 'iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]');
}); });
var info_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)]; const info_IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)];
stanza = $iq({ stanza = $iq({
'type': 'result', 'type': 'result',
'from': 'localhost', 'from': 'localhost',
...@@ -502,12 +501,12 @@ ...@@ -502,12 +501,12 @@
// 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('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"]');
}).length > 0; }).length > 0;
}, 300); }, 300);
stanza = _.find(IQ_stanzas, function (iq) { 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({
...@@ -530,15 +529,13 @@ ...@@ -530,15 +529,13 @@
// Converse.js sees that the entity has a disco#info feature, // Converse.js sees that the entity has a disco#info 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('iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); return iq.querySelector('iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]');
}).length > 0; }).length > 0;
}, 300); }, 300);
stanza = _.find(IQ_stanzas, function (iq) { stanza = _.find(IQ_stanzas, iq => iq.querySelector('iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'));
return iq.nodeTree.querySelector('iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); const IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)];
}); expect(Strophe.serialize(stanza)).toBe(
var IQ_id = IQ_ids[IQ_stanzas.indexOf(stanza)];
expect(stanza.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${IQ_id}" to="upload.localhost" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost/resource" id="${IQ_id}" to="upload.localhost" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`+ `<query xmlns="http://jabber.org/protocol/disco#info"/>`+
`</iq>`); `</iq>`);
...@@ -609,11 +606,11 @@ ...@@ -609,11 +606,11 @@
}; };
view.model.sendFiles([file]); view.model.sendFiles([file]);
await new Promise((resolve, reject) => view.once('messageInserted', resolve)); await new Promise((resolve, reject) => view.once('messageInserted', resolve));
await test_utils.waitUntil(() => _.filter(IQ_stanzas, (iq) => iq.nodeTree.querySelector('iq[to="upload.montague.tld"] request')).length) await test_utils.waitUntil(() => _.filter(IQ_stanzas, iq => iq.querySelector('iq[to="upload.montague.tld"] request')).length)
const iq = IQ_stanzas.pop(); const iq = IQ_stanzas.pop();
expect(iq.toLocaleString()).toBe( expect(Strophe.serialize(iq)).toBe(
`<iq from="dummy@localhost/resource" `+ `<iq from="dummy@localhost/resource" `+
`id="${iq.nodeTree.getAttribute("id")}" `+ `id="${iq.getAttribute("id")}" `+
`to="upload.montague.tld" `+ `to="upload.montague.tld" `+
`type="get" `+ `type="get" `+
`xmlns="jabber:client">`+ `xmlns="jabber:client">`+
...@@ -628,7 +625,7 @@ ...@@ -628,7 +625,7 @@
const message = base_url+"/logo/conversejs-filled.svg"; const message = base_url+"/logo/conversejs-filled.svg";
const stanza = u.toStanza(` const stanza = u.toStanza(`
<iq from="upload.montague.tld" <iq from="upload.montague.tld"
id="${iq.nodeTree.getAttribute("id")}" id="${iq.getAttribute("id")}"
to="dummy@localhost/resource" to="dummy@localhost/resource"
type="result"> type="result">
<slot xmlns="urn:xmpp:http:upload:0"> <slot xmlns="urn:xmpp:http:upload:0">
......
...@@ -281,11 +281,11 @@ ...@@ -281,11 +281,11 @@
} }
}); });
await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy'); await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
let stanza = await test_utils.waitUntil(() => _.get(_.filter( let 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());
// We pretend this is a new room, so no disco info is returned. // We pretend this is a new room, so no disco info is returned.
/* <iq from="jordie.langen@chat.example.org/converse.js-11659299" to="myroom@conference.chat.example.org" type="get"> /* <iq from="jordie.langen@chat.example.org/converse.js-11659299" to="myroom@conference.chat.example.org" type="get">
...@@ -316,13 +316,12 @@ ...@@ -316,13 +316,12 @@
* node="x-roomuser-item"/> * node="x-roomuser-item"/>
* </iq> * </iq>
*/ */
const node = await test_utils.waitUntil(() => _.filter( stanza = await test_utils.waitUntil(() => _.filter(
IQ_stanzas, IQ_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()
); );
stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${stanza.getAttribute("id")}" to="lounge@localhost" `+ `<iq from="dummy@localhost/resource" id="${stanza.getAttribute("id")}" to="lounge@localhost" `+
`type="get" xmlns="jabber:client">`+ `type="get" xmlns="jabber:client">`+
`<query node="x-roomuser-item" xmlns="http://jabber.org/protocol/disco#info"/></iq>`); `<query node="x-roomuser-item" xmlns="http://jabber.org/protocol/disco#info"/></iq>`);
...@@ -1734,13 +1733,12 @@ ...@@ -1734,13 +1733,12 @@
await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy'); await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
let stanza = await test_utils.waitUntil(() => _.get(_.filter( let 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()
); );
// We pretend this is a new room, so no disco info is returned. // We pretend this is a new room, so no disco info is returned.
const features_stanza = $iq({ const features_stanza = $iq({
from: 'lounge@localhost', from: 'lounge@localhost',
...@@ -1762,13 +1760,12 @@ ...@@ -1762,13 +1760,12 @@
* node='x-roomuser-item'/> * node='x-roomuser-item'/>
* </iq> * </iq>
*/ */
const node = await test_utils.waitUntil(() => _.filter( const iq = await test_utils.waitUntil(() => _.filter(
IQ_stanzas, IQ_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()
); );
const iq = node.nodeTree; expect(Strophe.serialize(iq)).toBe(
expect(node.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${iq.getAttribute('id')}" to="lounge@localhost" `+ `<iq from="dummy@localhost/resource" id="${iq.getAttribute('id')}" to="lounge@localhost" `+
`type="get" xmlns="jabber:client">`+ `type="get" xmlns="jabber:client">`+
`<query node="x-roomuser-item" xmlns="http://jabber.org/protocol/disco#info"/></iq>`); `<query node="x-roomuser-item" xmlns="http://jabber.org/protocol/disco#info"/></iq>`);
...@@ -1788,7 +1785,7 @@ ...@@ -1788,7 +1785,7 @@
*/ */
stanza = $iq({ stanza = $iq({
'type': 'result', 'type': 'result',
'id': node.nodeTree.getAttribute('id'), 'id': iq.getAttribute('id'),
'from': view.model.get('jid'), 'from': view.model.get('jid'),
'to': _converse.connection.jid 'to': _converse.connection.jid
}).c('query', {'xmlns': 'http://jabber.org/protocol/disco#info', 'node': 'x-roomuser-item'}) }).c('query', {'xmlns': 'http://jabber.org/protocol/disco#info', 'node': 'x-roomuser-item'})
...@@ -1863,9 +1860,7 @@ ...@@ -1863,9 +1860,7 @@
input.dispatchEvent(evt); input.dispatchEvent(evt);
let sent_stanza; let sent_stanza;
spyOn(_converse.connection, 'send').and.callFake(function (stanza) { spyOn(_converse.connection, 'send').and.callFake(stanza => (sent_stanza = stanza));
sent_stanza = stanza;
});
const hint = await test_utils.waitUntil(() => view.el.querySelector('.suggestion-box__results li')); const hint = await test_utils.waitUntil(() => view.el.querySelector('.suggestion-box__results li'));
expect(input.value).toBe('Felix'); expect(input.value).toBe('Felix');
expect(hint.textContent).toBe('Felix Amsel'); expect(hint.textContent).toBe('Felix Amsel');
...@@ -2214,15 +2209,14 @@ ...@@ -2214,15 +2209,14 @@
const room_jid = 'coven@chat.shakespeare.lit'; const room_jid = 'coven@chat.shakespeare.lit';
await _converse.api.rooms.open(room_jid, {'nick': 'some1'}); await _converse.api.rooms.open(room_jid, {'nick': 'some1'});
const node = await test_utils.waitUntil(() => _.filter( const 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()); )).pop());
// Check that the groupchat queried for the feautures. // Check that the groupchat queried for the feautures.
const stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${stanza.getAttribute("id")}" to="${room_jid}" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost/resource" id="${stanza.getAttribute("id")}" to="${room_jid}" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`+ `<query xmlns="http://jabber.org/protocol/disco#info"/>`+
`</iq>`); `</iq>`);
...@@ -2320,7 +2314,7 @@ ...@@ -2320,7 +2314,7 @@
const IQs = _converse.connection.IQ_stanzas; const IQs = _converse.connection.IQ_stanzas;
let iq = await test_utils.waitUntil(() => _.filter( let iq = await test_utils.waitUntil(() => _.filter(
IQs, IQs,
iq => iq.nodeTree.querySelector( iq => iq.querySelector(
`iq[to="${jid}"] query[xmlns="${Strophe.NS.MUC_OWNER}"]` `iq[to="${jid}"] query[xmlns="${Strophe.NS.MUC_OWNER}"]`
)).pop()); )).pop());
...@@ -2328,7 +2322,7 @@ ...@@ -2328,7 +2322,7 @@
`<iq xmlns="jabber:client" `<iq xmlns="jabber:client"
type="result" type="result"
to="dummy@localhost/pda" to="dummy@localhost/pda"
from="room@conference.example.org" id="${iq.nodeTree.getAttribute('id')}"> from="room@conference.example.org" id="${iq.getAttribute('id')}">
<query xmlns="http://jabber.org/protocol/muc#owner"> <query xmlns="http://jabber.org/protocol/muc#owner">
<x xmlns="jabber:x:data" type="form"> <x xmlns="jabber:x:data" type="form">
<title>Configuration for room@conference.example.org</title> <title>Configuration for room@conference.example.org</title>
...@@ -2396,13 +2390,13 @@ ...@@ -2396,13 +2390,13 @@
sizzle('[name="muc#roomconfig_roomname"]', chatroomview.el).pop().value = "New room name" sizzle('[name="muc#roomconfig_roomname"]', chatroomview.el).pop().value = "New room name"
chatroomview.el.querySelector('.btn-primary').click(); chatroomview.el.querySelector('.btn-primary').click();
iq = await test_utils.waitUntil(() => _.filter(IQs, iq => u.matchesSelector(iq.nodeTree, `iq[to="${jid}"][type="set"]`)).pop()); iq = await test_utils.waitUntil(() => _.filter(IQs, iq => u.matchesSelector(iq, `iq[to="${jid}"][type="set"]`)).pop());
const result = $iq({ const result = $iq({
"xmlns": "jabber:client", "xmlns": "jabber:client",
"type": "result", "type": "result",
"to": "dummy@localhost/resource", "to": "dummy@localhost/resource",
"from": "lounge@muc.localhost", "from": "lounge@muc.localhost",
"id": iq.nodeTree.getAttribute('id') "id": iq.getAttribute('id')
}); });
IQs.length = 0; // Empty the array IQs.length = 0; // Empty the array
...@@ -2410,13 +2404,13 @@ ...@@ -2410,13 +2404,13 @@
iq = await test_utils.waitUntil(() => _.filter( iq = await test_utils.waitUntil(() => _.filter(
IQs, IQs,
iq => iq.nodeTree.querySelector( iq => iq.querySelector(
`iq[to="${jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]` `iq[to="${jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).pop()); )).pop());
const features_stanza = $iq({ const features_stanza = $iq({
'from': jid, 'from': jid,
'id': iq.nodeTree.getAttribute('id'), 'id': iq.getAttribute('id'),
'to': 'dummy@localhost/desktop', 'to': 'dummy@localhost/desktop',
'type': 'result' 'type': 'result'
}).c('query', { 'xmlns': 'http://jabber.org/protocol/disco#info'}) }).c('query', { 'xmlns': 'http://jabber.org/protocol/disco#info'})
...@@ -2835,13 +2829,12 @@ ...@@ -2835,13 +2829,12 @@
}); });
_converse.connection.IQ_stanzas = []; _converse.connection.IQ_stanzas = [];
_converse.connection._dataRecv(test_utils.createRequest(result)); _converse.connection._dataRecv(test_utils.createRequest(result));
let node = await test_utils.waitUntil(() => _.filter( iq_stanza = await test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => iq.nodeTree.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="member"]')).pop() iq => iq.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="member"]')).pop()
); );
iq_stanza = node.nodeTree; expect(Strophe.serialize(iq_stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq id="${iq_stanza.getAttribute('id')}" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`+ `<iq id="${iq_stanza.getAttribute('id')}" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/muc#admin">`+ `<query xmlns="http://jabber.org/protocol/muc#admin">`+
`<item affiliation="member"/>`+ `<item affiliation="member"/>`+
...@@ -2860,13 +2853,12 @@ ...@@ -2860,13 +2853,12 @@
_converse.connection._dataRecv(test_utils.createRequest(result)); _converse.connection._dataRecv(test_utils.createRequest(result));
expect(view.model.occupants.length).toBe(2); expect(view.model.occupants.length).toBe(2);
node = await test_utils.waitUntil(() => _.filter( iq_stanza = await test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
(iq) => iq.nodeTree.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="owner"]')).pop() iq => iq.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="owner"]')).pop()
); );
iq_stanza = node.nodeTree; expect(Strophe.serialize(iq_stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq id="${iq_stanza.getAttribute('id')}" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`+ `<iq id="${iq_stanza.getAttribute('id')}" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/muc#admin">`+ `<query xmlns="http://jabber.org/protocol/muc#admin">`+
`<item affiliation="owner"/>`+ `<item affiliation="owner"/>`+
...@@ -2885,13 +2877,12 @@ ...@@ -2885,13 +2877,12 @@
_converse.connection._dataRecv(test_utils.createRequest(result)); _converse.connection._dataRecv(test_utils.createRequest(result));
expect(view.model.occupants.length).toBe(2); expect(view.model.occupants.length).toBe(2);
node = await test_utils.waitUntil(() => _.filter( iq_stanza = await test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
(iq) => iq.nodeTree.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="admin"]')).pop() iq => iq.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="admin"]')).pop()
); );
iq_stanza = node.nodeTree; expect(Strophe.serialize(iq_stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq id="${iq_stanza.getAttribute('id')}" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`+ `<iq id="${iq_stanza.getAttribute('id')}" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/muc#admin">`+ `<query xmlns="http://jabber.org/protocol/muc#admin">`+
`<item affiliation="admin"/>`+ `<item affiliation="admin"/>`+
...@@ -3875,21 +3866,20 @@ ...@@ -3875,21 +3866,20 @@
}); });
await _converse.api.rooms.open(room_jid, {'nick': 'dummy'}); await _converse.api.rooms.open(room_jid, {'nick': 'dummy'});
const node = await test_utils.waitUntil(() => _.filter( let 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()); )).pop());
// Check that the groupchat queried for the feautures. // Check that the groupchat queried for the feautures.
let stanza = node.nodeTree; expect(Strophe.serialize(stanza)).toBe(
expect(node.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${stanza.getAttribute("id")}" to="${room_jid}" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost/resource" id="${stanza.getAttribute("id")}" to="${room_jid}" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`+ `<query xmlns="http://jabber.org/protocol/disco#info"/>`+
`</iq>`); `</iq>`);
const view = _converse.chatboxviews.get('coven@chat.shakespeare.lit'); const view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
// State that the chat is members-only via the features IQ // State that the chat is members-only via the features IQ
var features_stanza = $iq({ const features_stanza = $iq({
from: 'coven@chat.shakespeare.lit', from: 'coven@chat.shakespeare.lit',
'id': IQ_ids.pop(), 'id': IQ_ids.pop(),
'to': 'dummy@localhost/desktop', 'to': 'dummy@localhost/desktop',
...@@ -4001,11 +3991,11 @@ ...@@ -4001,11 +3991,11 @@
}); });
_converse.connection._dataRecv(test_utils.createRequest(owner_list_stanza)); _converse.connection._dataRecv(test_utils.createRequest(owner_list_stanza));
await test_utils.waitUntil(() => IQ_ids.length, 300); await test_utils.waitUntil(() => IQ_ids.length, 300);
stanza = await test_utils.waitUntil(() => _.get(_.filter( 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/muc#admin"]` `iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/muc#admin"]`
)).pop(), 'nodeTree')); )).pop());
expect(stanza.outerHTML, expect(stanza.outerHTML,
`<iq id="${IQ_ids.pop()}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+ `<iq id="${IQ_ids.pop()}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/muc#admin">`+ `<query xmlns="http://jabber.org/protocol/muc#admin">`+
...@@ -4281,13 +4271,6 @@ ...@@ -4281,13 +4271,6 @@
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {}, null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
const sendIQ = _converse.connection.sendIQ;
let sent_stanza, IQ_id;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_stanza = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback);
});
test_utils.openControlBox(); test_utils.openControlBox();
const roomspanel = _converse.chatboxviews.get('controlbox').roomspanel; const roomspanel = _converse.chatboxviews.get('controlbox').roomspanel;
roomspanel.el.querySelector('.show-list-muc-modal').click(); roomspanel.el.querySelector('.show-list-muc-modal').click();
...@@ -4302,19 +4285,28 @@ ...@@ -4302,19 +4285,28 @@
const server_input = modal.el.querySelector('input[name="server"]'); const server_input = modal.el.querySelector('input[name="server"]');
expect(server_input.placeholder).toBe('conference.example.org'); expect(server_input.placeholder).toBe('conference.example.org');
const input = server_input.value = 'chat.shakespear.lit'; const input = server_input.value = 'chat.shakespeare.lit';
modal.el.querySelector('input[type="submit"]').click(); modal.el.querySelector('input[type="submit"]').click();
await test_utils.waitUntil(() => _converse.chatboxes.length); await test_utils.waitUntil(() => _converse.chatboxes.length);
expect(sent_stanza.toLocaleString()).toBe(
`<iq from="dummy@localhost/resource" id="${IQ_id}" to="chat.shakespear.lit" type="get" xmlns="jabber:client">`+ const IQ_stanzas = _converse.connection.IQ_stanzas;
`<query xmlns="http://jabber.org/protocol/disco#items"/>`+ const sent_stanza = await test_utils.waitUntil(
() => IQ_stanzas.filter(s => sizzle(`query[xmlns="${Strophe.NS.DISCO_ITEMS}"]`, s).length).pop()
);
const id = sent_stanza.getAttribute('id');
expect(Strophe.serialize(sent_stanza)).toBe(
`<iq from="dummy@localhost/resource" id="${id}" `+
`to="chat.shakespeare.lit" `+
`type="get" `+
`xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/disco#items"/>`+
`</iq>` `</iq>`
); );
const iq = $iq({ const iq = $iq({
from:'muc.localhost', 'from':'muc.localhost',
to:'dummy@localhost/pda', 'to':'dummy@localhost/pda',
id: IQ_id, 'id': id,
type:'result' 'type':'result'
}).c('query') }).c('query')
.c('item', { jid:'heath@chat.shakespeare.lit', name:'A Lonely Heath'}).up() .c('item', { jid:'heath@chat.shakespeare.lit', name:'A Lonely Heath'}).up()
.c('item', { jid:'coven@chat.shakespeare.lit', name:'A Dark Cave'}).up() .c('item', { jid:'coven@chat.shakespeare.lit', name:'A Dark Cave'}).up()
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
async function deviceListFetched (_converse, jid) { async function deviceListFetched (_converse, jid) {
const stanza = await test_utils.waitUntil(() => _.filter( const stanza = await test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => iq.nodeTree.querySelector(`iq[to="${jid}"] items[node="eu.siacs.conversations.axolotl.devicelist"]`) iq => iq.querySelector(`iq[to="${jid}"] items[node="eu.siacs.conversations.axolotl.devicelist"]`)
).pop()); ).pop());
await test_utils.waitUntil(() => _converse.devicelists.get(jid)); await test_utils.waitUntil(() => _converse.devicelists.get(jid));
return stanza; return stanza;
...@@ -17,21 +17,21 @@ ...@@ -17,21 +17,21 @@
function ownDeviceHasBeenPublished (_converse) { function ownDeviceHasBeenPublished (_converse) {
return _.filter( return _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => iq.nodeTree.querySelector('iq[from="'+_converse.bare_jid+'"] publish[node="eu.siacs.conversations.axolotl.devicelist"]') iq => iq.querySelector('iq[from="'+_converse.bare_jid+'"] publish[node="eu.siacs.conversations.axolotl.devicelist"]')
).pop(); ).pop();
} }
function bundleHasBeenPublished (_converse) { function bundleHasBeenPublished (_converse) {
return _.filter( return _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => iq.nodeTree.querySelector('publish[node="eu.siacs.conversations.axolotl.bundles:123456789"]') iq => iq.querySelector('publish[node="eu.siacs.conversations.axolotl.bundles:123456789"]')
).pop(); ).pop();
} }
function bundleFetched (_converse, jid, device_id) { function bundleFetched (_converse, jid, device_id) {
return _.filter( return _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
iq => iq.nodeTree.querySelector(`iq[to="${jid}"] items[node="eu.siacs.conversations.axolotl.bundles:${device_id}"]`) iq => iq.querySelector(`iq[to="${jid}"] items[node="eu.siacs.conversations.axolotl.bundles:${device_id}"]`)
).pop(); ).pop();
} }
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid));
let stanza = $iq({ let stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
let stanza = $iq({ let stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, contact_jid, '555')); iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, contact_jid, '555'));
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', { }).c('pubsub', {
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, _converse.bare_jid, '482886413b977930064a5888b92134fe')); iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, _converse.bare_jid, '482886413b977930064a5888b92134fe'));
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', { }).c('pubsub', {
...@@ -275,8 +275,8 @@ ...@@ -275,8 +275,8 @@
// Wait for Converse to fetch newguy's device list // Wait for Converse to fetch newguy's device list
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`+ `<items node="eu.siacs.conversations.axolotl.devicelist"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -285,7 +285,7 @@ ...@@ -285,7 +285,7 @@
// The server returns his device list // The server returns his device list
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -318,7 +318,7 @@ ...@@ -318,7 +318,7 @@
console.log("Bundle fetched 4e30f35051b7b8b42abe083742187228"); console.log("Bundle fetched 4e30f35051b7b8b42abe083742187228");
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', { }).c('pubsub', {
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
console.log("Bundle fetched 482886413b977930064a5888b92134fe"); console.log("Bundle fetched 482886413b977930064a5888b92134fe");
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', { }).c('pubsub', {
...@@ -397,7 +397,7 @@ ...@@ -397,7 +397,7 @@
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
const stanza = $iq({ const stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -464,8 +464,8 @@ ...@@ -464,8 +464,8 @@
keyCode: 13 // Enter keyCode: 13 // Enter
}); });
iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, _converse.bare_jid, '988349631')); iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, _converse.bare_jid, '988349631'));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="${_converse.bare_jid}" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="${_converse.bare_jid}" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.bundles:988349631"/>`+ `<items node="eu.siacs.conversations.axolotl.bundles:988349631"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -521,8 +521,8 @@ ...@@ -521,8 +521,8 @@
keyCode: 13 // Enter keyCode: 13 // Enter
}); });
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`+ `<items node="eu.siacs.conversations.axolotl.devicelist"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -530,7 +530,7 @@ ...@@ -530,7 +530,7 @@
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -551,7 +551,7 @@ ...@@ -551,7 +551,7 @@
iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, _converse.bare_jid, '482886413b977930064a5888b92134fe')); iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, _converse.bare_jid, '482886413b977930064a5888b92134fe'));
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', { }).c('pubsub', {
...@@ -580,7 +580,7 @@ ...@@ -580,7 +580,7 @@
*/ */
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': 'http://jabber.org/protocol/pubsub'}) }).c('pubsub', {'xmlns': 'http://jabber.org/protocol/pubsub'})
...@@ -648,7 +648,7 @@ ...@@ -648,7 +648,7 @@
iq_stanza = await deviceListFetched(_converse, contact_jid); iq_stanza = await deviceListFetched(_converse, contact_jid);
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -665,8 +665,8 @@ ...@@ -665,8 +665,8 @@
await test_utils.waitUntil(() => _converse.omemo_store); await test_utils.waitUntil(() => _converse.omemo_store);
iq_stanza = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse)); iq_stanza = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" type="set" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" type="set" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`+ `<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`+
`<item>`+ `<item>`+
...@@ -719,8 +719,8 @@ ...@@ -719,8 +719,8 @@
// Wait until own devices are fetched // Wait until own devices are fetched
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="dummy@localhost" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="dummy@localhost" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`+ `<items node="eu.siacs.conversations.axolotl.devicelist"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -728,7 +728,7 @@ ...@@ -728,7 +728,7 @@
let stanza = $iq({ let stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -747,7 +747,7 @@ ...@@ -747,7 +747,7 @@
iq_stanza = await test_utils.waitUntil(() => ownDeviceHasBeenPublished(_converse)); iq_stanza = await test_utils.waitUntil(() => ownDeviceHasBeenPublished(_converse));
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
...@@ -755,7 +755,7 @@ ...@@ -755,7 +755,7 @@
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
...@@ -840,8 +840,8 @@ ...@@ -840,8 +840,8 @@
iq_stanza = await test_utils.waitUntil(() => ownDeviceHasBeenPublished(_converse)); iq_stanza = await test_utils.waitUntil(() => ownDeviceHasBeenPublished(_converse));
// Check that our own device is added again, but that removed // Check that our own device is added again, but that removed
// devices are not added. // devices are not added.
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute(`id`)}" type="set" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute(`id`)}" type="set" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<publish node="eu.siacs.conversations.axolotl.devicelist">`+ `<publish node="eu.siacs.conversations.axolotl.devicelist">`+
`<item>`+ `<item>`+
...@@ -891,8 +891,8 @@ ...@@ -891,8 +891,8 @@
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
const contact_jid = mock.cur_names[3].replace(/ /g,'.').toLowerCase() + '@localhost'; const contact_jid = mock.cur_names[3].replace(/ /g,'.').toLowerCase() + '@localhost';
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="dummy@localhost" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="dummy@localhost" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`+ `<items node="eu.siacs.conversations.axolotl.devicelist"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -900,7 +900,7 @@ ...@@ -900,7 +900,7 @@
let stanza = $iq({ let stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -918,14 +918,14 @@ ...@@ -918,14 +918,14 @@
iq_stanza = await test_utils.waitUntil(() => ownDeviceHasBeenPublished(_converse)); iq_stanza = await test_utils.waitUntil(() => ownDeviceHasBeenPublished(_converse));
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
iq_stanza = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse)); iq_stanza = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse));
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
...@@ -1046,7 +1046,7 @@ ...@@ -1046,7 +1046,7 @@
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid));
let stanza = $iq({ let stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -1060,14 +1060,14 @@ ...@@ -1060,14 +1060,14 @@
iq_stanza = await ownDeviceHasBeenPublished(_converse); iq_stanza = await ownDeviceHasBeenPublished(_converse);
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
iq_stanza = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse)); iq_stanza = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" type="set" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" type="set" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`+ `<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`+
`<item>`+ `<item>`+
...@@ -1097,7 +1097,7 @@ ...@@ -1097,7 +1097,7 @@
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
...@@ -1122,8 +1122,8 @@ ...@@ -1122,8 +1122,8 @@
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="dummy@localhost" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="dummy@localhost" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`+ `<items node="eu.siacs.conversations.axolotl.devicelist"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -1131,7 +1131,7 @@ ...@@ -1131,7 +1131,7 @@
let stanza = $iq({ let stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -1148,8 +1148,8 @@ ...@@ -1148,8 +1148,8 @@
expect(devicelist.devices.at(1).get('id')).toBe('123456789'); expect(devicelist.devices.at(1).get('id')).toBe('123456789');
// Check that own device was published // Check that own device was published
iq_stanza = await test_utils.waitUntil(() => ownDeviceHasBeenPublished(_converse)); iq_stanza = await test_utils.waitUntil(() => ownDeviceHasBeenPublished(_converse));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute(`id`)}" type="set" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute(`id`)}" type="set" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<publish node="eu.siacs.conversations.axolotl.devicelist">`+ `<publish node="eu.siacs.conversations.axolotl.devicelist">`+
`<item>`+ `<item>`+
...@@ -1174,12 +1174,12 @@ ...@@ -1174,12 +1174,12 @@
stanza = $iq({ stanza = $iq({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result'}); 'type': 'result'});
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
const iq_el = await test_utils.waitUntil(() => _.get(bundleHasBeenPublished(_converse), 'nodeTree')); const iq_el = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse));
expect(iq_el.getAttributeNames().sort().join()).toBe(["from", "type", "xmlns", "id"].sort().join()); expect(iq_el.getAttributeNames().sort().join()).toBe(["from", "type", "xmlns", "id"].sort().join());
expect(iq_el.querySelector('prekeys').childNodes.length).toBe(100); expect(iq_el.querySelector('prekeys').childNodes.length).toBe(100);
...@@ -1199,8 +1199,8 @@ ...@@ -1199,8 +1199,8 @@
await _converse.api.waitUntil('OMEMOInitialized', 1000); await _converse.api.waitUntil('OMEMOInitialized', 1000);
await test_utils.openChatBoxFor(_converse, contact_jid); await test_utils.openChatBoxFor(_converse, contact_jid);
iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid)); iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`+ `<items node="eu.siacs.conversations.axolotl.devicelist"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -1208,7 +1208,7 @@ ...@@ -1208,7 +1208,7 @@
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -1328,8 +1328,8 @@ ...@@ -1328,8 +1328,8 @@
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`+ `<items node="eu.siacs.conversations.axolotl.devicelist"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -1337,7 +1337,7 @@ ...@@ -1337,7 +1337,7 @@
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -1414,8 +1414,8 @@ ...@@ -1414,8 +1414,8 @@
}).tree(); }).tree();
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid)); iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`+ `<items node="eu.siacs.conversations.axolotl.devicelist"/>`+
`</pubsub>`+ `</pubsub>`+
...@@ -1423,7 +1423,7 @@ ...@@ -1423,7 +1423,7 @@
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'error' 'type': 'error'
}).c('error', {'type': 'cancel'}) }).c('error', {'type': 'cancel'})
...@@ -1477,13 +1477,13 @@ ...@@ -1477,13 +1477,13 @@
const modal = view.user_details_modal; const modal = view.user_details_modal;
await test_utils.waitUntil(() => u.isVisible(modal.el), 1000); await test_utils.waitUntil(() => u.isVisible(modal.el), 1000);
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid)); let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="max.frankfurter@localhost" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="max.frankfurter@localhost" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub>`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub>`+
`</iq>`); `</iq>`);
let stanza = $iq({ let stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"}) }).c('pubsub', {'xmlns': "http://jabber.org/protocol/pubsub"})
...@@ -1494,15 +1494,15 @@ ...@@ -1494,15 +1494,15 @@
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
await test_utils.waitUntil(() => u.isVisible(modal.el), 1000); await test_utils.waitUntil(() => u.isVisible(modal.el), 1000);
iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, contact_jid, '555')); iq_stanza = await test_utils.waitUntil(() => bundleFetched(_converse, contact_jid, '555'));
expect(iq_stanza.toLocaleString()).toBe( expect(Strophe.serialize(iq_stanza)).toBe(
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="max.frankfurter@localhost" type="get" xmlns="jabber:client">`+ `<iq from="dummy@localhost" id="${iq_stanza.getAttribute("id")}" to="max.frankfurter@localhost" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+ `<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
`<items node="eu.siacs.conversations.axolotl.bundles:555"/>`+ `<items node="eu.siacs.conversations.axolotl.bundles:555"/>`+
`</pubsub>`+ `</pubsub>`+
`</iq>`); `</iq>`);
stanza = $iq({ stanza = $iq({
'from': contact_jid, 'from': contact_jid,
'id': iq_stanza.nodeTree.getAttribute('id'), 'id': iq_stanza.getAttribute('id'),
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'type': 'result', 'type': 'result',
}).c('pubsub', { }).c('pubsub', {
......
...@@ -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">`+
...@@ -83,15 +81,15 @@ ...@@ -83,15 +81,15 @@
function (done, _converse) { function (done, _converse) {
let view; let view;
const IQ_stanzas = _converse.connection.IQ_stanzas; const IQ_stanzas = _converse.connection.IQ_stanzas;
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