|
@@ -4,6 +4,7 @@
|
|
const _ = converse.env._,
|
|
const _ = converse.env._,
|
|
$iq = converse.env.$iq,
|
|
$iq = converse.env.$iq,
|
|
Strophe = converse.env.Strophe,
|
|
Strophe = converse.env.Strophe,
|
|
|
|
+ sizzle = converse.env.sizzle,
|
|
u = converse.env.utils;
|
|
u = converse.env.utils;
|
|
|
|
|
|
describe("Chatrooms", function () {
|
|
describe("Chatrooms", function () {
|
|
@@ -18,58 +19,44 @@
|
|
const room_jid = 'coven@chat.shakespeare.lit';
|
|
const room_jid = 'coven@chat.shakespeare.lit';
|
|
test_utils.openAndEnterChatRoom(_converse, 'coven', 'chat.shakespeare.lit', 'romeo')
|
|
test_utils.openAndEnterChatRoom(_converse, 'coven', 'chat.shakespeare.lit', 'romeo')
|
|
.then(() => {
|
|
.then(() => {
|
|
- return test_utils.waitUntil(() => _.get(_.filter(
|
|
|
|
- _converse.connection.IQ_stanzas,
|
|
|
|
- iq => iq.nodeTree.querySelector(
|
|
|
|
- `iq[to="coven@chat.shakespeare.lit"] query[xmlns="http://jabber.org/protocol/disco#info"]`
|
|
|
|
- )
|
|
|
|
- ).pop(), 'nodeTree'));
|
|
|
|
-
|
|
|
|
- }).then(stanza => {
|
|
|
|
view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
|
|
view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
|
|
- spyOn(view.model, 'parseRoomFeatures').and.callThrough();
|
|
|
|
- const features_stanza = $iq({
|
|
|
|
- 'from': room_jid,
|
|
|
|
- 'id': stanza.getAttribute('id'),
|
|
|
|
- 'to': 'dummy@localhost/desktop',
|
|
|
|
- 'type': 'result'
|
|
|
|
- })
|
|
|
|
- .c('query', { 'xmlns': 'http://jabber.org/protocol/disco#info'})
|
|
|
|
- .c('identity', {
|
|
|
|
- 'category': 'conference',
|
|
|
|
- 'name': 'A Dark Cave',
|
|
|
|
- 'type': 'text'
|
|
|
|
- }).up()
|
|
|
|
- .c('feature', {'var': 'http://jabber.org/protocol/muc'}).up()
|
|
|
|
- .c('feature', {'var': 'jabber:iq:register'}).up()
|
|
|
|
- .c('feature', {'var': 'muc_passwordprotected'}).up()
|
|
|
|
- .c('feature', {'var': 'muc_hidden'}).up()
|
|
|
|
- .c('feature', {'var': 'muc_temporary'}).up()
|
|
|
|
- .c('feature', {'var': 'muc_open'}).up()
|
|
|
|
- .c('feature', {'var': 'muc_unmoderated'}).up()
|
|
|
|
- .c('feature', {'var': 'muc_nonanonymous'});
|
|
|
|
- _converse.connection._dataRecv(test_utils.createRequest(features_stanza));
|
|
|
|
- return test_utils.waitUntil(() => view.model.parseRoomFeatures.calls.count(), 300)
|
|
|
|
- }).then(() => {
|
|
|
|
return test_utils.waitUntil(() => _.get(_.filter(
|
|
return test_utils.waitUntil(() => _.get(_.filter(
|
|
_converse.connection.IQ_stanzas,
|
|
_converse.connection.IQ_stanzas,
|
|
- iq => iq.nodeTree.querySelector(`iq[to="coven@chat.shakespeare.lit"] query[xmlns="jabber:iq:register"]`)
|
|
|
|
|
|
+ iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length
|
|
).pop(), 'nodeTree'));
|
|
).pop(), 'nodeTree'));
|
|
}).then(stanza => {
|
|
}).then(stanza => {
|
|
expect(stanza.outerHTML)
|
|
expect(stanza.outerHTML)
|
|
- .toBe(`<iq from="dummy@localhost" to="coven@chat.shakespeare.lit" `+
|
|
|
|
|
|
+ .toBe(`<iq to="coven@chat.shakespeare.lit" from="dummy@localhost/resource" `+
|
|
`type="get" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+
|
|
`type="get" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+
|
|
`<query xmlns="jabber:iq:register"/></iq>`);
|
|
`<query xmlns="jabber:iq:register"/></iq>`);
|
|
- // Room does not exist
|
|
|
|
view = _converse.chatboxviews.get(room_jid);
|
|
view = _converse.chatboxviews.get(room_jid);
|
|
const result = $iq({
|
|
const result = $iq({
|
|
'from': view.model.get('jid'),
|
|
'from': view.model.get('jid'),
|
|
'id': stanza.getAttribute('id'),
|
|
'id': stanza.getAttribute('id'),
|
|
'to': _converse.bare_jid,
|
|
'to': _converse.bare_jid,
|
|
- 'type': 'error',
|
|
|
|
- }).c('error', {'type': "cancel"})
|
|
|
|
- .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"})
|
|
|
|
|
|
+ 'type': 'result',
|
|
|
|
+ }).c('query', {'type': 'jabber:iq:register'})
|
|
|
|
+ .c('x', {'xmlns': 'jabber:x:data', 'type': 'form'})
|
|
|
|
+ .c('field', {
|
|
|
|
+ 'label': 'Desired Nickname',
|
|
|
|
+ 'type': 'text-single',
|
|
|
|
+ 'var': 'muc#register_roomnick'
|
|
|
|
+ }).c('required');
|
|
_converse.connection._dataRecv(test_utils.createRequest(result));
|
|
_converse.connection._dataRecv(test_utils.createRequest(result));
|
|
|
|
+ return test_utils.waitUntil(() => _.get(_.filter(
|
|
|
|
+ _converse.connection.IQ_stanzas,
|
|
|
|
+ iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq.nodeTree).length
|
|
|
|
+ ).pop(), 'nodeTree'));
|
|
|
|
+ }).then(stanza => {
|
|
|
|
+ expect(stanza.outerHTML).toBe(
|
|
|
|
+ `<iq to="coven@chat.shakespeare.lit" from="dummy@localhost/resource" type="set" xmlns="jabber:client" id="${stanza.getAttribute('id')}">`+
|
|
|
|
+ `<query xmlns="jabber:iq:register">`+
|
|
|
|
+ `<x xmlns="jabber:x:data" type="submit">`+
|
|
|
|
+ `<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`+
|
|
|
|
+ `<field var="muc#register_roomnick"><value>romeo</value></field>`+
|
|
|
|
+ `</x>`+
|
|
|
|
+ `</query>`+
|
|
|
|
+ `</iq>`);
|
|
done();
|
|
done();
|
|
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
|
|
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
|
|
}));
|
|
}));
|