Commit 1a3526f5 authored by JC Brand's avatar JC Brand

Update `openAndEnterChatRoom` to take JID

parent da1d8764
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'tom'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'tom');
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
['dick', 'harry'].forEach((nick) => { ['dick', 'harry'].forEach((nick) => {
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
expect(view.model.occupants.length).toBe(1); expect(view.model.occupants.length).toBe(1);
let presence = $pres({ let presence = $pres({
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
expect(view.model.occupants.length).toBe(1); expect(view.model.occupants.length).toBe(1);
const presence = $pres({ const presence = $pres({
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
async (done, _converse) => { async (done, _converse) => {
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
test_utils.waitUntilDiscoConfirmed( test_utils.waitUntilDiscoConfirmed(
_converse, _converse.domain, _converse, _converse.domain,
[{'category': 'server', 'type':'IM'}], [{'category': 'server', 'type':'IM'}],
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
await test_utils.waitUntilDiscoConfirmed(_converse, _converse.domain, [], [], ['upload.montague.lit'], 'items'); await test_utils.waitUntilDiscoConfirmed(_converse, _converse.domain, [], [], ['upload.montague.lit'], 'items');
await test_utils.waitUntilDiscoConfirmed(_converse, 'upload.montague.lit', [], [Strophe.NS.HTTPUPLOAD], []); await test_utils.waitUntilDiscoConfirmed(_converse, 'upload.montague.lit', [], [Strophe.NS.HTTPUPLOAD], []);
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
await test_utils.waitUntil(() => _converse.chatboxviews.get('lounge@montague.lit').el.querySelector('.upload-file')); await test_utils.waitUntil(() => _converse.chatboxviews.get('lounge@montague.lit').el.querySelector('.upload-file'));
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
expect(view.el.querySelector('.chat-toolbar .upload-file')).not.toBe(null); expect(view.el.querySelector('.chat-toolbar .upload-file')).not.toBe(null);
...@@ -365,7 +365,7 @@ ...@@ -365,7 +365,7 @@
await test_utils.waitUntilDiscoConfirmed(_converse, _converse.domain, [], [], ['upload.montague.tld'], 'items'); await test_utils.waitUntilDiscoConfirmed(_converse, _converse.domain, [], [], ['upload.montague.tld'], 'items');
await test_utils.waitUntilDiscoConfirmed(_converse, 'upload.montague.tld', [], [Strophe.NS.HTTPUPLOAD], []); await test_utils.waitUntilDiscoConfirmed(_converse, 'upload.montague.tld', [], [Strophe.NS.HTTPUPLOAD], []);
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
// Wait until MAM query has been sent out // Wait until MAM query has been sent out
const sent_stanzas = _converse.connection.sent_stanzas; const sent_stanzas = _converse.connection.sent_stanzas;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
null, ['discoInitialized'], {}, null, ['discoInitialized'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'trek-radio', 'conference.lightwitch.org', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'trek-radio@conference.lightwitch.org', 'romeo');
const view = _converse.chatboxviews.get('trek-radio@conference.lightwitch.org'); const view = _converse.chatboxviews.get('trek-radio@conference.lightwitch.org');
let stanza = u.toStanza( let stanza = u.toStanza(
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
null, ['discoInitialized'], {}, null, ['discoInitialized'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'trek-radio', 'conference.lightwitch.org', 'jcbrand'); await test_utils.openAndEnterChatRoom(_converse, 'trek-radio@conference.lightwitch.org', 'jcbrand');
const view = _converse.chatboxviews.get('trek-radio@conference.lightwitch.org'); const view = _converse.chatboxviews.get('trek-radio@conference.lightwitch.org');
let stanza = u.toStanza( let stanza = u.toStanza(
`<message xmlns="jabber:client" to="jcbrand@lightwitch.org/converse.js-73057452" type="groupchat" from="trek-radio@conference.lightwitch.org/comndrdukath#0805 (STO)"> `<message xmlns="jabber:client" to="jcbrand@lightwitch.org/converse.js-73057452" type="groupchat" from="trek-radio@conference.lightwitch.org/comndrdukath#0805 (STO)">
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
null, ['discoInitialized'], {}, null, ['discoInitialized'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'discuss', 'conference.conversejs.org', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'discuss@conference.conversejs.org', 'romeo');
const view = _converse.chatboxviews.get('discuss@conference.conversejs.org'); const view = _converse.chatboxviews.get('discuss@conference.conversejs.org');
let stanza = u.toStanza( let stanza = u.toStanza(
`<message xmlns="jabber:client" to="romeo@montague.lit/orchard" from="discuss@conference.conversejs.org"> `<message xmlns="jabber:client" to="romeo@montague.lit/orchard" from="discuss@conference.conversejs.org">
......
This diff is collapsed.
...@@ -153,30 +153,26 @@ ...@@ -153,30 +153,26 @@
it("shows the number messages received to minimized groupchats", it("shows the number messages received to minimized groupchats",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { async function (done, _converse) {
const room_jid = 'kitchen@conference.shakespeare.lit';
test_utils.openAndEnterChatRoom(
_converse, 'kitchen', 'conference.shakespeare.lit', 'fires').then(function () {
var view = _converse.chatboxviews.get(room_jid);
view.model.set({'minimized': true});
var contact_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@montague.lit'; const muc_jid = 'kitchen@conference.shakespeare.lit';
var message = 'fires: Your attention is required'; await test_utils.openAndEnterChatRoom(_converse, 'kitchen@conference.shakespeare.lit', 'fires');
var nick = mock.chatroom_names[0], const view = _converse.chatboxviews.get(muc_jid);
msg = $msg({ view.model.set({'minimized': true});
from: room_jid+'/'+nick, const contact_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@montague.lit';
id: (new Date()).getTime(), const message = 'fires: Your attention is required';
to: 'romeo@montague.lit', const nick = mock.chatroom_names[0];
type: 'groupchat' const msg = $msg({
}).c('body').t(message).tree(); from: muc_jid+'/'+nick,
view.model.onMessage(msg); id: (new Date()).getTime(),
return test_utils.waitUntil(() => view.model.messages.length); to: 'romeo@montague.lit',
}).then(() => { type: 'groupchat'
expect(u.isVisible(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count'))).toBeTruthy(); }).c('body').t(message).tree();
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe('1'); view.model.onMessage(msg);
done(); await test_utils.waitUntil(() => view.model.messages.length);
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)) expect(u.isVisible(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count'))).toBeTruthy();
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe('1');
done();
})); }));
}); });
})); }));
This diff is collapsed.
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
async (done, _converse) => { async (done, _converse) => {
await test_utils.createContacts(_converse, 'current'); await test_utils.createContacts(_converse, 'current');
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
const view = _converse.api.chatviews.get('lounge@montague.lit'); const view = _converse.api.chatviews.get('lounge@montague.lit');
if (!view.el.querySelectorAll('.chat-area').length) { if (!view.el.querySelectorAll('.chat-area').length) {
view.renderChatArea(); view.renderChatArea();
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
async (done, _converse) => { async (done, _converse) => {
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
_converse.play_sounds = true; _converse.play_sounds = true;
spyOn(_converse, 'playSoundNotification'); spyOn(_converse, 'playSoundNotification');
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
......
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
'muc_unmoderated', 'muc_unmoderated',
'muc_nonanonymous' 'muc_nonanonymous'
]; ];
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo', features); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo', features);
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
await test_utils.waitUntil(() => initializedOMEMO(_converse)); await test_utils.waitUntil(() => initializedOMEMO(_converse));
...@@ -490,7 +490,7 @@ ...@@ -490,7 +490,7 @@
'muc_unmoderated', 'muc_unmoderated',
'muc_nonanonymous' 'muc_nonanonymous'
]; ];
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo', features); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo', features);
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
await test_utils.waitUntil(() => initializedOMEMO(_converse)); await test_utils.waitUntil(() => initializedOMEMO(_converse));
...@@ -1282,7 +1282,7 @@ ...@@ -1282,7 +1282,7 @@
['http://jabber.org/protocol/pubsub#publish-options'] ['http://jabber.org/protocol/pubsub#publish-options']
); );
// MEMO encryption works only in members-only conferences that are non-anonymous. // MEMO encryption works only in members-only conferences that are non-anonymous.
const features = [ const features = [
'http://jabber.org/protocol/muc', 'http://jabber.org/protocol/muc',
'jabber:iq:register', 'jabber:iq:register',
...@@ -1293,7 +1293,7 @@ ...@@ -1293,7 +1293,7 @@
'muc_unmoderated', 'muc_unmoderated',
'muc_nonanonymous' 'muc_nonanonymous'
]; ];
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo', features); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo', features);
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
await test_utils.waitUntil(() => initializedOMEMO(_converse)); await test_utils.waitUntil(() => initializedOMEMO(_converse));
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
async function (done, _converse) { async function (done, _converse) {
test_utils.openControlBox(); test_utils.openControlBox();
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
const view = _converse.chatboxviews.get('lounge@montague.lit'), const view = _converse.chatboxviews.get('lounge@montague.lit'),
occupants = view.el.querySelector('.occupant-list'); occupants = view.el.querySelector('.occupant-list');
_.rangeRight(3000, 0).forEach(i => { _.rangeRight(3000, 0).forEach(i => {
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
expect(_converse.session.get('push_enabled').length).toBe(1); expect(_converse.session.get('push_enabled').length).toBe(1);
expect(_.includes(_converse.session.get('push_enabled'), 'romeo@montague.lit')).toBe(true); expect(_.includes(_converse.session.get('push_enabled'), 'romeo@montague.lit')).toBe(true);
test_utils.openAndEnterChatRoom(_converse, 'coven', 'chat.shakespeare.lit', 'oldhag'); test_utils.openAndEnterChatRoom(_converse, 'coven@chat.shakespeare.lit', 'oldhag');
await test_utils.waitUntilDiscoConfirmed( await test_utils.waitUntilDiscoConfirmed(
_converse, 'chat.shakespeare.lit', _converse, 'chat.shakespeare.lit',
[{'category': 'account', 'type':'registered'}], [{'category': 'account', 'type':'registered'}],
......
...@@ -16,59 +16,54 @@ ...@@ -16,59 +16,54 @@
it("allows you to register your nickname in a room", it("allows you to register your nickname in a room",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'auto_register_muc_nickname': true}, null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'auto_register_muc_nickname': true},
function (done, _converse) { async function (done, _converse) {
let view; const muc_jid = 'coven@chat.shakespeare.lit';
const room_jid = 'coven@chat.shakespeare.lit'; await test_utils.openAndEnterChatRoom(_converse, muc_jid, 'romeo')
test_utils.openAndEnterChatRoom(_converse, 'coven', 'chat.shakespeare.lit', 'romeo') const view = _converse.chatboxviews.get(muc_jid);
.then(() => { const textarea = view.el.querySelector('.chat-textarea')
view = _converse.chatboxviews.get(room_jid); textarea.value = '/register';
const textarea = view.el.querySelector('.chat-textarea') view.onKeyDown({
textarea.value = '/register'; target: textarea,
view.onKeyDown({ preventDefault: _.noop,
target: textarea, keyCode: 13
preventDefault: _.noop, });
keyCode: 13 let stanza = await test_utils.waitUntil(() => _.filter(
}); _converse.connection.IQ_stanzas,
return test_utils.waitUntil(() => _.filter( iq => sizzle(`iq[to="${muc_jid}"][type="get"] query[xmlns="jabber:iq:register"]`, iq).length
_converse.connection.IQ_stanzas, ).pop());
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`, iq).length expect(Strophe.serialize(stanza))
).pop());
}).then(stanza => {
expect(Strophe.serialize(stanza))
.toBe(`<iq from="romeo@montague.lit/orchard" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" `+ .toBe(`<iq from="romeo@montague.lit/orchard" 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>`);
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': 'result',
'type': 'result', }).c('query', {'type': 'jabber:iq:register'})
}).c('query', {'type': 'jabber:iq:register'}) .c('x', {'xmlns': 'jabber:x:data', 'type': 'form'})
.c('x', {'xmlns': 'jabber:x:data', 'type': 'form'}) .c('field', {
.c('field', { 'label': 'Desired Nickname',
'label': 'Desired Nickname', 'type': 'text-single',
'type': 'text-single', 'var': 'muc#register_roomnick'
'var': 'muc#register_roomnick' }).c('required');
}).c('required'); _converse.connection._dataRecv(test_utils.createRequest(result));
_converse.connection._dataRecv(test_utils.createRequest(result)); stanza = await test_utils.waitUntil(() => _.filter(
return test_utils.waitUntil(() => _.filter( _converse.connection.IQ_stanzas,
_converse.connection.IQ_stanzas, iq => sizzle(`iq[to="${muc_jid}"][type="set"] query[xmlns="jabber:iq:register"]`, iq).length
iq => sizzle(`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`, iq).length ).pop());
).pop());
}).then(stanza => { expect(Strophe.serialize(stanza)).toBe(
expect(Strophe.serialize(stanza)).toBe( `<iq from="romeo@montague.lit/orchard" id="${stanza.getAttribute('id')}" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`+
`<iq from="romeo@montague.lit/orchard" 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">`+ `<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`+
`<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`+ `<field var="muc#register_roomnick"><value>romeo</value></field>`+
`<field var="muc#register_roomnick"><value>romeo</value></field>`+ `</x>`+
`</x>`+ `</query>`+
`</query>`+ `</iq>`);
`</iq>`); done();
done();
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
})); }));
}); });
...@@ -81,9 +76,9 @@ ...@@ -81,9 +76,9 @@
async function (done, _converse) { async function (done, _converse) {
const IQ_stanzas = _converse.connection.IQ_stanzas; const IQ_stanzas = _converse.connection.IQ_stanzas;
const room_jid = 'coven@chat.shakespeare.lit'; const muc_jid = 'coven@chat.shakespeare.lit';
await test_utils.openAndEnterChatRoom(_converse, 'coven', 'chat.shakespeare.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'coven@chat.shakespeare.lit', 'romeo');
const view = _converse.chatboxviews.get(room_jid); const view = _converse.chatboxviews.get(muc_jid);
let stanza = await test_utils.waitUntil(() => _.filter( let stanza = await test_utils.waitUntil(() => _.filter(
_converse.connection.IQ_stanzas, _converse.connection.IQ_stanzas,
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
{'connection': ['send']}, ['rosterGroupsFetched', 'chatBoxesFetched'], {'view_mode': 'fullscreen'}, {'connection': ['send']}, ['rosterGroupsFetched', 'chatBoxesFetched'], {'view_mode': 'fullscreen'},
async function (done, _converse) { async function (done, _converse) {
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'montague.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
const view = _converse.chatboxviews.get('lounge@montague.lit'); const view = _converse.chatboxviews.get('lounge@montague.lit');
const contact_jid = 'newguy@montague.lit'; const contact_jid = 'newguy@montague.lit';
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
test_utils.openControlBox(); test_utils.openControlBox();
const room_jid = 'kitchen@conference.shakespeare.lit'; const room_jid = 'kitchen@conference.shakespeare.lit';
await test_utils.waitUntil(() => !_.isUndefined(_converse.rooms_list_view), 500); await test_utils.waitUntil(() => !_.isUndefined(_converse.rooms_list_view), 500);
await test_utils.openAndEnterChatRoom(_converse, 'kitchen', 'conference.shakespeare.lit', 'romeo'); await test_utils.openAndEnterChatRoom(_converse, 'kitchen@conference.shakespeare.lit', 'romeo');
const view = _converse.chatboxviews.get(room_jid); const view = _converse.chatboxviews.get(room_jid);
view.model.set({'minimized': true}); view.model.set({'minimized': true});
const contact_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@montague.lit'; const contact_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@montague.lit';
......
...@@ -49,32 +49,30 @@ ...@@ -49,32 +49,30 @@
return describe("Transcripts of chat logs", function () { return describe("Transcripts of chat logs", function () {
it("can be used to replay conversations", it("can be used to replay conversations",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { async function (done, _converse) {
_converse.allow_non_roster_messaging = true; _converse.allow_non_roster_messaging = true;
await test_utils.openAndEnterChatRoom(_converse, 'discuss@conference.conversejs.org', 'romeo');
test_utils.openAndEnterChatRoom(_converse, 'discuss', 'conference.conversejs.org', 'romeo').then(function () { spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true); _.each(transcripts, function (transcript) {
_.each(transcripts, function (transcript) { const text = transcript();
var text = transcript(); const xml = Strophe.xmlHtmlNode(text);
var xml = Strophe.xmlHtmlNode(text); _.each(xml.firstElementChild.children, function (el) {
_.each(xml.firstElementChild.children, function (el) { _.each(el.children, function (el) {
_.each(el.children, function (el) { if (el.nodeType === 3) {
if (el.nodeType === 3) { return; // Ignore text
return; // Ignore text }
} if (_.includes(IGNORED_TAGS, el.nodeName.toLowerCase())) {
if (_.includes(IGNORED_TAGS, el.nodeName.toLowerCase())) { return;
return; }
} const _stanza = traverseElement(el);
var _stanza = traverseElement(el); _converse.connection._dataRecv(test_utils.createRequest(_stanza));
_converse.connection._dataRecv(test_utils.createRequest(_stanza));
});
}); });
}); });
done();
}); });
done();
})); }));
}); });
})); }));
...@@ -164,7 +164,9 @@ ...@@ -164,7 +164,9 @@
_converse.connection._dataRecv(utils.createRequest(features_stanza)); _converse.connection._dataRecv(utils.createRequest(features_stanza));
}; };
utils.openAndEnterChatRoom = async function (_converse, room, server, nick, features=[]) { utils.openAndEnterChatRoom = async function (_converse, muc_jid, nick, features=[]) {
const room = Strophe.getNodeFromJid(muc_jid);
const server = Strophe.getDomainFromJid(muc_jid);
const room_jid = `${room}@${server}`.toLowerCase(); const room_jid = `${room}@${server}`.toLowerCase();
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);
......
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