2015-10-25 18:49:35 +01:00
|
|
|
/*global converse */
|
2013-05-11 14:20:07 +02:00
|
|
|
(function (root, factory) {
|
|
|
|
define([
|
2014-10-15 19:16:02 +02:00
|
|
|
"jquery",
|
2015-10-25 18:49:35 +01:00
|
|
|
"underscore",
|
2013-11-02 09:56:20 +01:00
|
|
|
"mock",
|
2015-03-01 11:22:37 +01:00
|
|
|
"test_utils",
|
|
|
|
"utils"
|
2015-10-25 18:49:35 +01:00
|
|
|
], function ($, _, mock, test_utils, utils) {
|
|
|
|
return factory($, _, mock, test_utils, utils);
|
2013-05-11 14:20:07 +02:00
|
|
|
}
|
|
|
|
);
|
2015-10-25 18:49:35 +01:00
|
|
|
} (this, function ($, _, mock, test_utils, utils) {
|
2015-02-01 16:15:34 +01:00
|
|
|
var $pres = converse_api.env.$pres;
|
|
|
|
var $msg = converse_api.env.$msg;
|
2015-09-09 10:17:46 +02:00
|
|
|
var Strophe = converse_api.env.Strophe;
|
2015-02-01 16:15:34 +01:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
return describe("ChatRooms", function (mock, test_utils) {
|
2015-10-12 16:23:05 +02:00
|
|
|
beforeEach(function () {
|
|
|
|
runs(function () {
|
|
|
|
test_utils.closeAllChatBoxes();
|
|
|
|
test_utils.clearBrowserStorage();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
describe("A Chat Room", function () {
|
2013-11-03 11:02:25 +01:00
|
|
|
beforeEach(function () {
|
2014-02-28 03:04:52 +01:00
|
|
|
runs(function () {
|
2014-08-08 22:06:01 +02:00
|
|
|
test_utils.closeAllChatBoxes();
|
2014-09-16 10:26:24 +02:00
|
|
|
test_utils.clearBrowserStorage();
|
2014-02-28 03:04:52 +01:00
|
|
|
});
|
2014-01-19 06:02:18 +01:00
|
|
|
});
|
|
|
|
|
2015-09-09 10:17:46 +02:00
|
|
|
it("can have spaces and special characters in its name", function () {
|
|
|
|
test_utils.openChatRoom('lounge & leisure', 'localhost', 'dummy');
|
|
|
|
var view = converse.chatboxviews.get(
|
|
|
|
Strophe.escapeNode('lounge & leisure')+'@localhost');
|
|
|
|
expect(view instanceof converse.ChatRoomView).toBe(true);
|
|
|
|
});
|
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("shows users currently present in the room", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2015-03-01 11:58:07 +01:00
|
|
|
var name;
|
|
|
|
var view = this.chatboxviews.get('lounge@localhost'),
|
2015-10-31 17:30:06 +01:00
|
|
|
$occupants = view.$('.occupant-list');
|
2015-03-01 11:58:07 +01:00
|
|
|
spyOn(view, 'onChatRoomPresence').andCallThrough();
|
2015-10-25 18:49:35 +01:00
|
|
|
var presence, role;
|
|
|
|
for (var i=0; i<mock.chatroom_names.length; i++) {
|
2015-03-01 11:58:07 +01:00
|
|
|
name = mock.chatroom_names[i];
|
|
|
|
role = mock.chatroom_roles[name].role;
|
|
|
|
// See example 21 http://xmpp.org/extensions/xep-0045.html#enter-pres
|
2015-03-01 13:28:24 +01:00
|
|
|
presence = $pres({
|
2015-03-01 11:58:07 +01:00
|
|
|
to:'dummy@localhost/pda',
|
|
|
|
from:'lounge@localhost/'+name
|
|
|
|
}).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
|
|
.c('item').attrs({
|
|
|
|
affiliation: mock.chatroom_roles[name].affiliation,
|
2015-03-01 13:28:24 +01:00
|
|
|
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
|
2015-03-01 11:58:07 +01:00
|
|
|
role: role
|
|
|
|
}).up()
|
|
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
|
|
|
|
|
|
this.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
|
expect(view.onChatRoomPresence).toHaveBeenCalled();
|
2015-10-31 17:30:06 +01:00
|
|
|
expect($occupants.find('li').length).toBe(1+i);
|
|
|
|
expect($($occupants.find('li')[i]).text()).toBe(mock.chatroom_names[i]);
|
|
|
|
expect($($occupants.find('li')[i]).hasClass('moderator')).toBe(role === "moderator");
|
2013-05-11 14:20:07 +02:00
|
|
|
}
|
2015-03-01 13:28:24 +01:00
|
|
|
|
|
|
|
// Test users leaving the room
|
|
|
|
// http://xmpp.org/extensions/xep-0045.html#exit
|
|
|
|
for (i=mock.chatroom_names.length-1; i>-1; i--) {
|
|
|
|
name = mock.chatroom_names[i];
|
|
|
|
role = mock.chatroom_roles[name].role;
|
|
|
|
// See example 21 http://xmpp.org/extensions/xep-0045.html#enter-pres
|
|
|
|
presence = $pres({
|
|
|
|
to:'dummy@localhost/pda',
|
|
|
|
from:'lounge@localhost/'+name,
|
|
|
|
type: 'unavailable'
|
|
|
|
}).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
|
|
.c('item').attrs({
|
|
|
|
affiliation: mock.chatroom_roles[name].affiliation,
|
|
|
|
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
|
|
|
|
role: 'none'
|
|
|
|
}).nodeTree;
|
|
|
|
this.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
|
expect(view.onChatRoomPresence).toHaveBeenCalled();
|
2015-10-31 17:30:06 +01:00
|
|
|
expect($occupants.find('li').length).toBe(i);
|
2015-03-01 13:28:24 +01:00
|
|
|
}
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("indicates moderators by means of a special css class and tooltip", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2015-03-01 11:58:07 +01:00
|
|
|
var view = this.chatboxviews.get('lounge@localhost');
|
|
|
|
|
|
|
|
var presence = $pres({
|
|
|
|
to:'dummy@localhost/pda',
|
|
|
|
from:'lounge@localhost/moderatorman'
|
|
|
|
}).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
|
|
.c('item').attrs({
|
|
|
|
affiliation: 'admin',
|
2015-03-01 13:28:24 +01:00
|
|
|
jid: name.replace(/ /g,'.').toLowerCase() + '@localhost',
|
2015-03-01 11:58:07 +01:00
|
|
|
role: 'moderator',
|
|
|
|
}).up()
|
|
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
|
|
|
|
|
|
this.connection._dataRecv(test_utils.createRequest(presence));
|
2015-10-31 17:30:06 +01:00
|
|
|
var occupant = view.$el.find('.occupant-list').find('li');
|
2013-05-11 14:34:36 +02:00
|
|
|
expect(occupant.length).toBe(1);
|
2015-03-01 11:58:07 +01:00
|
|
|
expect($(occupant).text()).toBe("moderatorman");
|
2013-05-11 14:34:36 +02:00
|
|
|
expect($(occupant).attr('class')).toBe('moderator');
|
|
|
|
expect($(occupant).attr('title')).toBe('This user is a moderator');
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:34:36 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("allows the user to invite their roster contacts to enter the chat room", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2014-08-31 22:48:26 +02:00
|
|
|
spyOn(converse, 'emit');
|
|
|
|
spyOn(window, 'prompt').andCallFake(function () {
|
|
|
|
return null;
|
|
|
|
});
|
2015-10-25 18:49:35 +01:00
|
|
|
var $input;
|
2014-09-06 12:25:37 +02:00
|
|
|
var view = this.chatboxviews.get('lounge@localhost');
|
2014-08-31 22:48:26 +02:00
|
|
|
view.$el.find('.chat-area').remove();
|
|
|
|
view.renderChatArea(); // Will init the widget
|
|
|
|
test_utils.createContacts('current'); // We need roster contacts, so that we have someone to invite
|
|
|
|
$input = view.$el.find('input.invited-contact.tt-input');
|
2015-10-25 18:49:35 +01:00
|
|
|
var $hint = view.$el.find('input.invited-contact.tt-hint');
|
2014-08-31 22:48:26 +02:00
|
|
|
runs (function () {
|
|
|
|
expect($input.length).toBe(1);
|
2016-04-07 12:35:07 +02:00
|
|
|
expect($input.attr('placeholder')).toBe('Invite');
|
2014-08-31 22:48:26 +02:00
|
|
|
$input.val("Felix");
|
|
|
|
$input.trigger('input');
|
|
|
|
});
|
|
|
|
waits(350); // Needed, due to debounce
|
|
|
|
runs (function () {
|
|
|
|
expect($input.val()).toBe('Felix');
|
|
|
|
expect($hint.val()).toBe('Felix Amsel');
|
|
|
|
var $sugg = view.$el.find('[data-jid="felix.amsel@localhost"]');
|
|
|
|
expect($sugg.length).toBe(1);
|
|
|
|
$sugg.trigger('click');
|
|
|
|
expect(window.prompt).toHaveBeenCalled();
|
|
|
|
});
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2014-08-31 19:25:54 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("can be joined automatically, based upon a received invite", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2014-09-02 20:01:49 +02:00
|
|
|
spyOn(window, 'confirm').andCallFake(function () {
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
test_utils.createContacts('current'); // We need roster contacts, who can invite us
|
2014-09-06 12:25:37 +02:00
|
|
|
var view = this.chatboxviews.get('lounge@localhost');
|
2014-09-02 20:01:49 +02:00
|
|
|
view.close();
|
|
|
|
var name = mock.cur_names[0];
|
|
|
|
var from_jid = name.replace(/ /g,'.').toLowerCase() + '@localhost';
|
|
|
|
var room_jid = 'lounge@localhost';
|
|
|
|
var reason = "Please join this chat room";
|
|
|
|
var message = $(
|
|
|
|
"<message from='"+from_jid+"' to='"+converse.bare_jid+"'>" +
|
|
|
|
"<x xmlns='jabber:x:conference'" +
|
|
|
|
"jid='"+room_jid+"'" +
|
|
|
|
"reason='"+reason+"'/>"+
|
|
|
|
"</message>"
|
|
|
|
)[0];
|
2014-09-22 12:55:14 +02:00
|
|
|
expect(converse.chatboxes.models.length).toBe(1);
|
|
|
|
expect(converse.chatboxes.models[0].id).toBe("controlbox");
|
2016-03-22 08:49:25 +01:00
|
|
|
converse.onDirectMUCInvitation(message);
|
2015-03-01 11:22:37 +01:00
|
|
|
expect(window.confirm).toHaveBeenCalledWith(
|
2014-09-02 20:01:49 +02:00
|
|
|
name + ' has invited you to join a chat room: '+ room_jid +
|
|
|
|
', and left the following reason: "'+reason+'"');
|
2014-09-22 12:55:14 +02:00
|
|
|
expect(converse.chatboxes.models.length).toBe(2);
|
|
|
|
expect(converse.chatboxes.models[0].id).toBe('controlbox');
|
|
|
|
expect(converse.chatboxes.models[1].id).toBe(room_jid);
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2014-09-02 20:01:49 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("shows received groupchat messages", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2013-12-16 18:19:25 +01:00
|
|
|
spyOn(converse, 'emit');
|
2014-09-06 12:25:37 +02:00
|
|
|
var view = this.chatboxviews.get('lounge@localhost');
|
2013-05-14 23:20:59 +02:00
|
|
|
if (!view.$el.find('.chat-area').length) { view.renderChatArea(); }
|
2013-11-02 09:56:20 +01:00
|
|
|
var nick = mock.chatroom_names[0];
|
2013-05-14 23:20:59 +02:00
|
|
|
var text = 'This is a received message';
|
|
|
|
var message = $msg({
|
2014-09-06 12:25:37 +02:00
|
|
|
from: 'lounge@localhost/'+nick,
|
2013-05-14 23:20:59 +02:00
|
|
|
id: '1',
|
|
|
|
to: 'dummy@localhost',
|
|
|
|
type: 'groupchat'
|
|
|
|
}).c('body').t(text);
|
|
|
|
view.onChatRoomMessage(message.nodeTree);
|
|
|
|
var $chat_content = view.$el.find('.chat-content');
|
|
|
|
expect($chat_content.find('.chat-message').length).toBe(1);
|
2015-10-28 09:52:19 +01:00
|
|
|
expect($chat_content.find('.chat-msg-content').text()).toBe(text);
|
2014-07-14 23:29:08 +02:00
|
|
|
expect(converse.emit).toHaveBeenCalledWith('message', message.nodeTree);
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-12-16 18:19:25 +01:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("shows sent groupchat messages", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2013-12-16 18:19:25 +01:00
|
|
|
spyOn(converse, 'emit');
|
2014-09-06 12:25:37 +02:00
|
|
|
var view = this.chatboxviews.get('lounge@localhost');
|
2013-12-16 18:19:25 +01:00
|
|
|
if (!view.$el.find('.chat-area').length) { view.renderChatArea(); }
|
|
|
|
var text = 'This is a sent message';
|
|
|
|
view.$el.find('.chat-textarea').text(text);
|
|
|
|
view.$el.find('textarea.chat-textarea').trigger($.Event('keypress', {keyCode: 13}));
|
2014-07-14 23:29:08 +02:00
|
|
|
expect(converse.emit).toHaveBeenCalledWith('messageSend', text);
|
2013-12-16 18:19:25 +01:00
|
|
|
|
|
|
|
var message = $msg({
|
2014-09-06 12:25:37 +02:00
|
|
|
from: 'lounge@localhost/dummy',
|
2013-12-16 18:19:25 +01:00
|
|
|
to: 'dummy@localhost.com',
|
2014-10-15 19:16:02 +02:00
|
|
|
type: 'groupchat',
|
|
|
|
id: view.model.messages.at(0).get('msgid')
|
2013-12-16 18:19:25 +01:00
|
|
|
}).c('body').t(text);
|
|
|
|
view.onChatRoomMessage(message.nodeTree);
|
|
|
|
var $chat_content = view.$el.find('.chat-content');
|
|
|
|
expect($chat_content.find('.chat-message').length).toBe(1);
|
2015-10-28 09:52:19 +01:00
|
|
|
expect($chat_content.find('.chat-msg-content').last().text()).toBe(text);
|
2013-12-16 18:19:25 +01:00
|
|
|
// We don't emit an event if it's our own message
|
|
|
|
expect(converse.emit.callCount, 1);
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-14 23:20:59 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("informs users if their nicknames has been changed.", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
/* The service then sends two presence stanzas to the full JID
|
|
|
|
* of each occupant (including the occupant who is changing his
|
|
|
|
* or her room nickname), one of type "unavailable" for the old
|
|
|
|
* nickname and one indicating availability for the new
|
|
|
|
* nickname.
|
|
|
|
*
|
|
|
|
* See: http://xmpp.org/extensions/xep-0045.html#changenick
|
|
|
|
*
|
|
|
|
* <presence
|
|
|
|
* from='coven@localhost/thirdwitch'
|
|
|
|
* id='DC352437-C019-40EC-B590-AF29E879AF98'
|
|
|
|
* to='hag66@shakespeare.lit/pda'
|
|
|
|
* type='unavailable'>
|
|
|
|
* <x xmlns='http://jabber.org/protocol/muc#user'>
|
|
|
|
* <item affiliation='member'
|
|
|
|
* jid='hag66@shakespeare.lit/pda'
|
|
|
|
* nick='oldhag'
|
2015-10-31 17:30:06 +01:00
|
|
|
* role='occupant'/>
|
2014-09-06 12:25:37 +02:00
|
|
|
* <status code='303'/>
|
|
|
|
* <status code='110'/>
|
|
|
|
* </x>
|
|
|
|
* </presence>
|
2015-03-01 11:22:37 +01:00
|
|
|
*
|
2014-09-06 12:25:37 +02:00
|
|
|
* <presence
|
|
|
|
* from='coven@localhost/oldhag'
|
|
|
|
* id='5B4F27A4-25ED-43F7-A699-382C6B4AFC67'
|
|
|
|
* to='hag66@shakespeare.lit/pda'>
|
|
|
|
* <x xmlns='http://jabber.org/protocol/muc#user'>
|
|
|
|
* <item affiliation='member'
|
|
|
|
* jid='hag66@shakespeare.lit/pda'
|
2015-10-31 17:30:06 +01:00
|
|
|
* role='occupant'/>
|
2014-09-06 12:25:37 +02:00
|
|
|
* <status code='110'/>
|
|
|
|
* </x>
|
|
|
|
* </presence>
|
|
|
|
*/
|
2015-10-07 10:57:11 +02:00
|
|
|
var __ = utils.__.bind(converse);
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'oldnick');
|
2015-03-01 11:22:37 +01:00
|
|
|
var view = this.chatboxviews.get('lounge@localhost');
|
|
|
|
var $chat_content = view.$el.find('.chat-content');
|
|
|
|
spyOn(view, 'onChatRoomPresence').andCallThrough();
|
|
|
|
|
|
|
|
// The user has just entered the room and receives their own
|
|
|
|
// presence from the server.
|
|
|
|
// See example 24:
|
|
|
|
// http://xmpp.org/extensions/xep-0045.html#enter-pres
|
|
|
|
var presence = $pres({
|
|
|
|
to:'dummy@localhost/pda',
|
|
|
|
from:'lounge@localhost/oldnick',
|
|
|
|
id:'DC352437-C019-40EC-B590-AF29E879AF97'
|
|
|
|
}).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
|
|
.c('item').attrs({
|
|
|
|
affiliation: 'member',
|
|
|
|
jid: 'dummy@localhost/pda',
|
2015-10-31 17:30:06 +01:00
|
|
|
role: 'occupant'
|
2015-03-01 11:22:37 +01:00
|
|
|
}).up()
|
|
|
|
.c('status').attrs({code:'110'}).up()
|
|
|
|
.c('status').attrs({code:'210'}).nodeTree;
|
|
|
|
|
|
|
|
this.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
|
expect(view.onChatRoomPresence).toHaveBeenCalled();
|
2015-10-31 17:30:06 +01:00
|
|
|
var $occupants = view.$('.occupant-list');
|
|
|
|
expect($occupants.children().length).toBe(1);
|
|
|
|
expect($occupants.children().first(0).text()).toBe("oldnick");
|
2015-03-01 11:22:37 +01:00
|
|
|
expect($chat_content.find('div.chat-info').length).toBe(1);
|
|
|
|
expect($chat_content.find('div.chat-info').html()).toBe(__(view.newNicknameMessages["210"], "oldnick"));
|
|
|
|
|
|
|
|
presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/oldnick',
|
|
|
|
id:'DC352437-C019-40EC-B590-AF29E879AF98',
|
|
|
|
to:'dummy@localhost/pda',
|
|
|
|
type:'unavailable'
|
|
|
|
})
|
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
|
|
.c('item').attrs({
|
|
|
|
affiliation: 'member',
|
|
|
|
jid: 'dummy@localhost/pda',
|
|
|
|
nick: 'newnick',
|
2015-10-31 17:30:06 +01:00
|
|
|
role: 'occupant'
|
2014-09-06 12:25:37 +02:00
|
|
|
}).up()
|
|
|
|
.c('status').attrs({code:'303'}).up()
|
|
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
|
|
|
2015-03-01 11:22:37 +01:00
|
|
|
this.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
|
expect(view.onChatRoomPresence).toHaveBeenCalled();
|
|
|
|
expect($chat_content.find('div.chat-info').length).toBe(2);
|
|
|
|
expect($chat_content.find('div.chat-info').last().html()).toBe(__(view.newNicknameMessages["303"], "newnick"));
|
2015-10-31 17:30:06 +01:00
|
|
|
$occupants = view.$('.occupant-list');
|
|
|
|
expect($occupants.children().length).toBe(0);
|
2014-09-06 12:25:37 +02:00
|
|
|
|
|
|
|
presence = $pres().attrs({
|
|
|
|
from:'lounge@localhost/newnick',
|
|
|
|
id:'5B4F27A4-25ED-43F7-A699-382C6B4AFC67',
|
|
|
|
to:'dummy@localhost/pda'
|
|
|
|
})
|
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
|
|
.c('item').attrs({
|
|
|
|
affiliation: 'member',
|
|
|
|
jid: 'dummy@localhost/pda',
|
2015-10-31 17:30:06 +01:00
|
|
|
role: 'occupant'
|
2014-09-06 12:25:37 +02:00
|
|
|
}).up()
|
|
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
2015-03-01 11:22:37 +01:00
|
|
|
|
|
|
|
this.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
|
expect(view.onChatRoomPresence).toHaveBeenCalled();
|
|
|
|
expect($chat_content.find('div.chat-info').length).toBe(2);
|
|
|
|
expect($chat_content.find('div.chat-info').last().html()).toBe(__(view.newNicknameMessages["303"], "newnick"));
|
2015-10-31 17:30:06 +01:00
|
|
|
$occupants = view.$('.occupant-list');
|
|
|
|
expect($occupants.children().length).toBe(1);
|
|
|
|
expect($occupants.children().first(0).text()).toBe("newnick");
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2014-09-06 12:46:24 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("informs users if they have been kicked out of the chat room", function () {
|
2014-09-06 12:46:24 +02:00
|
|
|
/* <presence
|
|
|
|
* from='harfleur@chat.shakespeare.lit/pistol'
|
|
|
|
* to='pistol@shakespeare.lit/harfleur'
|
|
|
|
* type='unavailable'>
|
|
|
|
* <x xmlns='http://jabber.org/protocol/muc#user'>
|
|
|
|
* <item affiliation='none' role='none'>
|
|
|
|
* <actor nick='Fluellen'/>
|
|
|
|
* <reason>Avaunt, you cullion!</reason>
|
|
|
|
* </item>
|
|
|
|
* <status code='307'/>
|
|
|
|
* </x>
|
|
|
|
* </presence>
|
|
|
|
*/
|
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
|
|
|
var presence = $pres().attrs({
|
|
|
|
from:'lounge@localhost/dummy',
|
|
|
|
to:'dummy@localhost/pda',
|
|
|
|
type:'unavailable'
|
|
|
|
})
|
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
|
|
.c('item').attrs({
|
|
|
|
affiliation: 'none',
|
|
|
|
jid: 'dummy@localhost/pda',
|
|
|
|
role: 'none'
|
|
|
|
})
|
|
|
|
.c('actor').attrs({nick: 'Fluellen'}).up()
|
|
|
|
.c('reason').t('Avaunt, you cullion!').up()
|
|
|
|
.up()
|
|
|
|
.c('status').attrs({code:'307'}).nodeTree;
|
|
|
|
|
|
|
|
var view = this.chatboxviews.get('lounge@localhost');
|
|
|
|
view.onChatRoomPresence(presence, {nick: 'dummy', name: 'lounge@localhost'});
|
2014-09-21 00:47:36 +02:00
|
|
|
expect(view.$('.chat-area').is(':visible')).toBeFalsy();
|
2015-10-31 17:30:06 +01:00
|
|
|
expect(view.$('.occupants').is(':visible')).toBeFalsy();
|
2015-10-24 21:52:54 +02:00
|
|
|
var $chat_body = view.$('.chatroom-body');
|
2014-09-21 00:47:36 +02:00
|
|
|
expect($chat_body.html().trim().indexOf('<p>You have been kicked from this room</p><p>The reason given is: "Avaunt, you cullion!"</p>')).not.toBe(-1);
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2014-09-06 12:25:37 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("can be saved to, and retrieved from, browserStorage", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2013-05-11 14:20:07 +02:00
|
|
|
// We instantiate a new ChatBoxes collection, which by default
|
|
|
|
// will be empty.
|
2014-08-08 22:06:01 +02:00
|
|
|
test_utils.openControlBox();
|
2013-05-11 14:20:07 +02:00
|
|
|
var newchatboxes = new this.ChatBoxes();
|
|
|
|
expect(newchatboxes.length).toEqual(0);
|
2014-06-30 19:21:16 +02:00
|
|
|
// The chatboxes will then be fetched from browserStorage inside the
|
2013-05-11 14:20:07 +02:00
|
|
|
// onConnected method
|
|
|
|
newchatboxes.onConnected();
|
2015-03-04 22:27:11 +01:00
|
|
|
expect(newchatboxes.length).toEqual(2);
|
2014-06-30 19:21:16 +02:00
|
|
|
// Check that the chatrooms retrieved from browserStorage
|
2013-05-11 14:20:07 +02:00
|
|
|
// have the same attributes values as the original ones.
|
2015-10-25 18:49:35 +01:00
|
|
|
var attrs = ['id', 'box_id', 'visible'];
|
|
|
|
var new_attrs, old_attrs;
|
|
|
|
for (var i=0; i<attrs.length; i++) {
|
2013-05-11 14:20:07 +02:00
|
|
|
new_attrs = _.pluck(_.pluck(newchatboxes.models, 'attributes'), attrs[i]);
|
|
|
|
old_attrs = _.pluck(_.pluck(this.chatboxes.models, 'attributes'), attrs[i]);
|
2014-04-18 17:42:11 +02:00
|
|
|
// FIXME: should have have to sort here? Order must
|
|
|
|
// probably be the same...
|
|
|
|
// This should be fixed once the controlbox always opens
|
|
|
|
// only on the right.
|
|
|
|
expect(_.isEqual(new_attrs.sort(), old_attrs.sort())).toEqual(true);
|
2013-05-11 14:20:07 +02:00
|
|
|
}
|
|
|
|
this.rosterview.render();
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2014-06-02 05:13:53 +02:00
|
|
|
it("can be minimized by clicking a DOM element with class 'toggle-chatbox-button'", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
|
|
|
var view = this.chatboxviews.get('lounge@localhost'),
|
2014-06-21 11:46:23 +02:00
|
|
|
trimmed_chatboxes = this.minimized_chats;
|
2014-06-02 05:13:53 +02:00
|
|
|
spyOn(view, 'minimize').andCallThrough();
|
|
|
|
spyOn(view, 'maximize').andCallThrough();
|
2014-03-14 20:35:43 +01:00
|
|
|
spyOn(converse, 'emit');
|
|
|
|
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
|
|
|
|
runs(function () {
|
|
|
|
view.$el.find('.toggle-chatbox-button').click();
|
|
|
|
});
|
2014-06-02 05:13:53 +02:00
|
|
|
waits(50);
|
2014-03-14 20:35:43 +01:00
|
|
|
runs(function () {
|
2014-06-02 05:13:53 +02:00
|
|
|
expect(view.minimize).toHaveBeenCalled();
|
2014-07-14 23:29:08 +02:00
|
|
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxMinimized', jasmine.any(Object));
|
2014-03-14 20:35:43 +01:00
|
|
|
expect(converse.emit.callCount, 2);
|
2014-06-02 05:13:53 +02:00
|
|
|
expect(view.$el.is(':visible')).toBeFalsy();
|
2014-03-14 20:35:43 +01:00
|
|
|
expect(view.model.get('minimized')).toBeTruthy();
|
2014-06-02 05:13:53 +02:00
|
|
|
expect(view.minimize).toHaveBeenCalled();
|
2015-10-25 18:49:35 +01:00
|
|
|
var trimmedview = trimmed_chatboxes.get(view.model.get('id'));
|
2014-06-02 05:13:53 +02:00
|
|
|
trimmedview.$("a.restore-chat").click();
|
2014-03-14 20:35:43 +01:00
|
|
|
});
|
2014-06-21 11:46:23 +02:00
|
|
|
waits(250);
|
2014-03-14 20:35:43 +01:00
|
|
|
runs(function () {
|
2014-06-02 05:13:53 +02:00
|
|
|
expect(view.maximize).toHaveBeenCalled();
|
2014-07-14 23:29:08 +02:00
|
|
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxMaximized', jasmine.any(Object));
|
2014-06-02 05:13:53 +02:00
|
|
|
expect(view.$el.is(':visible')).toBeTruthy();
|
2014-03-14 20:35:43 +01:00
|
|
|
expect(view.model.get('minimized')).toBeFalsy();
|
|
|
|
expect(converse.emit.callCount, 3);
|
|
|
|
});
|
|
|
|
}.bind(converse));
|
|
|
|
|
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("can be closed again by clicking a DOM element with class 'close-chatbox-button'", function () {
|
2014-09-06 12:25:37 +02:00
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2015-10-25 18:49:35 +01:00
|
|
|
var view = this.chatboxviews.get('lounge@localhost');
|
2014-05-27 18:34:22 +02:00
|
|
|
spyOn(view, 'close').andCallThrough();
|
2013-12-16 18:19:25 +01:00
|
|
|
spyOn(converse, 'emit');
|
2015-03-01 11:58:07 +01:00
|
|
|
spyOn(view, 'leave');
|
2013-05-11 14:20:07 +02:00
|
|
|
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
|
2014-02-28 03:04:52 +01:00
|
|
|
runs(function () {
|
|
|
|
view.$el.find('.close-chatbox-button').click();
|
|
|
|
});
|
2014-06-02 05:13:53 +02:00
|
|
|
waits(50);
|
2014-02-28 03:04:52 +01:00
|
|
|
runs(function () {
|
2014-05-27 18:34:22 +02:00
|
|
|
expect(view.close).toHaveBeenCalled();
|
2015-03-01 11:58:07 +01:00
|
|
|
expect(view.leave).toHaveBeenCalled();
|
2014-07-14 23:29:08 +02:00
|
|
|
expect(this.emit).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
2014-02-28 03:04:52 +01:00
|
|
|
}.bind(converse));
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
|
|
|
}.bind(converse));
|
2015-10-12 16:23:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
describe("Each chat room can take special commands", function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
runs(function () {
|
|
|
|
test_utils.closeAllChatBoxes();
|
|
|
|
test_utils.clearBrowserStorage();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("to clear messages", function () {
|
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2015-10-25 18:49:35 +01:00
|
|
|
var view = converse.chatboxviews.get('lounge@localhost');
|
2015-10-12 16:23:05 +02:00
|
|
|
spyOn(view, 'onChatRoomMessageSubmitted').andCallThrough();
|
|
|
|
spyOn(view, 'clearChatRoomMessages');
|
|
|
|
view.$el.find('.chat-textarea').text('/clear');
|
|
|
|
view.$el.find('textarea.chat-textarea').trigger($.Event('keypress', {keyCode: 13}));
|
|
|
|
expect(view.onChatRoomMessageSubmitted).toHaveBeenCalled();
|
|
|
|
expect(view.clearChatRoomMessages).toHaveBeenCalled();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
it("to ban a user", function () {
|
|
|
|
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
|
2015-10-25 18:49:35 +01:00
|
|
|
var view = converse.chatboxviews.get('lounge@localhost');
|
2015-10-12 16:23:05 +02:00
|
|
|
spyOn(view, 'onChatRoomMessageSubmitted').andCallThrough();
|
|
|
|
spyOn(view, 'setAffiliation').andCallThrough();
|
|
|
|
spyOn(view, 'showStatusNotification').andCallThrough();
|
|
|
|
spyOn(view, 'validateRoleChangeCommand').andCallThrough();
|
|
|
|
view.$el.find('.chat-textarea').text('/ban');
|
|
|
|
view.$el.find('textarea.chat-textarea').trigger($.Event('keypress', {keyCode: 13}));
|
|
|
|
expect(view.onChatRoomMessageSubmitted).toHaveBeenCalled();
|
|
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
|
|
expect(view.showStatusNotification).toHaveBeenCalledWith(
|
|
|
|
"Error: the \"ban\" command takes two arguments, the user's nickname and optionally a reason.",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
expect(view.setAffiliation).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
// Call now with the correct amount of arguments.
|
|
|
|
// XXX: Calling onChatRoomMessageSubmitted directly, trying
|
|
|
|
// again via triggering Event doesn't work for some weird
|
|
|
|
// reason.
|
|
|
|
view.onChatRoomMessageSubmitted('/ban jid This is the reason');
|
|
|
|
expect(view.validateRoleChangeCommand.callCount).toBe(2);
|
|
|
|
expect(view.showStatusNotification.callCount).toBe(1);
|
|
|
|
expect(view.setAffiliation).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
describe("When attempting to enter a chatroom", function () {
|
|
|
|
beforeEach(function () {
|
2014-03-04 14:54:36 +01:00
|
|
|
var roomspanel = this.chatboxviews.get('controlbox').roomspanel;
|
2013-05-11 14:20:07 +02:00
|
|
|
var $input = roomspanel.$el.find('input.new-chatroom-name');
|
2013-05-21 16:49:10 +02:00
|
|
|
var $nick = roomspanel.$el.find('input.new-chatroom-nick');
|
2013-05-11 14:20:07 +02:00
|
|
|
var $server = roomspanel.$el.find('input.new-chatroom-server');
|
|
|
|
$input.val('problematic');
|
2013-05-21 16:49:10 +02:00
|
|
|
$nick.val('dummy');
|
2013-05-11 14:20:07 +02:00
|
|
|
$server.val('muc.localhost');
|
|
|
|
roomspanel.$el.find('form').submit();
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
afterEach(function () {
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2014-05-27 18:34:22 +02:00
|
|
|
view.close();
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("will show an error message if the room requires a password", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'auth'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('not-authorized').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2013-05-14 09:43:49 +02:00
|
|
|
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-14 09:43:49 +02:00
|
|
|
spyOn(view, 'renderPasswordForm').andCallThrough();
|
|
|
|
runs(function () {
|
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
|
|
|
});
|
|
|
|
waits(250);
|
|
|
|
runs(function () {
|
2015-10-24 21:52:54 +02:00
|
|
|
var $chat_body = view.$el.find('.chatroom-body');
|
2013-05-14 09:43:49 +02:00
|
|
|
expect(view.renderPasswordForm).toHaveBeenCalled();
|
|
|
|
expect($chat_body.find('form.chatroom-form').length).toBe(1);
|
2013-06-02 22:32:33 +02:00
|
|
|
expect($chat_body.find('legend').text()).toBe('This chatroom requires a password');
|
2013-05-14 09:43:49 +02:00
|
|
|
});
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("will show an error message if the room is members-only and the user not included", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'auth'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('registration-required').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-30 21:24:00 +02:00
|
|
|
spyOn(view, 'showErrorMessage').andCallThrough();
|
2013-05-11 14:20:07 +02:00
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
2015-10-30 18:44:24 +01:00
|
|
|
expect(view.$el.find('.chatroom-body p:last').text()).toBe('You are not on the member list of this room');
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("will show an error message if the user has been banned", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'auth'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('forbidden').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-30 21:24:00 +02:00
|
|
|
spyOn(view, 'showErrorMessage').andCallThrough();
|
2013-05-11 14:20:07 +02:00
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
2015-10-30 18:44:24 +01:00
|
|
|
expect(view.$el.find('.chatroom-body p:last').text()).toBe('You have been banned from this room');
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("will show an error message if no nickname was specified for the user", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'modify'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('jid-malformed').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-30 21:24:00 +02:00
|
|
|
spyOn(view, 'showErrorMessage').andCallThrough();
|
2013-05-11 14:20:07 +02:00
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
2015-10-30 18:44:24 +01:00
|
|
|
expect(view.$el.find('.chatroom-body p:last').text()).toBe('No nickname was specified');
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("will show an error message if the user is not allowed to have created the room", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'cancel'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('not-allowed').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-30 21:24:00 +02:00
|
|
|
spyOn(view, 'showErrorMessage').andCallThrough();
|
2013-05-11 14:20:07 +02:00
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
2015-10-30 18:44:24 +01:00
|
|
|
expect(view.$el.find('.chatroom-body p:last').text()).toBe('You are not allowed to create new rooms');
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("will show an error message if the user's nickname doesn't conform to room policy", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'cancel'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('not-acceptable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-30 21:24:00 +02:00
|
|
|
spyOn(view, 'showErrorMessage').andCallThrough();
|
2013-05-11 14:20:07 +02:00
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
2015-10-30 18:44:24 +01:00
|
|
|
expect(view.$el.find('.chatroom-body p:last').text()).toBe("Your nickname doesn't conform to this room's policies");
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("will show an error message if the user's nickname is already taken", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'cancel'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('conflict').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-30 21:24:00 +02:00
|
|
|
spyOn(view, 'showErrorMessage').andCallThrough();
|
2013-05-11 14:20:07 +02:00
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
2015-10-30 18:44:24 +01:00
|
|
|
expect(view.$el.find('.chatroom-body p:last').text()).toBe("Your nickname is already taken");
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2015-10-07 10:57:11 +02:00
|
|
|
it("will show an error message if the room doesn't yet exist", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'cancel'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('item-not-found').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-30 21:24:00 +02:00
|
|
|
spyOn(view, 'showErrorMessage').andCallThrough();
|
2013-05-11 14:20:07 +02:00
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
2015-10-30 18:44:24 +01:00
|
|
|
expect(view.$el.find('.chatroom-body p:last').text()).toBe("This room does not (yet) exist");
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
2013-05-11 14:20:07 +02:00
|
|
|
|
2016-04-04 12:34:23 +02:00
|
|
|
it("will show an error message if the room has reached its maximum number of occupants", function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
var presence = $pres().attrs({
|
2014-09-06 12:25:37 +02:00
|
|
|
from:'lounge@localhost/thirdwitch',
|
2014-04-18 17:42:11 +02:00
|
|
|
id:'n13mt3l',
|
2014-09-06 12:25:37 +02:00
|
|
|
to:'dummy@localhost/pda',
|
2014-04-18 17:42:11 +02:00
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
2014-09-06 12:25:37 +02:00
|
|
|
.c('error').attrs({by:'lounge@localhost', type:'cancel'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('service-unavailable').attrs({xmlns:'urn:ietf:params:xml:ns:xmpp-stanzas'}).nodeTree;
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('problematic@muc.localhost');
|
2013-05-30 21:24:00 +02:00
|
|
|
spyOn(view, 'showErrorMessage').andCallThrough();
|
2013-05-11 14:20:07 +02:00
|
|
|
view.onChatRoomPresence(presence, {'nick': 'dummy'});
|
2016-04-04 12:34:23 +02:00
|
|
|
expect(view.$el.find('.chatroom-body p:last').text()).toBe("This room has reached its maximum number of occupants");
|
2015-10-07 10:57:11 +02:00
|
|
|
}.bind(converse));
|
|
|
|
}.bind(converse));
|
|
|
|
}.bind(converse, mock, test_utils));
|
2013-05-11 14:20:07 +02:00
|
|
|
}));
|