|
@@ -224,69 +224,64 @@
|
|
}));
|
|
}));
|
|
|
|
|
|
it("shows unread messages directed at the user", mock.initConverseWithAsync(
|
|
it("shows unread messages directed at the user", mock.initConverseWithAsync(
|
|
- { whitelisted_plugins: ['converse-roomslist'],
|
|
|
|
- allow_bookmarks: false // Makes testing easier, otherwise we
|
|
|
|
- // have to mock stanza traffic.
|
|
|
|
- }, function (done, _converse) {
|
|
|
|
|
|
+ { whitelisted_plugins: ['converse-roomslist'],
|
|
|
|
+ allow_bookmarks: false // Makes testing easier, otherwise we
|
|
|
|
+ // have to mock stanza traffic.
|
|
|
|
+ }, function (done, _converse) {
|
|
|
|
|
|
- test_utils.waitUntil(function () {
|
|
|
|
- return !_.isUndefined(_converse.rooms_list_view)
|
|
|
|
- }, 500)
|
|
|
|
- .then(function () {
|
|
|
|
- var room_jid = 'kitchen@conference.shakespeare.lit';
|
|
|
|
- test_utils.openAndEnterChatRoom(
|
|
|
|
- _converse, 'kitchen', 'conference.shakespeare.lit', 'romeo').then(function () {
|
|
|
|
-
|
|
|
|
- var view = _converse.chatboxviews.get(room_jid);
|
|
|
|
- view.model.set({'minimized': true});
|
|
|
|
- var contact_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
|
- var nick = mock.chatroom_names[0];
|
|
|
|
- view.model.onMessage(
|
|
|
|
- $msg({
|
|
|
|
- from: room_jid+'/'+nick,
|
|
|
|
- id: (new Date()).getTime(),
|
|
|
|
- to: 'dummy@localhost',
|
|
|
|
- type: 'groupchat'
|
|
|
|
- }).c('body').t('foo').tree());
|
|
|
|
|
|
+ test_utils.waitUntil(() => !_.isUndefined(_converse.rooms_list_view), 500)
|
|
|
|
+ .then(() => test_utils.openAndEnterChatRoom(_converse, 'kitchen', 'conference.shakespeare.lit', 'romeo'))
|
|
|
|
+ .then(() => {
|
|
|
|
+ const room_jid = 'kitchen@conference.shakespeare.lit';
|
|
|
|
+ const view = _converse.chatboxviews.get(room_jid);
|
|
|
|
+ view.model.set({'minimized': true});
|
|
|
|
+ const contact_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
|
+ const nick = mock.chatroom_names[0];
|
|
|
|
+ view.model.onMessage(
|
|
|
|
+ $msg({
|
|
|
|
+ from: room_jid+'/'+nick,
|
|
|
|
+ id: (new Date()).getTime(),
|
|
|
|
+ to: 'dummy@localhost',
|
|
|
|
+ type: 'groupchat'
|
|
|
|
+ }).c('body').t('foo').tree());
|
|
|
|
|
|
- // If the user isn't mentioned, the counter doesn't get incremented, but the text of the groupchat is bold
|
|
|
|
- var room_el = _converse.rooms_list_view.el.querySelector(
|
|
|
|
- ".available-chatroom"
|
|
|
|
- );
|
|
|
|
- expect(_.includes(room_el.classList, 'unread-msgs'));
|
|
|
|
|
|
+ // If the user isn't mentioned, the counter doesn't get incremented, but the text of the groupchat is bold
|
|
|
|
+ var room_el = _converse.rooms_list_view.el.querySelector(
|
|
|
|
+ ".available-chatroom"
|
|
|
|
+ );
|
|
|
|
+ expect(_.includes(room_el.classList, 'unread-msgs'));
|
|
|
|
|
|
- // If the user is mentioned, the counter also gets updated
|
|
|
|
- view.model.onMessage(
|
|
|
|
- $msg({
|
|
|
|
- from: room_jid+'/'+nick,
|
|
|
|
- id: (new Date()).getTime(),
|
|
|
|
- to: 'dummy@localhost',
|
|
|
|
- type: 'groupchat'
|
|
|
|
- }).c('body').t('romeo: Your attention is required').tree()
|
|
|
|
- );
|
|
|
|
- var indicator_el = _converse.rooms_list_view.el.querySelector(".msgs-indicator");
|
|
|
|
- expect(indicator_el.textContent).toBe('1');
|
|
|
|
|
|
+ // If the user is mentioned, the counter also gets updated
|
|
|
|
+ view.model.onMessage(
|
|
|
|
+ $msg({
|
|
|
|
+ from: room_jid+'/'+nick,
|
|
|
|
+ id: (new Date()).getTime(),
|
|
|
|
+ to: 'dummy@localhost',
|
|
|
|
+ type: 'groupchat'
|
|
|
|
+ }).c('body').t('romeo: Your attention is required').tree()
|
|
|
|
+ );
|
|
|
|
+ var indicator_el = _converse.rooms_list_view.el.querySelector(".msgs-indicator");
|
|
|
|
+ expect(indicator_el.textContent).toBe('1');
|
|
|
|
|
|
- view.model.onMessage(
|
|
|
|
- $msg({
|
|
|
|
- from: room_jid+'/'+nick,
|
|
|
|
- id: (new Date()).getTime(),
|
|
|
|
- to: 'dummy@localhost',
|
|
|
|
- type: 'groupchat'
|
|
|
|
- }).c('body').t('romeo: and another thing...').tree()
|
|
|
|
- );
|
|
|
|
- indicator_el = _converse.rooms_list_view.el.querySelector(".msgs-indicator");
|
|
|
|
- expect(indicator_el.textContent).toBe('2');
|
|
|
|
|
|
+ view.model.onMessage(
|
|
|
|
+ $msg({
|
|
|
|
+ from: room_jid+'/'+nick,
|
|
|
|
+ id: (new Date()).getTime(),
|
|
|
|
+ to: 'dummy@localhost',
|
|
|
|
+ type: 'groupchat'
|
|
|
|
+ }).c('body').t('romeo: and another thing...').tree()
|
|
|
|
+ );
|
|
|
|
+ indicator_el = _converse.rooms_list_view.el.querySelector(".msgs-indicator");
|
|
|
|
+ expect(indicator_el.textContent).toBe('2');
|
|
|
|
|
|
- // When the chat gets maximized again, the unread indicators are removed
|
|
|
|
- view.model.set({'minimized': false});
|
|
|
|
- indicator_el = _converse.rooms_list_view.el.querySelector(".msgs-indicator");
|
|
|
|
- expect(_.isNull(indicator_el));
|
|
|
|
- room_el = _converse.rooms_list_view.el.querySelector(".available-chatroom");
|
|
|
|
- expect(_.includes(room_el.classList, 'unread-msgs')).toBeFalsy();
|
|
|
|
- done();
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ // When the chat gets maximized again, the unread indicators are removed
|
|
|
|
+ view.model.set({'minimized': false});
|
|
|
|
+ indicator_el = _converse.rooms_list_view.el.querySelector(".msgs-indicator");
|
|
|
|
+ expect(_.isNull(indicator_el));
|
|
|
|
+ room_el = _converse.rooms_list_view.el.querySelector(".available-chatroom");
|
|
|
|
+ expect(_.includes(room_el.classList, 'unread-msgs')).toBeFalsy();
|
|
|
|
+ done();
|
|
|
|
+ }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
|
|
}));
|
|
}));
|
|
});
|
|
});
|
|
}));
|
|
}));
|