Commit cd05b897 authored by JC Brand's avatar JC Brand

Fix failing tests due to MUC disco refactoring

parent 603708a9
This diff is collapsed.
......@@ -57,7 +57,7 @@
}).then(done).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}));
it("can enabled for a MUC domain",
it("can be enabled for a MUC domain",
mock.initConverseWithPromises(null,
['rosterGroupsFetched'], {
'push_app_servers': [{
......
......@@ -98,11 +98,18 @@
}, function (done, _converse) {
let view;
const IQ_stanzas = _converse.connection.IQ_stanzas;
const room_jid = 'coven@chat.shakespeare.lit';
test_utils.openControlBox();
_converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'})
_converse.api.rooms.open(room_jid, {'nick': 'some1'})
.then(() => {
view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
const last_stanza = _.last(_converse.connection.IQ_stanzas).nodeTree;
return test_utils.waitUntil(() => _.get(_.filter(
IQ_stanzas,
iq => iq.nodeTree.querySelector(
`iq[to="${room_jid}"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).pop(), 'nodeTree'));
}).then(last_stanza => {
view = _converse.chatboxviews.get(room_jid);
const IQ_id = last_stanza.getAttribute('id');
const features_stanza = $iq({
'from': 'coven@chat.shakespeare.lit',
......
......@@ -957,15 +957,17 @@
break;
}
const occupant = this.model.occupants.findWhere({'nick': args[0]}) ||
this.model.occupants.findWhere({'jid': args[0]});
this.model.setAffiliation('member', [{
'jid': occupant.get('jid'),
'nick': occupant.get('nick'),
'reason': args[1]
}]).then(
() => this.model.occupants.fetchMembers(),
(err) => this.onCommandError(err)
);
this.model.occupants.findWhere({'jid': args[0]}),
attrs = {
'jid': occupant.get('jid'),
'reason': args[1]
};
if (_converse.auto_register_muc_nickname) {
attrs['nick'] = occupant.get('nick');
}
this.model.setAffiliation('member', [attrs])
.then(() => this.model.occupants.fetchMembers())
.catch(err => this.onCommandError(err));
break;
} case 'nick':
if (!this.verifyRoles(['visitor', 'participant', 'moderator'])) {
......
......@@ -19,20 +19,17 @@
if (_.isNil(type)) {
type = 'info';
}
var IQ_disco, stanza;
return utils.waitUntil(function () {
IQ_disco = _.filter(_converse.connection.IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector('query[xmlns="http://jabber.org/protocol/disco#'+type+'"]') &&
iq.nodeTree.getAttribute('to') === entity_jid;
}).pop();
return !_.isUndefined(IQ_disco);
}, 300).then(function () {
var info_IQ_id = IQ_disco.nodeTree.getAttribute('id');
var stanza = $iq({
return utils.waitUntil(() => {
return _.filter(
_converse.connection.IQ_stanzas,
(iq) => sizzle(`iq[to="${entity_jid}"] query[xmlns="http://jabber.org/protocol/disco#${type}"]`, iq.nodeTree).length
).pop();
}, 300).then(iq => {
const stanza = $iq({
'type': 'result',
'from': entity_jid,
'to': 'dummy@localhost/resource',
'id': info_IQ_id
'id': iq.nodeTree.getAttribute('id'),
}).c('query', {'xmlns': 'http://jabber.org/protocol/disco#'+type});
_.forEach(identities, function (identity) {
......@@ -169,18 +166,17 @@
_converse.connection._dataRecv(utils.createRequest(features_stanza));
});
}
return utils.waitUntil(() => _.get(_.filter(
return utils.waitUntil(() => _.filter(
stanzas,
s => sizzle(`iq[to="${room_jid}"] query[node="x-roomuser-item"]`, s.nodeTree).length
).pop(), 'nodeTree')
).pop()
);
}).then(last_stanza => {
// We empty the array, otherwise we might get stale stanzas
// returned in our filter above.
stanzas.length = 0;
}).then(iq => {
// We remove the stanza, otherwise we might get stale stanzas returned in our filter above.
stanzas.splice(stanzas.indexOf(iq), 1)
// The XMPP server returns the reserved nick for this user.
const IQ_id = last_stanza.getAttribute('id');
const IQ_id = iq.nodeTree.getAttribute('id');
const stanza = $iq({
'type': 'result',
'id': IQ_id,
......
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