diff --git a/spec/chatroom.js b/spec/chatroom.js
index 02cad1717..42e2ec107 100644
--- a/spec/chatroom.js
+++ b/spec/chatroom.js
@@ -19,97 +19,89 @@
it("has a method 'close' which closes rooms by JID or all rooms when called with no arguments",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
- function (done, _converse) {
+ async function (done, _converse) {
- test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy')
- .then(() => test_utils.openAndEnterChatRoom(_converse, 'leisure', 'localhost', 'dummy'))
- .then(() => test_utils.openAndEnterChatRoom(_converse, 'news', 'localhost', 'dummy'))
- .then(() => {
- expect(u.isVisible(_converse.chatboxviews.get('lounge@localhost').el)).toBeTruthy();
- expect(u.isVisible(_converse.chatboxviews.get('leisure@localhost').el)).toBeTruthy();
- expect(u.isVisible(_converse.chatboxviews.get('news@localhost').el)).toBeTruthy();
+ await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
+ await test_utils.openAndEnterChatRoom(_converse, 'leisure', 'localhost', 'dummy');
+ await test_utils.openAndEnterChatRoom(_converse, 'news', 'localhost', 'dummy');
+ expect(u.isVisible(_converse.chatboxviews.get('lounge@localhost').el)).toBeTruthy();
+ expect(u.isVisible(_converse.chatboxviews.get('leisure@localhost').el)).toBeTruthy();
+ expect(u.isVisible(_converse.chatboxviews.get('news@localhost').el)).toBeTruthy();
- // XXX: bit of a cheat here. We want `cleanup()` to be
- // called on the room. Either it's this or faking
- // `sendPresence`.
- _converse.connection.connected = false;
+ // XXX: bit of a cheat here. We want `cleanup()` to be
+ // called on the room. Either it's this or faking
+ // `sendPresence`.
+ _converse.connection.connected = false;
- _converse.api.roomviews.close('lounge@localhost');
- expect(_converse.chatboxviews.get('lounge@localhost')).toBeUndefined();
- expect(u.isVisible(_converse.chatboxviews.get('leisure@localhost').el)).toBeTruthy();
- expect(u.isVisible(_converse.chatboxviews.get('news@localhost').el)).toBeTruthy();
+ _converse.api.roomviews.close('lounge@localhost');
+ expect(_converse.chatboxviews.get('lounge@localhost')).toBeUndefined();
+ expect(u.isVisible(_converse.chatboxviews.get('leisure@localhost').el)).toBeTruthy();
+ expect(u.isVisible(_converse.chatboxviews.get('news@localhost').el)).toBeTruthy();
- _converse.api.roomviews.close(['leisure@localhost', 'news@localhost']);
- expect(_converse.chatboxviews.get('lounge@localhost')).toBeUndefined();
- expect(_converse.chatboxviews.get('leisure@localhost')).toBeUndefined();
- expect(_converse.chatboxviews.get('news@localhost')).toBeUndefined();
- return test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
- })
- .then(() => test_utils.openAndEnterChatRoom(_converse, 'leisure', 'localhost', 'dummy'))
- .then(() => {
- expect(u.isVisible(_converse.chatboxviews.get('lounge@localhost').el)).toBeTruthy();
- expect(u.isVisible(_converse.chatboxviews.get('leisure@localhost').el)).toBeTruthy();
- _converse.api.roomviews.close();
- expect(_converse.chatboxviews.get('lounge@localhost')).toBeUndefined();
- expect(_converse.chatboxviews.get('leisure@localhost')).toBeUndefined();
- done();
- }).catch(_.partial(console.error, _));
+ _converse.api.roomviews.close(['leisure@localhost', 'news@localhost']);
+ expect(_converse.chatboxviews.get('lounge@localhost')).toBeUndefined();
+ expect(_converse.chatboxviews.get('leisure@localhost')).toBeUndefined();
+ expect(_converse.chatboxviews.get('news@localhost')).toBeUndefined();
+ await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
+ await test_utils.openAndEnterChatRoom(_converse, 'leisure', 'localhost', 'dummy');
+ expect(u.isVisible(_converse.chatboxviews.get('lounge@localhost').el)).toBeTruthy();
+ expect(u.isVisible(_converse.chatboxviews.get('leisure@localhost').el)).toBeTruthy();
+ _converse.api.roomviews.close();
+ expect(_converse.chatboxviews.get('lounge@localhost')).toBeUndefined();
+ expect(_converse.chatboxviews.get('leisure@localhost')).toBeUndefined();
+ done();
}));
it("has a method 'get' which returns a wrapped groupchat (if it exists)",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
- function (done, _converse) {
+ async function (done, _converse) {
- let jid, room, chatroomview;
test_utils.createContacts(_converse, 'current');
- test_utils.waitUntil(() => _converse.rosterview.el.querySelectorAll('.roster-group .group-toggle').length, 300)
- .then(() => test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy'))
- .then(() => {
- jid = 'lounge@localhost';
- room = _converse.api.rooms.get(jid);
- expect(room instanceof Object).toBeTruthy();
+ await test_utils.waitUntil(() => _converse.rosterview.el.querySelectorAll('.roster-group .group-toggle').length, 300);
+ await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
+ let jid = 'lounge@localhost';
+ let room = _converse.api.rooms.get(jid);
+ expect(room instanceof Object).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid);
- expect(chatroomview.is_chatroom).toBeTruthy();
+ let chatroomview = _converse.chatboxviews.get(jid);
+ expect(chatroomview.is_chatroom).toBeTruthy();
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
- chatroomview.close();
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ chatroomview.close();
- // Test with mixed case
- return test_utils.openAndEnterChatRoom(_converse, 'Leisure', 'localhost', 'dummy');
- }).then(() => {
- jid = 'Leisure@localhost';
- room = _converse.api.rooms.get(jid);
- expect(room instanceof Object).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ // Test with mixed case
+ await test_utils.openAndEnterChatRoom(_converse, 'Leisure', 'localhost', 'dummy');
+ jid = 'Leisure@localhost';
+ room = _converse.api.rooms.get(jid);
+ expect(room instanceof Object).toBeTruthy();
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
- jid = 'leisure@localhost';
- room = _converse.api.rooms.get(jid);
- expect(room instanceof Object).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ jid = 'leisure@localhost';
+ room = _converse.api.rooms.get(jid);
+ expect(room instanceof Object).toBeTruthy();
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
- jid = 'leiSure@localhost';
- room = _converse.api.rooms.get(jid);
- expect(room instanceof Object).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
- chatroomview.close();
+ jid = 'leiSure@localhost';
+ room = _converse.api.rooms.get(jid);
+ expect(room instanceof Object).toBeTruthy();
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ chatroomview.close();
- // Non-existing room
- jid = 'lounge2@localhost';
- room = _converse.api.rooms.get(jid);
- expect(typeof room === 'undefined').toBeTruthy();
- done();
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ // Non-existing room
+ jid = 'lounge2@localhost';
+ room = _converse.api.rooms.get(jid);
+ expect(typeof room === 'undefined').toBeTruthy();
+ done();
}));
it("has a method 'open' which opens (optionally configures) and returns a wrapped chat box",
- mock.initConverseWithPromises(
- null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
- function (done, _converse) {
+ mock.initConverseWithPromises(
+ null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
+ async function (done, _converse) {
// Mock 'getRoomFeatures', otherwise the room won't be
// displayed as it waits first for the features to be returned
@@ -121,169 +113,161 @@
let chatroomview, sent_IQ, IQ_id;
test_utils.openControlBox();
test_utils.createContacts(_converse, 'current');
- test_utils.waitUntil(() => _converse.rosterview.el.querySelectorAll('.roster-group .group-toggle').length)
- .then(() => _converse.api.rooms.open(jid))
- .then((room) => {
- // Test on groupchat that's not yet open
- expect(room instanceof Backbone.Model).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid);
- expect(chatroomview.is_chatroom).toBeTruthy();
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ await test_utils.waitUntil(() => _converse.rosterview.el.querySelectorAll('.roster-group .group-toggle').length);
+ let room = await _converse.api.rooms.open(jid);
+ // Test on groupchat that's not yet open
+ expect(room instanceof Backbone.Model).toBeTruthy();
+ chatroomview = _converse.chatboxviews.get(jid);
+ expect(chatroomview.is_chatroom).toBeTruthy();
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
- // Test again, now that the room exists.
- return _converse.api.rooms.open(jid);
- }).then((room) => {
- expect(room instanceof Backbone.Model).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid);
- expect(chatroomview.is_chatroom).toBeTruthy();
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
- chatroomview.close();
+ // Test again, now that the room exists.
+ room = await _converse.api.rooms.open(jid);
+ expect(room instanceof Backbone.Model).toBeTruthy();
+ chatroomview = _converse.chatboxviews.get(jid);
+ expect(chatroomview.is_chatroom).toBeTruthy();
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ chatroomview.close();
- // Test with mixed case in JID
- jid = 'Leisure@localhost';
- return _converse.api.rooms.open(jid);
- }).then((room) => {
- expect(room instanceof Backbone.Model).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ // Test with mixed case in JID
+ jid = 'Leisure@localhost';
+ room = await _converse.api.rooms.open(jid);
+ expect(room instanceof Backbone.Model).toBeTruthy();
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
- jid = 'leisure@localhost';
- return _converse.api.rooms.open(jid);
- }).then((room) => {
- expect(room instanceof Backbone.Model).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ jid = 'leisure@localhost';
+ room = await _converse.api.rooms.open(jid);
+ expect(room instanceof Backbone.Model).toBeTruthy();
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
- jid = 'leiSure@localhost';
- return _converse.api.rooms.open(jid);
- }).then((room) => {
- expect(room instanceof Backbone.Model).toBeTruthy();
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
- chatroomview.close();
+ jid = 'leiSure@localhost';
+ room = await _converse.api.rooms.open(jid);
+ expect(room instanceof Backbone.Model).toBeTruthy();
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
+ chatroomview.close();
- _converse.muc_instant_rooms = false;
- var sendIQ = _converse.connection.sendIQ;
- spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
- sent_IQ = iq;
- sent_IQ_els.push(iq.nodeTree);
- IQ_id = sendIQ.bind(this)(iq, callback, errback);
- });
- // Test with configuration
- return _converse.api.rooms.open('room@conference.example.org', {
- 'nick': 'some1',
- 'auto_configure': true,
- 'roomconfig': {
- 'changesubject': false,
- 'membersonly': true,
- 'persistentroom': true,
- 'publicroom': true,
- 'roomdesc': 'Welcome to this groupchat',
- 'whois': 'anyone'
- }
- });
- }).then((room) => {
- chatroomview = _converse.chatboxviews.get('room@conference.example.org');
-
- // We pretend this is a new room, so no disco info is returned.
- var features_stanza = $iq({
- from: 'room@conference.example.org',
- 'id': IQ_id,
- 'to': 'dummy@localhost/desktop',
- 'type': 'error'
- }).c('error', {'type': 'cancel'})
- .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});
- _converse.connection._dataRecv(test_utils.createRequest(features_stanza));
-
- /*
- *
- *
- *
- *
- *
- *
- */
- var presence = $pres({
- from:'room@conference.example.org/some1',
- to:'dummy@localhost/pda'
- })
- .c('x', {xmlns:'http://jabber.org/protocol/muc#user'})
- .c('item', {
- affiliation: 'owner',
- jid: 'dummy@localhost/pda',
- role: 'moderator'
- }).up()
- .c('status', {code:'110'}).up()
- .c('status', {code:'201'});
- _converse.connection._dataRecv(test_utils.createRequest(presence));
- expect(_converse.connection.sendIQ).toHaveBeenCalled();
- expect(sent_IQ.toLocaleString()).toBe(
- ``+
- ``
- );
- var node = Strophe.xmlHtmlNode(
- ''+
- ' '+
- ' '+
- ' Configuration for room@conference.example.org'+
- ' Complete and submit this form to configure the room.'+
- ' '+
- ' http://jabber.org/protocol/muc#roomconfig'+
- ' '+
- ' '+
- ' Room'+
- ' '+
- ' '+
- ' '+
- ' 1'+
- ' '+
- ' '+
- ' '+
- ' '+
- ' '+
- ' '+
- ' '+
- ' 20'+
- ' '+
- ' '+
- ' ');
-
- spyOn(chatroomview.model, 'sendConfiguration').and.callThrough();
- _converse.connection._dataRecv(test_utils.createRequest(node.firstElementChild));
- return test_utils.waitUntil(() => chatroomview.model.sendConfiguration.calls.count() === 1);
- }).then(() => {
- var sent_stanza = sent_IQ_els.pop();
- while (sent_stanza.getAttribute('type') !== 'set') {
- sent_stanza = sent_IQ_els.pop();
- }
- expect(sizzle('field[var="muc#roomconfig_roomname"] value', sent_stanza).pop().textContent).toBe('Room');
- expect(sizzle('field[var="muc#roomconfig_roomdesc"] value', sent_stanza).pop().textContent).toBe('Welcome to this groupchat');
- expect(sizzle('field[var="muc#roomconfig_persistentroom"] value', sent_stanza).pop().textContent).toBe('1');
- expect(sizzle('field[var="muc#roomconfig_publicroom"] value ', sent_stanza).pop().textContent).toBe('1');
- expect(sizzle('field[var="muc#roomconfig_changesubject"] value', sent_stanza).pop().textContent).toBe('0');
- expect(sizzle('field[var="muc#roomconfig_whois"] value ', sent_stanza).pop().textContent).toBe('anyone');
- expect(sizzle('field[var="muc#roomconfig_membersonly"] value', sent_stanza).pop().textContent).toBe('1');
- expect(sizzle('field[var="muc#roomconfig_historylength"] value', sent_stanza).pop().textContent).toBe('20');
- done();
+ _converse.muc_instant_rooms = false;
+ var sendIQ = _converse.connection.sendIQ;
+ spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
+ sent_IQ = iq;
+ sent_IQ_els.push(iq.nodeTree);
+ IQ_id = sendIQ.bind(this)(iq, callback, errback);
});
+ // Test with configuration
+ room = await _converse.api.rooms.open('room@conference.example.org', {
+ 'nick': 'some1',
+ 'auto_configure': true,
+ 'roomconfig': {
+ 'changesubject': false,
+ 'membersonly': true,
+ 'persistentroom': true,
+ 'publicroom': true,
+ 'roomdesc': 'Welcome to this groupchat',
+ 'whois': 'anyone'
+ }
+ });
+ chatroomview = _converse.chatboxviews.get('room@conference.example.org');
+
+ // We pretend this is a new room, so no disco info is returned.
+ var features_stanza = $iq({
+ from: 'room@conference.example.org',
+ 'id': IQ_id,
+ 'to': 'dummy@localhost/desktop',
+ 'type': 'error'
+ }).c('error', {'type': 'cancel'})
+ .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});
+ _converse.connection._dataRecv(test_utils.createRequest(features_stanza));
+
+ /*
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+ var presence = $pres({
+ from:'room@conference.example.org/some1',
+ to:'dummy@localhost/pda'
+ })
+ .c('x', {xmlns:'http://jabber.org/protocol/muc#user'})
+ .c('item', {
+ affiliation: 'owner',
+ jid: 'dummy@localhost/pda',
+ role: 'moderator'
+ }).up()
+ .c('status', {code:'110'}).up()
+ .c('status', {code:'201'});
+ _converse.connection._dataRecv(test_utils.createRequest(presence));
+ expect(_converse.connection.sendIQ).toHaveBeenCalled();
+ expect(sent_IQ.toLocaleString()).toBe(
+ ``+
+ ``
+ );
+ var node = Strophe.xmlHtmlNode(
+ ''+
+ ' '+
+ ' '+
+ ' Configuration for room@conference.example.org'+
+ ' Complete and submit this form to configure the room.'+
+ ' '+
+ ' http://jabber.org/protocol/muc#roomconfig'+
+ ' '+
+ ' '+
+ ' Room'+
+ ' '+
+ ' '+
+ ' '+
+ ' 1'+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ' '+
+ ' 20'+
+ ' '+
+ ' '+
+ ' ');
+
+ spyOn(chatroomview.model, 'sendConfiguration').and.callThrough();
+ _converse.connection._dataRecv(test_utils.createRequest(node.firstElementChild));
+ await test_utils.waitUntil(() => chatroomview.model.sendConfiguration.calls.count() === 1);
+ var sent_stanza = sent_IQ_els.pop();
+ while (sent_stanza.getAttribute('type') !== 'set') {
+ sent_stanza = sent_IQ_els.pop();
+ }
+ expect(sizzle('field[var="muc#roomconfig_roomname"] value', sent_stanza).pop().textContent).toBe('Room');
+ expect(sizzle('field[var="muc#roomconfig_roomdesc"] value', sent_stanza).pop().textContent).toBe('Welcome to this groupchat');
+ expect(sizzle('field[var="muc#roomconfig_persistentroom"] value', sent_stanza).pop().textContent).toBe('1');
+ expect(sizzle('field[var="muc#roomconfig_publicroom"] value ', sent_stanza).pop().textContent).toBe('1');
+ expect(sizzle('field[var="muc#roomconfig_changesubject"] value', sent_stanza).pop().textContent).toBe('0');
+ expect(sizzle('field[var="muc#roomconfig_whois"] value ', sent_stanza).pop().textContent).toBe('anyone');
+ expect(sizzle('field[var="muc#roomconfig_membersonly"] value', sent_stanza).pop().textContent).toBe('1');
+ expect(sizzle('field[var="muc#roomconfig_historylength"] value', sent_stanza).pop().textContent).toBe('20');
+ done();
}));
});
describe("An instant groupchat", function () {
it("will be created when muc_instant_rooms is set to true",
- mock.initConverseWithPromises(
- null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
- function (done, _converse) {
+ mock.initConverseWithPromises(
+ null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
+ async function (done, _converse) {
const IQ_stanzas = _converse.connection.IQ_stanzas;
const sendIQ = _converse.connection.sendIQ;
const room_jid = 'lounge@localhost';
- let sent_IQ, IQ_id, view;
+ let sent_IQ, IQ_id;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
if (iq.nodeTree.getAttribute('to') === 'lounge@localhost') {
sent_IQ = iq;
@@ -292,120 +276,115 @@
sendIQ.bind(this)(iq, callback, errback);
}
});
- test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy')
- .then(() => {
- 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(stanza => {
- // We pretend this is a new room, so no disco info is returned.
+ await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
+ let stanza = await 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'));
+ // We pretend this is a new room, so no disco info is returned.
- /*
- *
- *
- *
- *
- *
- *
- *
- */
- var features_stanza = $iq({
- 'from': 'lounge@localhost',
- 'id': stanza.getAttribute('id'),
- 'to': 'dummy@localhost/desktop',
- 'type': 'error'
- }).c('error', {'type': 'cancel'})
- .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});
- _converse.connection._dataRecv(test_utils.createRequest(features_stanza));
-
- view = _converse.chatboxviews.get('lounge@localhost');
- spyOn(view, 'join').and.callThrough();
- spyOn(view, 'submitNickname').and.callThrough();
-
- /*
- *
- *
- */
- return test_utils.waitUntil(() => _.filter(
- IQ_stanzas,
- s => sizzle(`iq[to="${room_jid}"] query[node="x-roomuser-item"]`, s.nodeTree).length
- ).pop()
- );
- }).then(node => {
- const stanza = node.nodeTree;
- expect(node.toLocaleString()).toBe(
- ``+
- ``);
-
- /*
- *
- *
- *
- *
- */
- var result_stanza = $iq({
- 'type': 'error',
+ /*
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+ const features_stanza = $iq({
+ 'from': 'lounge@localhost',
'id': stanza.getAttribute('id'),
- 'from': view.model.get('jid'),
- 'to': _converse.connection.jid
+ 'to': 'dummy@localhost/desktop',
+ 'type': 'error'
}).c('error', {'type': 'cancel'})
.c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});
- _converse.connection._dataRecv(test_utils.createRequest(result_stanza));
- return test_utils.waitUntil(() => view.el.querySelector('input[name="nick"]'));
- }).then(input => {
- input.value = 'nicky';
- view.el.querySelector('input[type=submit]').click();
- expect(view.submitNickname).toHaveBeenCalled();
- expect(view.join).toHaveBeenCalled();
+ _converse.connection._dataRecv(test_utils.createRequest(features_stanza));
- // The user has just entered the room (because join was called)
- // and receives their own presence from the server.
- // See example 24:
- // http://xmpp.org/extensions/xep-0045.html#enter-pres
- //
- /*
- *
- *
- *
- *
- *
- *
- */
- var presence = $pres({
- to:'dummy@localhost/resource',
- from:'lounge@localhost/thirdwitch',
- id:'5025e055-036c-4bc5-a227-706e7e352053'
- }).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
- .c('item').attrs({
- affiliation: 'owner',
- jid: 'dummy@localhost/resource',
- role: 'moderator'
- }).up()
- .c('status').attrs({code:'110'}).up()
- .c('status').attrs({code:'201'}).nodeTree;
+ const view = _converse.chatboxviews.get('lounge@localhost');
+ spyOn(view, 'join').and.callThrough();
+ spyOn(view, 'submitNickname').and.callThrough();
- _converse.connection._dataRecv(test_utils.createRequest(presence));
- var info_text = view.el.querySelector('.chat-content .chat-info').textContent;
- expect(info_text).toBe('A new groupchat has been created');
+ /*
+ *
+ *
+ */
+ const node = await test_utils.waitUntil(() => _.filter(
+ IQ_stanzas,
+ s => sizzle(`iq[to="${room_jid}"] query[node="x-roomuser-item"]`, s.nodeTree).length
+ ).pop()
+ );
+ stanza = node.nodeTree;
+ expect(node.toLocaleString()).toBe(
+ ``+
+ ``);
- // An instant room is created by saving the default configuratoin.
- //
- /*
- *
- *
- */
- expect(sent_IQ.toLocaleString()).toBe(
- ``+
- ``+
- ``);
- done();
- }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
+ /*
+ *
+ *
+ *
+ *
+ */
+ var result_stanza = $iq({
+ 'type': 'error',
+ 'id': stanza.getAttribute('id'),
+ 'from': view.model.get('jid'),
+ 'to': _converse.connection.jid
+ }).c('error', {'type': 'cancel'})
+ .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"});
+ _converse.connection._dataRecv(test_utils.createRequest(result_stanza));
+ const input = await test_utils.waitUntil(() => view.el.querySelector('input[name="nick"]'));
+ input.value = 'nicky';
+ view.el.querySelector('input[type=submit]').click();
+ expect(view.submitNickname).toHaveBeenCalled();
+ expect(view.join).toHaveBeenCalled();
+
+ // The user has just entered the room (because join was called)
+ // and receives their own presence from the server.
+ // See example 24:
+ // http://xmpp.org/extensions/xep-0045.html#enter-pres
+ //
+ /*
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+ var presence = $pres({
+ to:'dummy@localhost/resource',
+ from:'lounge@localhost/thirdwitch',
+ id:'5025e055-036c-4bc5-a227-706e7e352053'
+ }).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
+ .c('item').attrs({
+ affiliation: 'owner',
+ jid: 'dummy@localhost/resource',
+ role: 'moderator'
+ }).up()
+ .c('status').attrs({code:'110'}).up()
+ .c('status').attrs({code:'201'}).nodeTree;
+
+ _converse.connection._dataRecv(test_utils.createRequest(presence));
+ var info_text = view.el.querySelector('.chat-content .chat-info').textContent;
+ expect(info_text).toBe('A new groupchat has been created');
+
+ // An instant room is created by saving the default configuratoin.
+ //
+ /*
+ *
+ *
+ */
+ expect(sent_IQ.toLocaleString()).toBe(
+ ``+
+ ``+
+ ``);
+ done();
}));
});
@@ -441,63 +420,60 @@
}));
it("shows a notification if its not anonymous",
- mock.initConverseWithPromises(
- null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
- function (done, _converse) {
+ mock.initConverseWithPromises(
+ null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
+ async function (done, _converse) {
- test_utils.openChatRoom(_converse, "coven", 'chat.shakespeare.lit', 'some1')
- .then(() => {
- const view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
- const chat_content = view.el.querySelector('.chat-content');
- /*
- *
- *
- *
- *
- *
- *