Commit 0653505a authored by JC Brand's avatar JC Brand

tests: Use `u.getUniqueId` instead of time for message ids

parent fb9fe280
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
from: contact_jid, from: contact_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t('hello world').tree(); }).c('body').t('hello world').tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
await u.waitUntil(() => view.content.querySelectorAll('.chat-msg').length); await u.waitUntil(() => view.content.querySelectorAll('.chat-msg').length);
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
...@@ -535,7 +535,7 @@ ...@@ -535,7 +535,7 @@
'from': sender_jid, 'from': sender_jid,
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': (new Date()).getTime() 'id': u.getUniqueId()
}).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
spyOn(_converse.api, "trigger").and.callThrough(); spyOn(_converse.api, "trigger").and.callThrough();
...@@ -685,7 +685,7 @@ ...@@ -685,7 +685,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
spyOn(_converse.api, "trigger").and.callThrough(); spyOn(_converse.api, "trigger").and.callThrough();
...@@ -703,7 +703,7 @@ ...@@ -703,7 +703,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
const events = view.el.querySelectorAll('.chat-state-notification'); const events = view.el.querySelectorAll('.chat-state-notification');
...@@ -725,7 +725,7 @@ ...@@ -725,7 +725,7 @@
const view = await test_utils.openChatBoxFor(_converse, recipient_jid); const view = await test_utils.openChatBoxFor(_converse, recipient_jid);
const msg = $msg({ const msg = $msg({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'xmlns': 'jabber:client' 'xmlns': 'jabber:client'
...@@ -829,7 +829,7 @@ ...@@ -829,7 +829,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('paused', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('paused', {'xmlns': Strophe.NS.CHATSTATES}).tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
expect(_converse.api.trigger).toHaveBeenCalledWith('message', jasmine.any(Object)); expect(_converse.api.trigger).toHaveBeenCalledWith('message', jasmine.any(Object));
...@@ -852,7 +852,7 @@ ...@@ -852,7 +852,7 @@
const view = await test_utils.openChatBoxFor(_converse, recipient_jid); const view = await test_utils.openChatBoxFor(_converse, recipient_jid);
const msg = $msg({ const msg = $msg({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'xmlns': 'jabber:client' 'xmlns': 'jabber:client'
...@@ -1021,7 +1021,7 @@ ...@@ -1021,7 +1021,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('inactive', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('inactive', {'xmlns': Strophe.NS.CHATSTATES}).tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
await u.waitUntil(() => (view.model.messages.length > 1)); await u.waitUntil(() => (view.model.messages.length > 1));
...@@ -1048,7 +1048,7 @@ ...@@ -1048,7 +1048,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').c('gone', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('body').c('gone', {'xmlns': Strophe.NS.CHATSTATES}).tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
expect(_converse.api.trigger).toHaveBeenCalledWith('message', jasmine.any(Object)); expect(_converse.api.trigger).toHaveBeenCalledWith('message', jasmine.any(Object));
...@@ -1128,7 +1128,7 @@ ...@@ -1128,7 +1128,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': Strophe.NS.CHATSTATES}).tree(); .c('active', {'xmlns': Strophe.NS.CHATSTATES}).tree();
_converse.windowState = 'hidden'; _converse.windowState = 'hidden';
...@@ -1179,7 +1179,7 @@ ...@@ -1179,7 +1179,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': Strophe.NS.CHATSTATES}).tree(); .c('active', {'xmlns': Strophe.NS.CHATSTATES}).tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
...@@ -1203,7 +1203,7 @@ ...@@ -1203,7 +1203,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}) })
.c('body').t(message).up() .c('body').t(message).up()
.c('active', {'xmlns': Strophe.NS.CHATSTATES}) .c('active', {'xmlns': Strophe.NS.CHATSTATES})
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t('hello').up() }).c('body').t('hello').up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
_converse.handleMessageStanza(msg); _converse.handleMessageStanza(msg);
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t('hello again').up() }).c('body').t('hello again').up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
_converse.handleMessageStanza(msg); _converse.handleMessageStanza(msg);
......
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
'from': contact_jid, 'from': contact_jid,
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': (new Date()).getTime() 'id': u.getUniqueId()
}).c('body').t('Hello').up() }).c('body').t('Hello').up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree() .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()
); );
...@@ -525,7 +525,7 @@ ...@@ -525,7 +525,7 @@
from: 'montague.lit', from: 'montague.lit',
to: _converse.bare_jid, to: _converse.bare_jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t("This headline message will not be shown").tree(); }).c('body').t("This headline message will not be shown").tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
expect(converse.env.log.info.calledWith( expect(converse.env.log.info.calledWith(
...@@ -556,7 +556,7 @@ ...@@ -556,7 +556,7 @@
const sender_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@montague.lit'; const sender_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@montague.lit';
const msg = $msg({ const msg = $msg({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'xmlns': 'jabber:client' 'xmlns': 'jabber:client'
...@@ -607,7 +607,7 @@ ...@@ -607,7 +607,7 @@
const recipient_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@montague.lit'; const recipient_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@montague.lit';
const msg = $msg({ const msg = $msg({
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'xmlns': 'jabber:client' 'xmlns': 'jabber:client'
...@@ -663,7 +663,7 @@ ...@@ -663,7 +663,7 @@
const impersonated_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@montague.lit'; const impersonated_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@montague.lit';
const msg = $msg({ const msg = $msg({
'from': sender_jid, 'from': sender_jid,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'xmlns': 'jabber:client' 'xmlns': 'jabber:client'
...@@ -714,7 +714,7 @@ ...@@ -714,7 +714,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
...@@ -733,7 +733,7 @@ ...@@ -733,7 +733,7 @@
from: mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit', from: mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit',
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t('This message is also sent to a minimized chatbox').up() }).c('body').t('This message is also sent to a minimized chatbox').up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree() .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()
); );
...@@ -1076,7 +1076,7 @@ ...@@ -1076,7 +1076,7 @@
'from': sender_jid, 'from': sender_jid,
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': (new Date()).getTime() 'id': u.getUniqueId()
}).c('body').t('A message').up() }).c('body').t('A message').up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
await new Promise(resolve => _converse.on('chatBoxViewInitialized', resolve)); await new Promise(resolve => _converse.on('chatBoxViewInitialized', resolve));
...@@ -1088,7 +1088,7 @@ ...@@ -1088,7 +1088,7 @@
'from': sender_jid, 'from': sender_jid,
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': (new Date()).getTime() 'id': u.getUniqueId()
}).c('body').t("Another message 3 minutes later").up() }).c('body').t("Another message 3 minutes later").up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
await new Promise(resolve => view.once('messageInserted', resolve)); await new Promise(resolve => view.once('messageInserted', resolve));
...@@ -1098,7 +1098,7 @@ ...@@ -1098,7 +1098,7 @@
'from': sender_jid, 'from': sender_jid,
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': (new Date()).getTime() 'id': u.getUniqueId()
}).c('body').t("Another message 14 minutes since we started").up() }).c('body').t("Another message 14 minutes since we started").up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
await new Promise(resolve => view.once('messageInserted', resolve)); await new Promise(resolve => view.once('messageInserted', resolve));
...@@ -1395,7 +1395,7 @@ ...@@ -1395,7 +1395,7 @@
'from': sender_jid, 'from': sender_jid,
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': (new Date()).getTime() 'id': u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree() .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()
); );
...@@ -1436,7 +1436,7 @@ ...@@ -1436,7 +1436,7 @@
'from': sender_jid, 'from': sender_jid,
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': (new Date()).getTime() 'id': u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree() .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()
); );
...@@ -1537,7 +1537,7 @@ ...@@ -1537,7 +1537,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
...@@ -1585,7 +1585,7 @@ ...@@ -1585,7 +1585,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
...@@ -1823,7 +1823,7 @@ ...@@ -1823,7 +1823,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
await new Promise(resolve => view.once('messageInserted', resolve)); await new Promise(resolve => view.once('messageInserted', resolve));
...@@ -1858,7 +1858,7 @@ ...@@ -1858,7 +1858,7 @@
from: sender_jid, from: sender_jid,
to: _converse.bare_jid+"/some-other-resource", to: _converse.bare_jid+"/some-other-resource",
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t("This message will not be shown").up() }).c('body').t("This message will not be shown").up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
await _converse.handleMessageStanza(msg); await _converse.handleMessageStanza(msg);
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
['rosterGroupsFetched', 'chatBoxesFetched'], {}, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) { async function (done, _converse) {
await test_utils.waitForRoster(_converse, 'current'); await test_utils.waitForRoster(_converse, 'current', 4);
await test_utils.openControlBox(_converse); await test_utils.openControlBox(_converse);
_converse.minimized_chats.initToggle(); _converse.minimized_chats.initToggle();
...@@ -84,61 +84,61 @@ ...@@ -84,61 +84,61 @@
contact_jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@montague.lit'; contact_jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@montague.lit';
test_utils.openChatBoxFor(_converse, contact_jid); test_utils.openChatBoxFor(_converse, contact_jid);
} }
u.waitUntil(() => _converse.chatboxes.length == 4).then(() => { await u.waitUntil(() => _converse.chatboxes.length == 4);
for (i=0; i<3; i++) {
chatview = _converse.chatboxviews.get(contact_jid);
chatview.model.set({'minimized': true});
msg = $msg({
from: contact_jid,
to: _converse.connection.jid,
type: 'chat',
id: (new Date()).getTime()
}).c('body').t('This message is sent to a minimized chatbox').up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
_converse.handleMessageStanza(msg);
}
return u.waitUntil(() => chatview.model.messages.length);
}).then(() => {
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((3).toString());
// Chat state notifications don't increment the unread messages counter
// <composing> state
_converse.handleMessageStanza($msg({
from: contact_jid,
to: _converse.connection.jid,
type: 'chat',
id: (new Date()).getTime()
}).c('composing', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((i).toString());
// <paused> state chatview = _converse.chatboxviews.get(contact_jid);
_converse.handleMessageStanza($msg({ chatview.model.set({'minimized': true});
from: contact_jid, for (i=0; i<3; i++) {
to: _converse.connection.jid, msg = $msg({
type: 'chat',
id: (new Date()).getTime()
}).c('paused', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((i).toString());
// <gone> state
_converse.handleMessageStanza($msg({
from: contact_jid, from: contact_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('gone', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()); }).c('body').t('This message is sent to a minimized chatbox').up()
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((i).toString()); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
_converse.handleMessageStanza(msg);
}
await u.waitUntil(() => chatview.model.messages.length === 3, 500);
// <inactive> state expect(u.isVisible(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count'))).toBeTruthy();
_converse.handleMessageStanza($msg({ expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((3).toString());
from: contact_jid, // Chat state notifications don't increment the unread messages counter
to: _converse.connection.jid, // <composing> state
type: 'chat', _converse.handleMessageStanza($msg({
id: (new Date()).getTime() from: contact_jid,
}).c('inactive', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()); to: _converse.connection.jid,
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((i).toString()); type: 'chat',
done(); id: u.getUniqueId()
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)) }).c('composing', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((i).toString());
// <paused> state
_converse.handleMessageStanza($msg({
from: contact_jid,
to: _converse.connection.jid,
type: 'chat',
id: u.getUniqueId()
}).c('paused', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((i).toString());
// <gone> state
_converse.handleMessageStanza($msg({
from: contact_jid,
to: _converse.connection.jid,
type: 'chat',
id: u.getUniqueId()
}).c('gone', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((i).toString());
// <inactive> state
_converse.handleMessageStanza($msg({
from: contact_jid,
to: _converse.connection.jid,
type: 'chat',
id: u.getUniqueId()
}).c('inactive', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
expect(_converse.minimized_chats.toggleview.el.querySelector('.unread-message-count').textContent).toBe((i).toString());
done();
})); }));
it("shows the number messages received to minimized groupchats", it("shows the number messages received to minimized groupchats",
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
const nick = mock.chatroom_names[0]; const nick = mock.chatroom_names[0];
const msg = $msg({ const msg = $msg({
from: muc_jid+'/'+nick, from: muc_jid+'/'+nick,
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t(message).tree(); }).c('body').t(message).tree();
......
...@@ -490,7 +490,7 @@ ...@@ -490,7 +490,7 @@
nick = mock.chatroom_names[0], nick = mock.chatroom_names[0],
msg = $msg({ msg = $msg({
'from': 'lounge@montague.lit/'+nick, 'from': 'lounge@montague.lit/'+nick,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': 'romeo@montague.lit', 'to': 'romeo@montague.lit',
'type': 'groupchat' 'type': 'groupchat'
}).c('body').t(message).tree(); }).c('body').t(message).tree();
...@@ -521,7 +521,7 @@ ...@@ -521,7 +521,7 @@
nick = mock.chatroom_names[0], nick = mock.chatroom_names[0],
msg = $msg({ msg = $msg({
'from': 'lounge@montague.lit/'+nick, 'from': 'lounge@montague.lit/'+nick,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': 'romeo@montague.lit', 'to': 'romeo@montague.lit',
'type': 'groupchat' 'type': 'groupchat'
}).c('body').t(message).tree(); }).c('body').t(message).tree();
...@@ -644,7 +644,7 @@ ...@@ -644,7 +644,7 @@
const msg = $msg({ const msg = $msg({
'from': 'coven@chat.shakespeare.lit/some1', 'from': 'coven@chat.shakespeare.lit/some1',
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': 'romeo@montague.lit', 'to': 'romeo@montague.lit',
'type': 'groupchat' 'type': 'groupchat'
}).c('body').t('hello world').tree(); }).c('body').t('hello world').tree();
...@@ -1109,7 +1109,7 @@ ...@@ -1109,7 +1109,7 @@
const view = _converse.chatboxviews.get('conversations@conference.siacs.eu'); const view = _converse.chatboxviews.get('conversations@conference.siacs.eu');
const msg = $msg({ const msg = $msg({
'from': 'conversations@conference.siacs.eu/romeo', 'from': 'conversations@conference.siacs.eu/romeo',
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': 'romeo@montague.lit', 'to': 'romeo@montague.lit',
'type': 'groupchat' 'type': 'groupchat'
}).c('body').t('Some message').tree(); }).c('body').t('Some message').tree();
...@@ -1325,7 +1325,7 @@ ...@@ -1325,7 +1325,7 @@
const nick = mock.chatroom_names[0]; const nick = mock.chatroom_names[0];
let msg = $msg({ let msg = $msg({
'from': 'lounge@montague.lit/'+nick, 'from': 'lounge@montague.lit/'+nick,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': 'romeo@montague.lit', 'to': 'romeo@montague.lit',
'type': 'groupchat' 'type': 'groupchat'
}).c('body').t(message).tree(); }).c('body').t(message).tree();
...@@ -1336,7 +1336,7 @@ ...@@ -1336,7 +1336,7 @@
message = '/me is as well'; message = '/me is as well';
msg = $msg({ msg = $msg({
from: 'lounge@montague.lit/Romeo Montague', from: 'lounge@montague.lit/Romeo Montague',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t(message).tree(); }).c('body').t(message).tree();
...@@ -2134,7 +2134,7 @@ ...@@ -2134,7 +2134,7 @@
from: 'lounge@montague.lit/someone', from: 'lounge@montague.lit/someone',
to: 'romeo@montague.lit.com', to: 'romeo@montague.lit.com',
type: 'groupchat', type: 'groupchat',
id: (new Date()).getTime(), id: u.getUniqueId(),
}).c('body').t('Message: '+i).tree()) }).c('body').t('Message: '+i).tree())
); );
} }
...@@ -2147,7 +2147,7 @@ ...@@ -2147,7 +2147,7 @@
from: 'lounge@montague.lit/someone', from: 'lounge@montague.lit/someone',
to: 'romeo@montague.lit.com', to: 'romeo@montague.lit.com',
type: 'groupchat', type: 'groupchat',
id: (new Date()).getTime(), id: u.getUniqueId(),
}).c('body').t(message).tree()); }).c('body').t(message).tree());
// Now check that the message appears inside the chatbox in the DOM // Now check that the message appears inside the chatbox in the DOM
const chat_content = view.el.querySelector('.chat-content'); const chat_content = view.el.querySelector('.chat-content');
...@@ -4948,7 +4948,7 @@ ...@@ -4948,7 +4948,7 @@
await view.model.onMessage($msg({ await view.model.onMessage($msg({
from: muc_jid+'/'+nick, from: muc_jid+'/'+nick,
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t(message).tree()); }).c('body').t(message).tree());
...@@ -4959,7 +4959,7 @@ ...@@ -4959,7 +4959,7 @@
await view.model.onMessage($msg({ await view.model.onMessage($msg({
'from': muc_jid+'/'+nick, 'from': muc_jid+'/'+nick,
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': 'romeo@montague.lit', 'to': 'romeo@montague.lit',
'type': 'groupchat' 'type': 'groupchat'
}).c('body').t(message).tree()); }).c('body').t(message).tree());
...@@ -5078,7 +5078,7 @@ ...@@ -5078,7 +5078,7 @@
// <composing> state // <composing> state
let msg = $msg({ let msg = $msg({
from: muc_jid+'/newguy', from: muc_jid+'/newguy',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
...@@ -5103,7 +5103,7 @@ ...@@ -5103,7 +5103,7 @@
// Check that it doesn't appear twice // Check that it doesn't appear twice
msg = $msg({ msg = $msg({
from: muc_jid+'/newguy', from: muc_jid+'/newguy',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
...@@ -5123,7 +5123,7 @@ ...@@ -5123,7 +5123,7 @@
// <composing> state for a different occupant // <composing> state for a different occupant
msg = $msg({ msg = $msg({
from: muc_jid+'/nomorenicks', from: muc_jid+'/nomorenicks',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
...@@ -5143,7 +5143,7 @@ ...@@ -5143,7 +5143,7 @@
// Check that new messages appear under the chat state notifications // Check that new messages appear under the chat state notifications
msg = $msg({ msg = $msg({
from: `${muc_jid}/some1`, from: `${muc_jid}/some1`,
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('hello world').tree(); }).c('body').t('hello world').tree();
...@@ -5248,7 +5248,7 @@ ...@@ -5248,7 +5248,7 @@
// <composing> state // <composing> state
var msg = $msg({ var msg = $msg({
from: muc_jid+'/newguy', from: muc_jid+'/newguy',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
...@@ -5269,7 +5269,7 @@ ...@@ -5269,7 +5269,7 @@
// Check that it doesn't appear twice // Check that it doesn't appear twice
msg = $msg({ msg = $msg({
from: muc_jid+'/newguy', from: muc_jid+'/newguy',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
...@@ -5288,7 +5288,7 @@ ...@@ -5288,7 +5288,7 @@
// <composing> state for a different occupant // <composing> state for a different occupant
msg = $msg({ msg = $msg({
from: muc_jid+'/nomorenicks', from: muc_jid+'/nomorenicks',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
...@@ -5311,7 +5311,7 @@ ...@@ -5311,7 +5311,7 @@
// <paused> state from occupant who typed first // <paused> state from occupant who typed first
msg = $msg({ msg = $msg({
from: muc_jid+'/newguy', from: muc_jid+'/newguy',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').c('paused', {'xmlns': Strophe.NS.CHATSTATES}).tree(); }).c('body').c('paused', {'xmlns': Strophe.NS.CHATSTATES}).tree();
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
const nick = mock.chatroom_names[0], const nick = mock.chatroom_names[0],
msg = $msg({ msg = $msg({
from: 'lounge@montague.lit/'+nick, from: 'lounge@montague.lit/'+nick,
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t(message).tree(); }).c('body').t(message).tree();
...@@ -322,7 +322,7 @@ ...@@ -322,7 +322,7 @@
const view = _converse.api.chatviews.get(muc_jid); const view = _converse.api.chatviews.get(muc_jid);
let msg = $msg({ let msg = $msg({
from: 'lounge@montague.lit/romeo', from: 'lounge@montague.lit/romeo',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('I wrote this message!').tree(); }).c('body').t('I wrote this message!').tree();
...@@ -348,7 +348,7 @@ ...@@ -348,7 +348,7 @@
msg = $msg({ msg = $msg({
from: 'lounge@montague.lit/romeo', from: 'lounge@montague.lit/romeo',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('Another message!').tree(); }).c('body').t('Another message!').tree();
...@@ -383,7 +383,7 @@ ...@@ -383,7 +383,7 @@
const add_events = view.model.occupants._events.add.length; const add_events = view.model.occupants._events.add.length;
msg = $msg({ msg = $msg({
from: 'lounge@montague.lit/some1', from: 'lounge@montague.lit/some1',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('Message from someone not in the MUC right now').tree(); }).c('body').t('Message from someone not in the MUC right now').tree();
...@@ -447,7 +447,7 @@ ...@@ -447,7 +447,7 @@
const view = _converse.api.chatviews.get(muc_jid); const view = _converse.api.chatviews.get(muc_jid);
const msg = $msg({ const msg = $msg({
from: 'lounge@montague.lit/romeo', from: 'lounge@montague.lit/romeo',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('I wrote this message!').tree(); }).c('body').t('I wrote this message!').tree();
...@@ -599,7 +599,7 @@ ...@@ -599,7 +599,7 @@
// Check that messages from other users are skipped // Check that messages from other users are skipped
await view.model.onMessage($msg({ await view.model.onMessage($msg({
'from': muc_jid+'/someone-else', 'from': muc_jid+'/someone-else',
'id': (new Date()).getTime(), 'id': u.getUniqueId(),
'to': 'romeo@montague.lit', 'to': 'romeo@montague.lit',
'type': 'groupchat' 'type': 'groupchat'
}).c('body').t('Hello world').tree()); }).c('body').t('Hello world').tree());
...@@ -835,7 +835,7 @@ ...@@ -835,7 +835,7 @@
}); });
const msg = $msg({ const msg = $msg({
from: 'lounge@montague.lit/gibson', from: 'lounge@montague.lit/gibson',
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('hello z3r0 tom mr.robot, how are you?').up() }).c('body').t('hello z3r0 tom mr.robot, how are you?').up()
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
from: sender_jid, from: sender_jid,
to: _converse.connection.jid, to: _converse.connection.jid,
type: 'chat', type: 'chat',
id: (new Date()).getTime() id: u.getUniqueId()
}).c('body').t(message).up() }).c('body').t(message).up()
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
await _converse.handleMessageStanza(msg); // This will emit 'message' await _converse.handleMessageStanza(msg); // This will emit 'message'
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
const nick = mock.chatroom_names[0], const nick = mock.chatroom_names[0],
msg = $msg({ msg = $msg({
from: 'lounge@montague.lit/'+nick, from: 'lounge@montague.lit/'+nick,
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t(message).tree(); }).c('body').t(message).tree();
......
...@@ -286,7 +286,7 @@ ...@@ -286,7 +286,7 @@
await view.model.onMessage( await view.model.onMessage(
$msg({ $msg({
from: room_jid+'/'+nick, from: room_jid+'/'+nick,
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('foo').tree()); }).c('body').t('foo').tree());
...@@ -300,7 +300,7 @@ ...@@ -300,7 +300,7 @@
await view.model.onMessage( await view.model.onMessage(
$msg({ $msg({
from: room_jid+'/'+nick, from: room_jid+'/'+nick,
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('romeo: Your attention is required').tree() }).c('body').t('romeo: Your attention is required').tree()
...@@ -313,7 +313,7 @@ ...@@ -313,7 +313,7 @@
await view.model.onMessage( await view.model.onMessage(
$msg({ $msg({
from: room_jid+'/'+nick, from: room_jid+'/'+nick,
id: (new Date()).getTime(), id: u.getUniqueId(),
to: 'romeo@montague.lit', to: 'romeo@montague.lit',
type: 'groupchat' type: 'groupchat'
}).c('body').t('romeo: and another thing...').tree() }).c('body').t('romeo: and another thing...').tree()
......
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