From ca141401a079150debabcc0c019b1ef200490de8 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 11 Mar 2018 13:56:53 +0100 Subject: [PATCH] Fix failing tests --- css/converse.css | 9 +- css/inverse.css | 9 +- mockup/user-panel.html | 1 + sass/_controlbox.scss | 8 +- sass/_core.scss | 1 - spec/bookmarks.js | 4 - spec/chatbox.js | 54 -- spec/chatroom.js | 639 ++++++++++++------------ spec/controlbox.js | 132 ++--- spec/converse.js | 16 +- spec/minchats.js | 3 - spec/otr.js | 2 - spec/roomslist.js | 2 - spec/roster.js | 6 - spec/spoilers.js | 2 - src/converse-chatboxes.js | 5 +- src/converse-chatview.js | 1 + src/converse-fullscreen.js | 12 - src/converse-muc-views.js | 5 +- src/converse-muc.js | 5 +- src/templates/chatroom_form.html | 2 +- src/templates/login_panel.html | 2 +- src/templates/registration_request.html | 2 +- src/templates/room_item.html | 1 + src/templates/room_panel.html | 4 +- src/templates/rooms_list_item.html | 4 +- src/templates/trimmed_chat.html | 2 +- src/utils.js | 1 - tests/index.html | 1 + tests/transpiled.html | 1 + tests/utils.js | 71 ++- 31 files changed, 435 insertions(+), 572 deletions(-) diff --git a/css/converse.css b/css/converse.css index 23c22aa37..233ea2315 100644 --- a/css/converse.css +++ b/css/converse.css @@ -4574,7 +4574,6 @@ body.reset { position: absolute; bottom: 1em; } #conversejs .badge { - padding: 0.4em; line-height: 1; font-weight: normal; font-size: 90%; } @@ -5442,13 +5441,7 @@ body.reset { #conversejs #controlbox form.search-xmpp-contact input { width: 8em; } #conversejs #controlbox .msgs-indicator { - border-radius: 3px; - background-color: #E77051; - color: white; - font-size: 12px; - font-weight: normal; - padding: 0 4px; - text-shadow: none; } + margin-right: 0.5em; } #conversejs #controlbox a.subscribe-to-user { padding-left: 2em; font-weight: bold; } diff --git a/css/inverse.css b/css/inverse.css index 9d4d6e6cb..1dff01b0d 100644 --- a/css/inverse.css +++ b/css/inverse.css @@ -4574,7 +4574,6 @@ body.reset { position: absolute; bottom: 1em; } #conversejs .badge { - padding: 0.4em; line-height: 1; font-weight: normal; font-size: 90%; } @@ -5512,13 +5511,7 @@ body { #conversejs #controlbox form.search-xmpp-contact input { width: 8em; } #conversejs #controlbox .msgs-indicator { - border-radius: 3px; - background-color: #E77051; - color: white; - font-size: 14px; - font-weight: normal; - padding: 0 4px; - text-shadow: none; } + margin-right: 0.5em; } #conversejs #controlbox a.subscribe-to-user { padding-left: 2em; font-weight: bold; } diff --git a/mockup/user-panel.html b/mockup/user-panel.html index 11607dfa9..db4f124fc 100644 --- a/mockup/user-panel.html +++ b/mockup/user-panel.html @@ -22,6 +22,7 @@
+ 1 public   diff --git a/sass/_controlbox.scss b/sass/_controlbox.scss index 9d6aa0162..a0c39f842 100644 --- a/sass/_controlbox.scss +++ b/sass/_controlbox.scss @@ -74,13 +74,7 @@ } .msgs-indicator { - border-radius: 3px; - background-color: $red; - color: white; - font-size: $font-size-small; - font-weight: normal; - padding: 0 4px; - text-shadow: none; + margin-right: 0.5em; } a.subscribe-to-user { diff --git a/sass/_core.scss b/sass/_core.scss index db629c427..cade337d5 100644 --- a/sass/_core.scss +++ b/sass/_core.scss @@ -209,7 +209,6 @@ body.reset { } } .badge { - padding: 0.4em; line-height: 1; font-weight: normal; font-size: 90%; diff --git a/spec/bookmarks.js b/spec/bookmarks.js index b36185aea..ecd245a2b 100644 --- a/spec/bookmarks.js +++ b/spec/bookmarks.js @@ -320,7 +320,6 @@ [{'category': 'pubsub', 'type': 'pep'}], ['http://jabber.org/protocol/pubsub#publish-options'] ).then(function () { - test_utils.openControlBox().openRoomsPanel(_converse); test_utils.waitUntil(function () { return _converse.bookmarks; }, 300).then(function () { @@ -465,7 +464,6 @@ ['http://jabber.org/protocol/pubsub#publish-options'] ).then(function () { - test_utils.openControlBox().openRoomsPanel(_converse); var IQ_id; expect(_.filter(_converse.connection.send.calls.all(), function (call) { var stanza = call.args[0]; @@ -575,7 +573,6 @@ 'name': 'The Play', 'nick': '' }); - test_utils.openControlBox().openRoomsPanel(_converse); test_utils.waitUntil(function () { return $('#chatrooms dl.bookmarks dd:visible').length; @@ -609,7 +606,6 @@ [{'category': 'pubsub', 'type': 'pep'}], ['http://jabber.org/protocol/pubsub#publish-options'] ).then(function () { - test_utils.openControlBox().openRoomsPanel(_converse); // XXX Create bookmarks view here, otherwise we need to mock stanza // traffic for it to get created. _converse.bookmarksview = new _converse.BookmarksView( diff --git a/spec/chatbox.js b/spec/chatbox.js index b41561220..a251a3be5 100644 --- a/spec/chatbox.js +++ b/spec/chatbox.js @@ -27,7 +27,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, contact_jid); @@ -65,7 +64,6 @@ }).then(function () { test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); expect(_converse.chatboxes.length).toEqual(1); var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; var message = '/me is tired'; @@ -97,7 +95,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var i, $el, jid, chatboxview; // openControlBox was called earlier, so the controlbox is @@ -134,7 +131,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var i, $el, jid, chatbox, chatboxview, trimmedview; // openControlBox was called earlier, so the controlbox is @@ -215,7 +211,6 @@ test_utils.createContacts(_converse, 'current'); _converse.rosterview.update(); // XXX: Hack to make sure $roster element is attaced. test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost'; var $el, jid, chatbox; @@ -243,7 +238,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); spyOn(_converse, 'emit'); spyOn(_converse.chatboxviews, 'trimChats'); @@ -279,7 +273,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300) @@ -317,7 +310,6 @@ var chatview; test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300) @@ -364,7 +356,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300) @@ -409,7 +400,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, contact_jid); @@ -430,7 +420,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, contact_jid); @@ -478,7 +467,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; @@ -507,7 +495,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var view; var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost'; @@ -540,7 +527,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var view, clearButton, $toolbar; var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost'; @@ -581,7 +567,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300) @@ -749,7 +734,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); // TODO: what could still be done for error // messages... if the element has type @@ -853,7 +837,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, sender_jid); @@ -918,7 +901,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; @@ -973,7 +955,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; @@ -1142,7 +1123,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); /* Ideally we wouldn't have to filter out headline * messages, but Prosody gives them the wrong 'type' :( @@ -1179,7 +1159,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); // Send a message from a different resource spyOn(_converse, 'log'); @@ -1236,7 +1215,6 @@ }).then(function () { test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); // Send a message from a different resource spyOn(_converse, 'log'); @@ -1285,7 +1263,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); /* * * @@ -1334,7 +1311,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300) @@ -1394,7 +1370,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300) @@ -1483,7 +1458,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); spyOn(_converse, 'emit'); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; @@ -1507,7 +1481,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, contact_jid); @@ -1529,7 +1502,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, contact_jid); @@ -1551,7 +1523,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var message, msg; var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; @@ -1680,7 +1651,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); spyOn(_converse, 'emit'); var sender_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost'; @@ -1705,7 +1675,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300).then(function () { @@ -1731,7 +1700,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.waitUntil(function () { @@ -1772,7 +1740,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300).then(function () { @@ -1812,7 +1779,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); // See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions spyOn(_converse, 'emit'); @@ -1896,7 +1862,6 @@ var view, contact_jid; test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group li').length; }, 700).then(function () { @@ -1958,7 +1923,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300) @@ -2043,7 +2007,6 @@ var view, contact_jid; test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 500).then(function () { @@ -2111,7 +2074,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, contact_jid); @@ -2133,7 +2095,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 300).then(function () { @@ -2162,7 +2123,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); // See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions spyOn(_converse, 'emit'); @@ -2194,7 +2154,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); spyOn(_converse, 'emit'); var sender_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost'; @@ -2225,7 +2184,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); spyOn(_converse, 'emit'); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; @@ -2266,7 +2224,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); spyOn(_converse, 'emit'); expect(_converse.msg_counter).toBe(0); @@ -2300,7 +2257,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); _converse.windowState = 'hidden'; spyOn(_converse, 'clearMsgCounter').and.callThrough(); _converse.saveWindowState(null, 'focus'); @@ -2316,7 +2272,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); expect(_converse.msg_counter).toBe(0); spyOn(_converse, 'incrementMsgCounter').and.callThrough(); @@ -2392,7 +2347,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost', msg = test_utils.createChatMessage(_converse, sender_jid, 'This message will be unread'); @@ -2412,7 +2366,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost', msg = test_utils.createChatMessage(_converse, sender_jid, 'This message will be read'); @@ -2528,7 +2481,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 500) @@ -2561,7 +2513,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 500) @@ -2595,7 +2546,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 500) @@ -2630,7 +2580,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 500) @@ -2663,7 +2612,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group').length; }, 500) @@ -2698,7 +2646,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, sender_jid); @@ -2729,7 +2676,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'current'); - test_utils.openContactsPanel(_converse); var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; test_utils.openChatBoxFor(_converse, sender_jid); diff --git a/spec/chatroom.js b/spec/chatroom.js index 35be45f44..0704f6efe 100644 --- a/spec/chatroom.js +++ b/spec/chatroom.js @@ -81,8 +81,10 @@ var jid = 'lounge@localhost'; var room = _converse.api.rooms.get(jid); expect(room instanceof Object).toBeTruthy(); - expect(room.is_chatroom).toBeTruthy(); + var chatroomview = _converse.chatboxviews.get(jid); + expect(chatroomview.is_chatroom).toBeTruthy(); + expect(u.isVisible(chatroomview.el)).toBeTruthy(); chatroomview.close(); @@ -140,15 +142,15 @@ var room = _converse.api.rooms.open(jid); // Test on chat room that's not yet open expect(room instanceof Object).toBeTruthy(); - expect(room.is_chatroom).toBeTruthy(); var chatroomview = _converse.chatboxviews.get(jid); + expect(chatroomview.is_chatroom).toBeTruthy(); expect(u.isVisible(chatroomview.el)).toBeTruthy(); // Test again, now that the room exists. room = _converse.api.rooms.open(jid); expect(room instanceof Object).toBeTruthy(); - expect(room.is_chatroom).toBeTruthy(); chatroomview = _converse.chatboxviews.get(jid); + expect(chatroomview.is_chatroom).toBeTruthy(); expect(u.isVisible(chatroomview.el)).toBeTruthy(); chatroomview.close(); @@ -358,7 +360,7 @@ .c('item-not-found', {'xmlns': "urn:ietf:params:xml:ns:xmpp-stanzas"}); _converse.connection._dataRecv(test_utils.createRequest(stanza)); - var input = view.el.querySelector('input.new-chatroom-nick'); + var input = view.el.querySelector('input[name="nick"]'); input.value = 'nicky'; view.el.querySelector('input[type=submit]').click(); expect(view.submitNickname).toHaveBeenCalled(); @@ -455,7 +457,7 @@ }).up() .c('status', {code: '110'}); _converse.connection._dataRecv(test_utils.createRequest(presence)); - expect($chat_content.find('div.chat-info:first').html()).toBe("some1 has entered the room."); + expect($chat_content.find('div.chat-info:first').html()).toBe("some1 has entered the room"); presence = $pres({ to: 'dummy@localhost/_converse.js-29092160', @@ -469,7 +471,7 @@ }); _converse.connection._dataRecv(test_utils.createRequest(presence)); expect($chat_content[0].querySelectorAll('div.chat-info').length).toBe(2); - expect($chat_content.find('div.chat-info:last').html()).toBe("newguy has entered the room."); + expect($chat_content.find('div.chat-info:last').html()).toBe("newguy has entered the room"); // Add another entrant, otherwise the above message will be // collapsed if "newguy" leaves immediately again @@ -485,7 +487,7 @@ }); _converse.connection._dataRecv(test_utils.createRequest(presence)); expect($chat_content[0].querySelectorAll('div.chat-info').length).toBe(3); - expect($chat_content.find('div.chat-info:last').html()).toBe("newgirl has entered the room."); + expect($chat_content.find('div.chat-info:last').html()).toBe("newgirl has entered the room"); // Don't show duplicate join messages presence = $pres({ @@ -544,7 +546,7 @@ _converse.connection._dataRecv(test_utils.createRequest(presence)); expect($chat_content.find('div.chat-info').length).toBe(4); var $msg_el = $chat_content.find('div.chat-info:last'); - expect($msg_el.html()).toBe("newguy has left and re-entered the room."); + expect($msg_el.html()).toBe("newguy has left and re-entered the room"); expect($msg_el.data('leavejoin')).toBe('"newguy"'); presence = $pres({ @@ -561,7 +563,7 @@ _converse.connection._dataRecv(test_utils.createRequest(presence)); expect($chat_content.find('div.chat-info').length).toBe(4); $msg_el = $chat_content.find('div.chat-info:last'); - expect($msg_el.html()).toBe('newguy has left the room.'); + expect($msg_el.html()).toBe('newguy has left the room'); expect($msg_el.data('leave')).toBe('"newguy"'); presence = $pres({ @@ -576,7 +578,7 @@ }); _converse.connection._dataRecv(test_utils.createRequest(presence)); expect($chat_content[0].querySelectorAll('div.chat-info').length).toBe(5); - expect($chat_content.find('div.chat-info:last').html()).toBe("nomorenicks has entered the room."); + expect($chat_content.find('div.chat-info:last').html()).toBe("nomorenicks has entered the room"); presence = $pres({ to: 'dummy@localhost/_converse.js-290918392', @@ -590,7 +592,7 @@ }); _converse.connection._dataRecv(test_utils.createRequest(presence)); expect($chat_content[0].querySelectorAll('div.chat-info').length).toBe(5); - expect($chat_content.find('div.chat-info:last').html()).toBe("nomorenicks has entered and left the room."); + expect($chat_content.find('div.chat-info:last').html()).toBe("nomorenicks has entered and left the room"); presence = $pres({ to: 'dummy@localhost/_converse.js-29092160', @@ -604,7 +606,7 @@ }); _converse.connection._dataRecv(test_utils.createRequest(presence)); expect($chat_content[0].querySelectorAll('div.chat-info').length).toBe(5); - expect($chat_content.find('div.chat-info:last').html()).toBe("nomorenicks has entered the room."); + expect($chat_content.find('div.chat-info:last').html()).toBe("nomorenicks has entered the room"); done(); })); @@ -639,10 +641,10 @@ var $time = $chat_content.find('time'); expect($time.length).toEqual(1); - expect($time.attr('class')).toEqual('message chat-info chat-date'); + expect($time.attr('class')).toEqual('message chat-info chat-date badge badge-info'); expect($time.data('isodate')).toEqual(moment().startOf('day').format()); expect($time.text()).toEqual(moment().startOf('day').format("dddd MMM Do YYYY")); - expect($chat_content.find('div.chat-info:first').html()).toBe("some1 has entered the room."); + expect($chat_content.find('div.chat-info:first').html()).toBe("some1 has entered the room"); // XXX: Hack. We clear the chat contents instead of mocking the date $chat_content.html(''); @@ -664,7 +666,7 @@ $time = $chat_content.find('time'); expect($time.length).toEqual(1); - expect($time.attr('class')).toEqual('message chat-info chat-date'); + expect($time.attr('class')).toEqual('message chat-info chat-date badge badge-info'); expect($time.data('isodate')).toEqual(moment().startOf('day').format()); expect($time.text()).toEqual(moment().startOf('day').format("dddd MMM Do YYYY")); expect($chat_content.find('div.chat-info').length).toBe(1); @@ -700,11 +702,11 @@ expect($time.length).toEqual(2); $time = $chat_content.find('time:eq(1)'); - expect($time.attr('class')).toEqual('message chat-info chat-date'); + expect($time.attr('class')).toEqual('message chat-info chat-date badge badge-info'); expect($time.data('isodate')).toEqual(moment().startOf('day').format()); expect($time.text()).toEqual(moment().startOf('day').format("dddd MMM Do YYYY")); expect($chat_content.find('div.chat-info').length).toBe(1); - expect($chat_content.find('div.chat-info:first').html()).toBe("newguy has entered the room."); + expect($chat_content.find('div.chat-info:first').html()).toBe("newguy has entered the room"); // XXX: Hack. We clear the chat contents instead of mocking the date $chat_content.html(''); @@ -738,7 +740,7 @@ expect($time.length).toEqual(2); $time = $chat_content.find('time:eq(1)'); - expect($time.attr('class')).toEqual('message chat-info chat-date'); + expect($time.attr('class')).toEqual('message chat-info chat-date badge badge-info'); expect($time.data('isodate')).toEqual(moment().startOf('day').format()); expect($time.text()).toEqual(moment().startOf('day').format("dddd MMM Do YYYY")); expect($chat_content.find('div.chat-info').length).toBe(1); @@ -760,7 +762,8 @@ sent_IQ = iq; IQ_id = sendIQ.bind(this)(iq, callback, errback); }); - var view = _converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'}); + _converse.api.rooms.open('coven@chat.shakespeare.lit', {'nick': 'some1'}); + var view = _converse.chatboxviews.get('coven@chat.shakespeare.lit'); var features_stanza = $iq({ from: 'coven@chat.shakespeare.lit', @@ -863,18 +866,6 @@ }); })); - it("can have spaces and special characters in its name", - mock.initConverseWithPromises( - null, ['rosterGroupsFetched'], {}, - function (done, _converse) { - - test_utils.openChatRoom(_converse, 'lounge & leisure', 'localhost', 'dummy'); - var view = _converse.chatboxviews.get( - Strophe.escapeNode('lounge & leisure')+'@localhost'); - expect(view instanceof _converse.ChatRoomView).toBe(true); - done(); - })); - it("can be configured if you're its owner", mock.initConverseWithPromises( null, ['rosterGroupsFetched'], {}, @@ -1563,8 +1554,9 @@ '').firstChild; _converse.connection._dataRecv(test_utils.createRequest(stanza)); var view = _converse.chatboxviews.get('jdev@conference.jabber.org'); - var $chat_content = $(view.el).find('.chat-content'); - expect($chat_content.find('.chat-info:last').text()).toBe('Topic set by ralphm to: '+text); + var chat_content = view.el.querySelector('.chat-content'); + expect($(chat_content).find('.chat-event:last').text()).toBe('Topic set by ralphm'); + expect($(chat_content).find('.chat-topic:last').text()).toBe(text); done(); }); })); @@ -1579,8 +1571,9 @@ var subject = ''; var view = _converse.chatboxviews.get('jdev@conference.jabber.org'); view.setChatRoomSubject('ralphm', subject); - var $chat_content = $(view.el).find('.chat-content'); - expect($chat_content.find('.chat-info:last').text()).toBe('Topic set by ralphm to: '+subject); + var chat_content = view.el.querySelector('.chat-content'); + expect($(chat_content).find('.chat-event:last').text()).toBe('Topic set by ralphm'); + expect($(chat_content).find('.chat-topic:last').text()).toBe(subject); done(); }); })); @@ -1653,7 +1646,7 @@ expect($occupants.children().first(0).text()).toBe("oldnick"); expect($chat_content.find('div.chat-info').length).toBe(2); - expect($chat_content.find('div.chat-info:first').html()).toBe("oldnick has entered the room."); + expect($chat_content.find('div.chat-info:first').html()).toBe("oldnick has entered the room"); expect($chat_content.find('div.chat-info:last').html()).toBe( __(_converse.muc.new_nickname_messages["210"], "oldnick") ); @@ -1702,7 +1695,7 @@ __(_converse.muc.new_nickname_messages["303"], "newnick") ); expect($chat_content.find('div.chat-info').last().html()).toBe( - "newnick has entered the room."); + "newnick has entered the room"); $occupants = $(view.el.querySelector('.occupant-list')); expect($occupants.children().length).toBe(1); expect($occupants.children().first(0).text()).toBe("newnick"); @@ -2366,7 +2359,7 @@ }); _converse.connection._dataRecv(test_utils.createRequest(presence)); var info_msgs = Array.prototype.slice.call(view.el.querySelectorAll('.chat-info'), 0); - expect(info_msgs.pop().textContent).toBe("trustworthyguy has entered the room."); + expect(info_msgs.pop().textContent).toBe("trustworthyguy has entered the room"); var textarea = view.el.querySelector('.chat-textarea') textarea.value = '/op'; @@ -2505,7 +2498,7 @@ }); _converse.connection._dataRecv(test_utils.createRequest(presence)); var info_msgs = Array.prototype.slice.call(view.el.querySelectorAll('.chat-info'), 0); - expect(info_msgs.pop().textContent).toBe("annoyingGuy has entered the room."); + expect(info_msgs.pop().textContent).toBe("annoyingGuy has entered the room"); var textarea = view.el.querySelector('.chat-textarea') textarea.value = '/mute'; @@ -2606,50 +2599,39 @@ describe("When attempting to enter a chatroom", function () { - var submitRoomForm = function (_converse) { - var roomspanel = _converse.chatboxviews.get('controlbox').roomspanel; - var input = roomspanel.el.querySelector('input.new-chatroom-name'); - var nick = roomspanel.el.querySelector('input.new-chatroom-nick'); - var server = roomspanel.el.querySelector('input.new-chatroom-server'); - input.value = 'problematic'; - if (nick) { - nick.value = 'dummy'; - } - server.value = 'muc.localhost'; - roomspanel.el.querySelector('form [type="submit"]').click(); - }; - it("will show an error message if the room requires a password", mock.initConverseWithPromises( - null, ['rosterGroupsFetched'], {}, + null, ['rosterGroupsFetched', 'chatBoxesFetched'], {}, function (done, _converse) { - submitRoomForm(_converse); - var presence = $pres().attrs({ - from:'lounge@localhost/thirdwitch', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error'}) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'auth'}) - .c('not-authorized').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + var presence = $pres().attrs({ + from:'lounge@localhost/thirdwitch', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error'}) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'auth'}) + .c('not-authorized').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'renderPasswordForm').and.callThrough(); - view.onChatRoomPresence(presence); + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'renderPasswordForm').and.callThrough(); + view.onChatRoomPresence(presence); - var $chat_body = $(view.el).find('.chatroom-body'); - expect(view.renderPasswordForm).toHaveBeenCalled(); - expect($chat_body.find('form.chatroom-form').length).toBe(1); - expect($chat_body.find('legend').text()).toBe('This chatroom requires a password'); + var $chat_body = $(view.el).find('.chatroom-body'); + expect(view.renderPasswordForm).toHaveBeenCalled(); + expect($chat_body.find('form.chatroom-form').length).toBe(1); + expect($chat_body.find('legend').text()).toBe('This chatroom requires a password'); - // Let's submit the form - spyOn(view, 'join'); - var input_el = view.el.querySelector('[name="password"]'); - input_el.value = 'secret'; - view.el.querySelector('input[type=submit]').click(); - expect(view.join).toHaveBeenCalledWith(undefined, "secret"); - done(); + // Let's submit the form + spyOn(view, 'join'); + var input_el = view.el.querySelector('[name="password"]'); + input_el.value = 'secret'; + view.el.querySelector('input[type=submit]').click(); + expect(view.join).toHaveBeenCalledWith('dummy', 'secret'); + done(); + }); })); it("will show an error message if the room is members-only and the user not included", @@ -2657,20 +2639,22 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - submitRoomForm(_converse); - var presence = $pres().attrs({ - from:'lounge@localhost/thirdwitch', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error'}) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'auth'}) - .c('registration-required').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'showErrorMessage').and.callThrough(); - view.onChatRoomPresence(presence); - expect($(view.el).find('.chatroom-body p:last').text()).toBe('You are not on the member list of this room.'); - done(); + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + var presence = $pres().attrs({ + from:'lounge@localhost/thirdwitch', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error'}) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'auth'}) + .c('registration-required').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'showErrorMessage').and.callThrough(); + view.onChatRoomPresence(presence); + expect($(view.el).find('.chatroom-body p:last').text()).toBe('You are not on the member list of this room.'); + done(); + }); })); it("will show an error message if the user has been banned", @@ -2678,20 +2662,22 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - submitRoomForm(_converse); - var presence = $pres().attrs({ - from:'lounge@localhost/thirdwitch', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error'}) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'auth'}) - .c('forbidden').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'showErrorMessage').and.callThrough(); - view.onChatRoomPresence(presence); - expect($(view.el).find('.chatroom-body p:last').text()).toBe('You have been banned from this room.'); - done(); + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + var presence = $pres().attrs({ + from:'lounge@localhost/thirdwitch', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error'}) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'auth'}) + .c('forbidden').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'showErrorMessage').and.callThrough(); + view.onChatRoomPresence(presence); + expect($(view.el).find('.chatroom-body p:last').text()).toBe('You have been banned from this room.'); + done(); + }); })); it("will render a nickname form if a nickname conflict happens and muc_nickname_from_jid=false", @@ -2699,24 +2685,26 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - submitRoomForm(_converse); - var presence = $pres().attrs({ - from:'lounge@localhost/thirdwitch', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error'}) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'cancel'}) - .c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'showErrorMessage').and.callThrough(); - view.onChatRoomPresence(presence); - expect($(view.el).find('.chatroom-body form.chatroom-form label:first').text()).toBe('Please choose your nickname'); + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + var presence = $pres().attrs({ + from:'lounge@localhost/thirdwitch', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error'}) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'cancel'}) + .c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'showErrorMessage').and.callThrough(); + view.onChatRoomPresence(presence); + expect($(view.el).find('.chatroom-body form.chatroom-form label:first').text()).toBe('Please choose your nickname'); - var $input = $(view.el).find('.chatroom-body form.chatroom-form input:first'); - $input.val('nicky'); - view.el.querySelector('input[type=submit]').click(); - done(); + var $input = $(view.el).find('.chatroom-body form.chatroom-form input:first'); + $input.val('nicky'); + view.el.querySelector('input[type=submit]').click(); + done(); + }); })); it("will automatically choose a new nickname if a nickname conflict happens and muc_nickname_from_jid=true", @@ -2724,57 +2712,59 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - /* - * - * - * - * - * - */ - submitRoomForm(_converse); - _converse.muc_nickname_from_jid = true; + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + /* + * + * + * + * + * + */ + _converse.muc_nickname_from_jid = true; - var attrs = { - from:'lounge@localhost/dummy', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error' - }; - var presence = $pres().attrs(attrs) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'cancel'}) - .c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + var attrs = { + from:'lounge@localhost/dummy', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error' + }; + var presence = $pres().attrs(attrs) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'cancel'}) + .c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'showErrorMessage').and.callThrough(); - spyOn(view, 'join').and.callThrough(); + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'showErrorMessage').and.callThrough(); + spyOn(view, 'join').and.callThrough(); - // Simulate repeatedly that there's already someone in the room - // with that nickname - view.onChatRoomPresence(presence); - expect(view.join).toHaveBeenCalledWith('dummy-2'); + // Simulate repeatedly that there's already someone in the room + // with that nickname + view.onChatRoomPresence(presence); + expect(view.join).toHaveBeenCalledWith('dummy-2'); - attrs.from = 'lounge@localhost/dummy-2'; - presence = $pres().attrs(attrs) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'cancel'}) - .c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - view.onChatRoomPresence(presence); + attrs.from = 'lounge@localhost/dummy-2'; + presence = $pres().attrs(attrs) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'cancel'}) + .c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + view.onChatRoomPresence(presence); - expect(view.join).toHaveBeenCalledWith('dummy-3'); + expect(view.join).toHaveBeenCalledWith('dummy-3'); - attrs.from = 'lounge@localhost/dummy-3'; - presence = $pres().attrs(attrs) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'cancel'}) - .c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - view.onChatRoomPresence(presence); - expect(view.join).toHaveBeenCalledWith('dummy-4'); - done(); + attrs.from = 'lounge@localhost/dummy-3'; + presence = $pres().attrs(attrs) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'cancel'}) + .c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + view.onChatRoomPresence(presence); + expect(view.join).toHaveBeenCalledWith('dummy-4'); + done(); + }); })); it("will show an error message if the user is not allowed to have created the room", @@ -2782,20 +2772,22 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - submitRoomForm(_converse); - var presence = $pres().attrs({ - from:'lounge@localhost/thirdwitch', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error'}) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'cancel'}) - .c('not-allowed').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'showErrorMessage').and.callThrough(); - view.onChatRoomPresence(presence); - expect($(view.el).find('.chatroom-body p:last').text()).toBe('You are not allowed to create new rooms.'); - done(); + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + var presence = $pres().attrs({ + from:'lounge@localhost/thirdwitch', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error'}) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'cancel'}) + .c('not-allowed').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'showErrorMessage').and.callThrough(); + view.onChatRoomPresence(presence); + expect($(view.el).find('.chatroom-body p:last').text()).toBe('You are not allowed to create new rooms.'); + done(); + }); })); it("will show an error message if the user's nickname doesn't conform to room policy", @@ -2803,20 +2795,22 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - submitRoomForm(_converse); - var presence = $pres().attrs({ - from:'lounge@localhost/thirdwitch', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error'}) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'cancel'}) - .c('not-acceptable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'showErrorMessage').and.callThrough(); - view.onChatRoomPresence(presence); - expect($(view.el).find('.chatroom-body p:last').text()).toBe("Your nickname doesn't conform to this room's policies."); - done(); + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + var presence = $pres().attrs({ + from:'lounge@localhost/thirdwitch', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error'}) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'cancel'}) + .c('not-acceptable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'showErrorMessage').and.callThrough(); + view.onChatRoomPresence(presence); + expect($(view.el).find('.chatroom-body p:last').text()).toBe("Your nickname doesn't conform to this room's policies."); + done(); + }); })); it("will show an error message if the room doesn't yet exist", @@ -2824,20 +2818,22 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - submitRoomForm(_converse); - var presence = $pres().attrs({ - from:'lounge@localhost/thirdwitch', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error'}) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'cancel'}) - .c('item-not-found').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'showErrorMessage').and.callThrough(); - view.onChatRoomPresence(presence); - expect($(view.el).find('.chatroom-body p:last').text()).toBe("This room does not (yet) exist."); - done(); + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + var presence = $pres().attrs({ + from:'lounge@localhost/thirdwitch', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error'}) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'cancel'}) + .c('item-not-found').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'showErrorMessage').and.callThrough(); + view.onChatRoomPresence(presence); + expect($(view.el).find('.chatroom-body p:last').text()).toBe("This room does not (yet) exist."); + done(); + }); })); it("will show an error message if the room has reached its maximum number of occupants", @@ -2845,20 +2841,22 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - submitRoomForm(_converse); - var presence = $pres().attrs({ - from:'lounge@localhost/thirdwitch', - id:'n13mt3l', - to:'dummy@localhost/pda', - type:'error'}) - .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() - .c('error').attrs({by:'lounge@localhost', type:'cancel'}) - .c('service-unavailable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; - var view = _converse.chatboxviews.get('problematic@muc.localhost'); - spyOn(view, 'showErrorMessage').and.callThrough(); - view.onChatRoomPresence(presence); - expect($(view.el).find('.chatroom-body p:last').text()).toBe("This room has reached its maximum number of occupants."); - done(); + test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost', 'dummy') + .then(function () { + var presence = $pres().attrs({ + from:'lounge@localhost/thirdwitch', + id:'n13mt3l', + to:'dummy@localhost/pda', + type:'error'}) + .c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up() + .c('error').attrs({by:'lounge@localhost', type:'cancel'}) + .c('service-unavailable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree; + var view = _converse.chatboxviews.get('problematic@muc.localhost'); + spyOn(view, 'showErrorMessage').and.callThrough(); + view.onChatRoomPresence(presence); + expect($(view.el).find('.chatroom-body p:last').text()).toBe("This room has reached its maximum number of occupants."); + done(); + }); })); }); @@ -3084,63 +3082,41 @@ })); }); - describe("The \"Rooms\" Panel", function () { + describe("The \"Chatrooms\" section", function () { - it("is opened by clicking the 'Chatrooms' tab", - mock.initConverseWithPromises( - null, ['rosterGroupsFetched'], {}, - function (done, _converse) { - - test_utils.openControlBox(); - var cbview = _converse.chatboxviews.get('controlbox'); - var $tabs = $(cbview.el).find('#controlbox-tabs'); - var $panels = $(cbview.el).find('.controlbox-panes'); - var $contacts = $panels.children().first(); - var $chatrooms = $panels.children().last(); - spyOn(cbview, 'switchTab').and.callThrough(); - cbview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called - $tabs.find('li').last().find('a')[0].click(); // Clicks the chatrooms tab - expect(u.isVisible($contacts[0])).toBe(false); - expect(u.isVisible($chatrooms[0])).toBe(true); - expect(cbview.switchTab).toHaveBeenCalled(); - done(); - })); - - it("contains a form through which a new chatroom can be created", + it("contains a link to a modal through which a new chatroom can be created", mock.initConverseWithPromises( null, ['rosterGroupsFetched'], {}, function (done, _converse) { test_utils.openControlBox(); var roomspanel = _converse.chatboxviews.get('controlbox').roomspanel; - var $input = $(roomspanel.el).find('input.new-chatroom-name'); - var $nick = $(roomspanel.el).find('input.new-chatroom-nick'); - var $server = $(roomspanel.el).find('input.new-chatroom-server'); - expect($input.length).toBe(1); - expect($server.length).toBe(1); - expect($('.chatroom:visible').length).toBe(0); // There shouldn't be any chatrooms open currently - spyOn(roomspanel, 'openChatRoom').and.callThrough(); - spyOn(_converse.ChatRoomView.prototype, 'getRoomFeatures').and.callFake(function () { - var deferred = new $.Deferred(); - deferred.resolve(); - return deferred.promise(); - }); + roomspanel.el.querySelector('.trigger-add-chatrooms-modal').click(); + test_utils.closeControlBox(_converse); + const modal = roomspanel.add_room_modal; + test_utils.waitUntil(function () { + return u.isVisible(modal.el); + }, 1000).then(function () { + spyOn(_converse.ChatRoomView.prototype, 'getRoomFeatures').and.callFake(function () { + var deferred = new $.Deferred(); + deferred.resolve(); + return deferred.promise(); + }); + roomspanel.delegateEvents(); // We need to rebind all events otherwise our spy won't be called - roomspanel.delegateEvents(); // We need to rebind all events otherwise our spy won't be called - $input.val('Lounge'); - $nick.val('dummy'); - $server.val('muc.localhost'); - roomspanel.el.querySelector('form [type="submit"]').click(); - expect(roomspanel.openChatRoom).toHaveBeenCalled(); - expect($('.chatroom:visible').length).toBe(1); // There should now be an open chatroom - done(); + modal.el.querySelector('input[name="chatroom"]').value = 'lounce@muc.localhost'; + modal.el.querySelector('form input[type="submit"]').click(); + expect($('.chatroom:visible').length).toBe(1); // There should now be an open chatroom + done(); + }).catch(_.partial(console.error, _)); })); - it("can list rooms publically available on the server", + it("contains a link to a modal which can list rooms publically available on the server", mock.initConverseWithPromises( null, ['rosterGroupsFetched'], {}, function (done, _converse) { + var sendIQ = _converse.connection.sendIQ; var sent_stanza, IQ_id; spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) { @@ -3149,53 +3125,79 @@ }); test_utils.openControlBox(); - var panel = _converse.chatboxviews.get('controlbox').roomspanel; - $(panel.tabs).find('li').last().find('a')[0].click(); // Click the chatrooms tab - panel.model.set({'muc_domain': 'muc.localhost'}); // Make sure the domain is set - // See: http://xmpp.org/extensions/xep-0045.html#disco-rooms - expect(document.querySelectorAll('#available-chatrooms dt').length).toBe(0); - expect(document.querySelectorAll('#available-chatrooms dd').length).toBe(0); - document.querySelector('input#show-rooms').click(); + var roomspanel = _converse.chatboxviews.get('controlbox').roomspanel; + roomspanel.el.querySelector('.trigger-list-chatrooms-modal').click(); + test_utils.closeControlBox(_converse); + const modal = roomspanel.list_rooms_modal; + test_utils.waitUntil(function () { + return u.isVisible(modal.el); + }, 1000).then(function () { + spyOn(_converse.ChatRoomView.prototype, 'getRoomFeatures').and.callFake(function () { + var deferred = new $.Deferred(); + deferred.resolve(); + return deferred.promise(); + }); + roomspanel.delegateEvents(); // We need to rebind all events otherwise our spy won't be called - expect(sent_stanza.toLocaleString()).toBe( - ""+ - ""+ - "" - ); + // See: http://xmpp.org/extensions/xep-0045.html#disco-rooms + expect(modal.el.querySelectorAll('.available-chatrooms li').length).toBe(0); - var iq = $iq({ - from:'muc.localhost', - to:'dummy@localhost/pda', - id: IQ_id, - type:'result' - }).c('query') - .c('item', { jid:'heath@chat.shakespeare.lit', name:'A Lonely Heath'}).up() - .c('item', { jid:'coven@chat.shakespeare.lit', name:'A Dark Cave'}).up() - .c('item', { jid:'forres@chat.shakespeare.lit', name:'The Palace'}).up() - .c('item', { jid:'inverness@chat.shakespeare.lit', name:'Macbeth's Castle'}).nodeTree; - _converse.connection._dataRecv(test_utils.createRequest(iq)); + const input = modal.el.querySelector('input[name="server"]').value = 'chat.shakespear.lit'; + modal.el.querySelector('input[type="submit"]').click(); - expect(document.querySelectorAll('#available-chatrooms dt').length).toBe(1); - expect($(panel.el.querySelector('#available-chatrooms')).children('dt').first().text()).toBe("Rooms found"); - expect($(panel.el.querySelector('#available-chatrooms')).children('dd').length).toBe(4); - done(); + expect(sent_stanza.toLocaleString()).toBe( + ""+ + ""+ + "" + ); + + var iq = $iq({ + from:'muc.localhost', + to:'dummy@localhost/pda', + id: IQ_id, + type:'result' + }).c('query') + .c('item', { jid:'heath@chat.shakespeare.lit', name:'A Lonely Heath'}).up() + .c('item', { jid:'coven@chat.shakespeare.lit', name:'A Dark Cave'}).up() + .c('item', { jid:'forres@chat.shakespeare.lit', name:'The Palace'}).up() + .c('item', { jid:'inverness@chat.shakespeare.lit', name:'Macbeth's Castle'}).nodeTree; + _converse.connection._dataRecv(test_utils.createRequest(iq)); + + expect(modal.el.querySelectorAll('.available-chatrooms li').length).toBe(5); + + const rooms = modal.el.querySelectorAll('.available-chatrooms li'); + expect(rooms[0].textContent.trim()).toBe("Rooms found:"); + expect(rooms[1].textContent.trim()).toBe("A Lonely Heath"); + expect(rooms[2].textContent.trim()).toBe("A Dark Cave"); + expect(rooms[3].textContent.trim()).toBe("The Palace"); + expect(rooms[4].textContent.trim()).toBe("Macbeth's Castle"); + + rooms[4].querySelector('.open-room').click(); + expect($('.chatroom:visible').length).toBe(1); // There should now be an open chatroom + var view = _converse.chatboxviews.get('inverness@chat.shakespeare.lit'); + expect(view.el.querySelector('.chat-head-chatroom').textContent.trim()).toBe("Macbeth's Castle"); + done(); + }).catch(_.partial(console.error, _)); })); - }); - - describe("The \"Rooms\" Panel", function () { it("shows the number of unread mentions received", mock.initConverseWithPromises( - null, ['rosterGroupsFetched'], {}, + null, ['rosterGroupsFetched'], {'allow_bookmarks': false}, function (done, _converse) { + // XXX: we set `allow_bookmarks` to false, so that the rooms + // list gets rendered. Otherwise we would have to mock + // the bookmark stanza exchange. + + test_utils.openControlBox(); + var roomspanel = _converse.chatboxviews.get('controlbox').roomspanel; + expect(roomspanel.el.querySelectorAll('.available-room').length).toBe(0); var room_jid = 'kitchen@conference.shakespeare.lit'; test_utils.openAndEnterChatRoom( _converse, 'kitchen', 'conference.shakespeare.lit', 'fires').then(function () { - test_utils.openContactsPanel(_converse); - var roomspanel = _converse.chatboxviews.get('controlbox').roomspanel; - expect(_.isNull(roomspanel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); + expect(roomspanel.el.querySelectorAll('.available-room').length).toBe(1); + expect(roomspanel.el.querySelectorAll('.msgs-indicator').length).toBe(0); var view = _converse.chatboxviews.get(room_jid); view.model.set({'minimized': true}); @@ -3209,32 +3211,29 @@ to: 'dummy@localhost', type: 'groupchat' }).c('body').t(message).tree(); - view.handleMUCMessage(msg); - test_utils.waitUntil(function () { - return _.includes(roomspanel.tab_el.firstChild.classList, 'unread-msgs'); - }, 300).then(function () { - expect(_.includes(roomspanel.tab_el.firstChild.classList, 'unread-msgs')).toBeTruthy(); - expect(roomspanel.tab_el.querySelector('.msgs-indicator').textContent).toBe('1'); + expect(roomspanel.el.querySelectorAll('.available-room').length).toBe(1); + expect(roomspanel.el.querySelectorAll('.msgs-indicator').length).toBe(1); + expect(roomspanel.el.querySelector('.msgs-indicator').textContent).toBe('1'); - msg = $msg({ - from: room_jid+'/'+nick, - id: (new Date()).getTime(), - to: 'dummy@localhost', - type: 'groupchat' - }).c('body').t(message).tree(); - view.handleMUCMessage(msg); - expect(roomspanel.tab_el.querySelector('.msgs-indicator').textContent).toBe('2'); + msg = $msg({ + from: room_jid+'/'+nick, + id: (new Date()).getTime(), + to: 'dummy@localhost', + type: 'groupchat' + }).c('body').t(message).tree(); + view.handleMUCMessage(msg); - var contacts_panel = _converse.chatboxviews.get('controlbox').contactspanel; - expect(_.isNull(contacts_panel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); + expect(roomspanel.el.querySelectorAll('.available-room').length).toBe(1); + expect(roomspanel.el.querySelectorAll('.msgs-indicator').length).toBe(1); + expect(roomspanel.el.querySelector('.msgs-indicator').textContent).toBe('2'); - view.model.set({'minimized': false}); - expect(_.includes(roomspanel.tab_el.firstChild.classList, 'unread-msgs')).toBeFalsy(); - expect(_.isNull(roomspanel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); - done(); - }); + view.model.set({'minimized': false}); + + expect(roomspanel.el.querySelectorAll('.available-room').length).toBe(1); + expect(roomspanel.el.querySelectorAll('.msgs-indicator').length).toBe(0); + done(); }); })); }); diff --git a/spec/controlbox.js b/spec/controlbox.js index c8b654666..a59e090df 100644 --- a/spec/controlbox.js +++ b/spec/controlbox.js @@ -8,7 +8,7 @@ var u = converse.env.utils; - describe("The Control Box", function () { + describe("The Controlbox", function () { it("can be opened by clicking a DOM element with class 'toggle-controlbox'", mock.initConverseWithPromises( @@ -31,6 +31,53 @@ done(); })); + describe("The \"Contacts\" section", function () { + + it("shows the number of unread mentions received", + mock.initConverseWithPromises( + null, ['rosterGroupsFetched'], {}, + function (done, _converse) { + + test_utils.createContacts(_converse, 'all').openControlBox(); + + var contacts_panel = _converse.chatboxviews.get('controlbox').contactspanel; + expect(_.isNull(contacts_panel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); + + var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; + test_utils.openChatBoxFor(_converse, sender_jid); + var chatview = _converse.chatboxviews.get(sender_jid); + chatview.model.set({'minimized': true}); + + var msg = $msg({ + from: sender_jid, + to: _converse.connection.jid, + type: 'chat', + id: (new Date()).getTime() + }).c('body').t('hello').up() + .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); + _converse.chatboxes.onMessage(msg); + expect(contacts_panel.tab_el.querySelector('.msgs-indicator').textContent).toBe('1'); + + msg = $msg({ + from: sender_jid, + to: _converse.connection.jid, + type: 'chat', + id: (new Date()).getTime() + }).c('body').t('hello again').up() + .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); + _converse.chatboxes.onMessage(msg); + expect(contacts_panel.tab_el.querySelector('.msgs-indicator').textContent).toBe('2'); + + var roomspanel = _converse.chatboxviews.get('controlbox').roomspanel; + expect(_.isNull(roomspanel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); + + chatview.model.set({'minimized': false}); + expect(_.includes(contacts_panel.tab_el.firstChild.classList, 'unread-msgs')).toBeFalsy(); + expect(_.isNull(contacts_panel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); + done(); + })); + }); + describe("The Status Widget", function () { it("shows the user's chat status, which is online by default", @@ -144,87 +191,4 @@ }); })); }); - - describe("The Controlbox Tabs", function () { - - it("contains two tabs, 'Contacts' and 'ChatRooms'", - mock.initConverseWithPromises( - null, ['rosterGroupsFetched'], {}, - function (done, _converse) { - - test_utils.openControlBox(); - var cbview = _converse.chatboxviews.get('controlbox'); - var $panels = $(cbview.el).find('.controlbox-panes'); - expect($panels.children().length).toBe(2); - expect($panels.children().first().attr('id')).toBe('users'); - expect($panels.children().first().is(':visible')).toBe(true); - expect($panels.children().last().attr('id')).toBe('chatrooms'); - expect($panels.children().last().is(':visible')).toBe(false); - done(); - })); - - it("remembers which tab was open last", - mock.initConverseWithPromises( - null, ['rosterGroupsFetched'], {}, - function (done, _converse) { - - test_utils.openControlBox(); - var cbview = _converse.chatboxviews.get('controlbox'); - var $tabs = $(cbview.el).find('#controlbox-tabs'); - expect(cbview.model.get('active-panel')).toBe('users'); - $tabs.find('li').last().find('a')[0].click(); - expect(cbview.model.get('active-panel')).toBe('chatrooms'); - $tabs.find('li').first().find('a')[0].click(); - expect(cbview.model.get('active-panel')).toBe('users'); - done(); - })); - - describe("The \"Contacts\" Panel", function () { - - it("shows the number of unread mentions received", - mock.initConverseWithPromises( - null, ['rosterGroupsFetched'], {}, - function (done, _converse) { - - test_utils.createContacts(_converse, 'all').openControlBox(); - test_utils.openContactsPanel(_converse); - - var contacts_panel = _converse.chatboxviews.get('controlbox').contactspanel; - expect(_.isNull(contacts_panel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); - - var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; - test_utils.openChatBoxFor(_converse, sender_jid); - var chatview = _converse.chatboxviews.get(sender_jid); - chatview.model.set({'minimized': true}); - - var msg = $msg({ - from: sender_jid, - to: _converse.connection.jid, - type: 'chat', - id: (new Date()).getTime() - }).c('body').t('hello').up() - .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); - _converse.chatboxes.onMessage(msg); - expect(contacts_panel.tab_el.querySelector('.msgs-indicator').textContent).toBe('1'); - - msg = $msg({ - from: sender_jid, - to: _converse.connection.jid, - type: 'chat', - id: (new Date()).getTime() - }).c('body').t('hello again').up() - .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); - _converse.chatboxes.onMessage(msg); - expect(contacts_panel.tab_el.querySelector('.msgs-indicator').textContent).toBe('2'); - - var roomspanel = _converse.chatboxviews.get('controlbox').roomspanel; - expect(_.isNull(roomspanel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); - - chatview.model.set({'minimized': false}); - expect(_.includes(contacts_panel.tab_el.firstChild.classList, 'unread-msgs')).toBeFalsy(); - expect(_.isNull(contacts_panel.tab_el.querySelector('.msgs-indicator'))).toBeTruthy(); - done(); - })); - }); - }); })); diff --git a/spec/converse.js b/spec/converse.js index 757fb2007..e1342a696 100644 --- a/spec/converse.js +++ b/spec/converse.js @@ -276,7 +276,7 @@ describe("The \"chats\" API", function() { - it("has a method 'get' which returns a wrapped chat box", mock.initConverseWithPromises( + it("has a method 'get' which returns the chatbox model", mock.initConverseWithPromises( null, ['rosterInitialized'], {}, function (done, _converse) { test_utils.openControlBox(); test_utils.createContacts(_converse, 'current'); @@ -291,7 +291,7 @@ test_utils.openChatBoxFor(_converse, jid); box = _converse.api.chats.get(jid); expect(box instanceof Object).toBeTruthy(); - expect(box.model.get('box_id')).toBe(b64_sha1(jid)); + expect(box.get('box_id')).toBe(b64_sha1(jid)); chatboxview = _converse.chatboxviews.get(jid); expect($(chatboxview.el).is(':visible')).toBeTruthy(); // Test for multiple JIDs @@ -299,12 +299,12 @@ test_utils.openChatBoxFor(_converse, jid2); var list = _converse.api.chats.get([jid, jid2]); expect(_.isArray(list)).toBeTruthy(); - expect(list[0].model.get('box_id')).toBe(b64_sha1(jid)); - expect(list[1].model.get('box_id')).toBe(b64_sha1(jid2)); + expect(list[0].get('box_id')).toBe(b64_sha1(jid)); + expect(list[1].get('box_id')).toBe(b64_sha1(jid2)); done(); })); - it("has a method 'open' which opens and returns a wrapped chat box", mock.initConverseWithPromises( + it("has a method 'open' which opens and returns the chatbox model", mock.initConverseWithPromises( null, ['rosterGroupsFetched'], {}, function (done, _converse) { test_utils.openControlBox(); @@ -315,7 +315,7 @@ expect(_converse.api.chats.get('non-existing@jabber.org')).toBeFalsy(); var box = _converse.api.chats.open(jid); expect(box instanceof Object).toBeTruthy(); - expect(box.model.get('box_id')).toBe(b64_sha1(jid)); + expect(box.get('box_id')).toBe(b64_sha1(jid)); expect( _.keys(box), ['close', 'endOTR', 'focus', 'get', 'initiateOTR', 'is_chatroom', 'maximize', 'minimize', 'open', 'set'] @@ -326,8 +326,8 @@ var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost'; var list = _converse.api.chats.open([jid, jid2]); expect(_.isArray(list)).toBeTruthy(); - expect(list[0].model.get('box_id')).toBe(b64_sha1(jid)); - expect(list[1].model.get('box_id')).toBe(b64_sha1(jid2)); + expect(list[0].get('box_id')).toBe(b64_sha1(jid)); + expect(list[1].get('box_id')).toBe(b64_sha1(jid2)); done(); })); }); diff --git a/spec/minchats.js b/spec/minchats.js index e698b24fc..ce220d90d 100644 --- a/spec/minchats.js +++ b/spec/minchats.js @@ -13,7 +13,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); _converse.minimized_chats.toggleview.model.browserStorage._clear(); _converse.minimized_chats.initToggle(); @@ -48,7 +47,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); _converse.minimized_chats.toggleview.model.browserStorage._clear(); _converse.minimized_chats.initToggle(); @@ -79,7 +77,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); _converse.minimized_chats.toggleview.model.browserStorage._clear(); _converse.minimized_chats.initToggle(); diff --git a/spec/otr.js b/spec/otr.js index f868319d0..13b6a731f 100644 --- a/spec/otr.js +++ b/spec/otr.js @@ -77,7 +77,6 @@ function (done, _converse) { test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.createContacts(_converse, 'current'); var UNVERIFIED = 1, UNENCRYPTED = 0; @@ -104,7 +103,6 @@ function (done, _converse) { test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.createContacts(_converse, 'current'); var msgtext = "?OTR,1,3,?OTR:AAIDAAAAAAEAAAABAAAAwCQ8HKsag0y0DGKsneo0kzKu1ua5L93M4UKTkCf1I2kbm2RgS5kIxDTxrTj3wVRB+H5Si86E1fKtuBgsDf/bKkGTM0h/49vh5lOD9HkE8cnSrFEn5GN,"; diff --git a/spec/roomslist.js b/spec/roomslist.js index 4880e29e7..ee717350c 100644 --- a/spec/roomslist.js +++ b/spec/roomslist.js @@ -14,7 +14,6 @@ // have to mock stanza traffic. }, function (done, _converse) { - test_utils.openControlBox().openRoomsPanel(_converse); var controlbox = _converse.chatboxviews.get('controlbox'); var list = controlbox.el.querySelector('div.rooms-list-container'); @@ -69,7 +68,6 @@ test_utils.openChatRoom( _converse, 'lounge', 'conference.shakespeare.lit', 'JC'); expect(_converse.chatboxes.length).toBe(2); - test_utils.openControlBox().openRoomsPanel(_converse); var room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room"); expect(room_els.length).toBe(1); var close_el = _converse.rooms_list_view.el.querySelector(".close-room"); diff --git a/spec/roster.js b/spec/roster.js index ebd811896..20b1fd7ac 100644 --- a/spec/roster.js +++ b/spec/roster.js @@ -497,7 +497,6 @@ // Must be initialized, so that render is called and documentFragment set up. test_utils.createContacts(_converse, 'pending'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); } it("can be collapsed under their own header", @@ -690,7 +689,6 @@ var _addContacts = function (_converse) { test_utils.createContacts(_converse, 'current') .openControlBox() - .openContactsPanel(_converse); }; it("can be collapsed under their own header", @@ -1081,7 +1079,6 @@ names.push($(item).text().replace(/^\s+|\s+$/g, '')); } }; - test_utils.openContactsPanel(_converse); spyOn(_converse, 'emit'); spyOn(_converse.rosterview, 'update').and.callThrough(); spyOn(_converse.controlboxtoggle, 'showControlBox').and.callThrough(); @@ -1112,7 +1109,6 @@ null, ['rosterGroupsFetched'], {}, function (done, _converse) { - test_utils.openContactsPanel(_converse); var name = mock.req_names[0]; spyOn(window, 'confirm').and.returnValue(true); _converse.roster.create({ @@ -1258,7 +1254,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'all').openControlBox(); - test_utils.openContactsPanel(_converse); var new_attrs, old_attrs, attrs; var num_contacts = _converse.roster.length; var new_roster = new _converse.RosterContacts(); @@ -1287,7 +1282,6 @@ function (done, _converse) { test_utils.createContacts(_converse, 'all').openControlBox(); - test_utils.openContactsPanel(_converse); test_utils.waitUntil(function () { return $(_converse.rosterview.el).find('.roster-group li').length; }, 700).then(function () { diff --git a/spec/spoilers.js b/spec/spoilers.js index 6a8992cd7..d0d6b52f5 100644 --- a/spec/spoilers.js +++ b/spec/spoilers.js @@ -93,7 +93,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; // XXX: We need to send a presence from the contact, so that we @@ -167,7 +166,6 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); - test_utils.openContactsPanel(_converse); var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; // XXX: We need to send a presence from the contact, so that we diff --git a/src/converse-chatboxes.js b/src/converse-chatboxes.js index a7957132c..6d57427b9 100644 --- a/src/converse-chatboxes.js +++ b/src/converse-chatboxes.js @@ -366,10 +366,11 @@ create = attrs; attrs = jid; jid = attrs.jid; - } else { - attrs.jid = jid; } jid = jid.toLowerCase(); + attrs.jid = jid; + attrs.id = jid; + let chatbox = this.get(Strophe.getBareJidFromJid(jid)); if (!chatbox && create) { chatbox = this.create(attrs, { diff --git a/src/converse-chatview.js b/src/converse-chatview.js index db11257d0..ae96e0d25 100644 --- a/src/converse-chatview.js +++ b/src/converse-chatview.js @@ -269,6 +269,7 @@ }, render () { + // XXX: Is this still needed? this.el.setAttribute('id', this.model.get('box_id')); this.el.innerHTML = tpl_chatbox( _.extend(this.model.toJSON(), { diff --git a/src/converse-fullscreen.js b/src/converse-fullscreen.js index 55b10fc90..fe17210f6 100644 --- a/src/converse-fullscreen.js +++ b/src/converse-fullscreen.js @@ -44,18 +44,6 @@ this.createBrandHeadingHTML() ); } - }, - - ChatRoomView: { - afterShown (focus) { - /* Make sure chat rooms are scrolled down when opened - */ - this.scrollDown(); - if (focus) { - this.focus(); - } - return this.__super__.afterShown.apply(this, arguments); - } } }, diff --git a/src/converse-muc-views.js b/src/converse-muc-views.js index 7e66e9b04..5950ede6a 100644 --- a/src/converse-muc-views.js +++ b/src/converse-muc-views.js @@ -242,8 +242,9 @@ openRoom (ev) { ev.preventDefault(); const jid = ev.target.getAttribute('data-room-jid'); + const name = ev.target.getAttribute('data-room-name'); this.modal.hide(); - _converse.api.rooms.open(jid); + _converse.api.rooms.open(jid, {'name': name}); }, toggleRoomInfo (ev) { @@ -264,7 +265,7 @@ ); const div = document.createElement('div'); div.innerHTML = tpl_room_item({ - 'name': name, + 'name': Strophe.xmlunescape(name), 'jid': room.getAttribute('jid'), 'open_title': __('Click to open this room'), 'info_title': __('Show more information on this room') diff --git a/src/converse-muc.js b/src/converse-muc.js index 9aa425db2..651cd3314 100644 --- a/src/converse-muc.js +++ b/src/converse-muc.js @@ -482,6 +482,7 @@ 'rooms': { 'close' (jids) { if (_.isUndefined(jids)) { + // FIXME: can't access views here _converse.chatboxviews.each(function (view) { if (view.is_chatroom && view.model) { view.close(); @@ -543,9 +544,9 @@ attrs.nick = Strophe.getNodeFromJid(_converse.bare_jid); } if (_.isString(jids)) { - return _converse.getChatRoom(jids, attrs); + return getChatRoom(jids, attrs); } - return _.map(jids, _.partial(_converse.getChatRoom, _, attrs)); + return _.map(jids, _.partial(getChatRoom, _, attrs)); } } }); diff --git a/src/templates/chatroom_form.html b/src/templates/chatroom_form.html index 16a0830d1..99fc323e3 100644 --- a/src/templates/chatroom_form.html +++ b/src/templates/chatroom_form.html @@ -1,7 +1,7 @@
- +
diff --git a/src/templates/login_panel.html b/src/templates/login_panel.html index 696b1ebf3..958c921df 100644 --- a/src/templates/login_panel.html +++ b/src/templates/login_panel.html @@ -5,7 +5,7 @@
{[ if (o.auto_login || o._converse.CONNECTION_STATUS[o.connection_status] === 'CONNECTING') { ]} - + {[ } else { ]} {[ if (o.authentication == o.LOGIN || o.authentication == o.EXTERNAL) { ]}
diff --git a/src/templates/registration_request.html b/src/templates/registration_request.html index f7cf4f679..c5675fdd6 100644 --- a/src/templates/registration_request.html +++ b/src/templates/registration_request.html @@ -1,4 +1,4 @@ - +

{{{o.__("Hold tight, we're fetching the registration form…")}}}

{[ if (o.cancel) { ]} diff --git a/src/templates/room_item.html b/src/templates/room_item.html index 66341f548..d798bbef4 100644 --- a/src/templates/room_item.html +++ b/src/templates/room_item.html @@ -2,6 +2,7 @@
{{{o.name}}} -->
diff --git a/src/templates/rooms_list_item.html b/src/templates/rooms_list_item.html index 29fd46918..927033c6c 100644 --- a/src/templates/rooms_list_item.html +++ b/src/templates/rooms_list_item.html @@ -1,11 +1,11 @@
{[ if (o.num_unread) { ]} - {{{ o.num_unread }}} + {{{ o.num_unread }}} {[ } ]} {{{o.name}}} + title="{{{o.open_title}}}" href="#">{{{o.name || o.jid}}} {{{o.num_unread}}} {[ } ]} - {{{o. title }}} + {{{o.title || o.jid }}} diff --git a/src/utils.js b/src/utils.js index 19b39171f..f8551442b 100644 --- a/src/utils.js +++ b/src/utils.js @@ -705,6 +705,5 @@ evt.initEvent(name, bubbles, cancelable); el.dispatchEvent(evt); }; - return u; })); diff --git a/tests/index.html b/tests/index.html index 174462014..d3260eb07 100644 --- a/tests/index.html +++ b/tests/index.html @@ -7,6 +7,7 @@ + diff --git a/tests/transpiled.html b/tests/transpiled.html index c6de8e291..117cb58dd 100644 --- a/tests/transpiled.html +++ b/tests/transpiled.html @@ -7,6 +7,7 @@ + diff --git a/tests/utils.js b/tests/utils.js index c5e300fe0..87cb3a5f5 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -83,18 +83,6 @@ return this; }; - utils.openContactsPanel = function (converse) { - this.openControlBox(converse); - var cbview = converse.chatboxviews.get('controlbox'); - cbview.el.querySelector('#controlbox-tabs li:first-child a').click(); - }; - - utils.openRoomsPanel = function (converse) { - utils.openControlBox(); - var cbview = converse.chatboxviews.get('controlbox'); - cbview.el.querySelector('#controlbox-tabs li:last-child a').click(); - }; - utils.openChatBoxes = function (converse, amount) { var i = 0, jid, views = []; for (i; i