2013-05-11 14:20:07 +02:00
|
|
|
(function (root, factory) {
|
|
|
|
define([
|
2013-11-02 09:56:20 +01:00
|
|
|
"mock",
|
2014-08-08 22:06:01 +02:00
|
|
|
"test_utils"
|
|
|
|
], function (mock, test_utils) {
|
|
|
|
return factory(mock, test_utils);
|
2013-05-11 14:20:07 +02:00
|
|
|
}
|
|
|
|
);
|
2014-08-08 22:06:01 +02:00
|
|
|
} (this, function (mock, test_utils) {
|
|
|
|
return describe("ChatRooms", $.proxy(function (mock, test_utils) {
|
2013-05-11 14:20:07 +02:00
|
|
|
describe("A Chat Room", $.proxy(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-02-28 03:04:52 +01:00
|
|
|
});
|
|
|
|
waits(250);
|
|
|
|
runs(function () {
|
2014-08-08 22:06:01 +02:00
|
|
|
test_utils.openControlBox();
|
2014-02-28 03:04:52 +01:00
|
|
|
});
|
|
|
|
waits(250);
|
|
|
|
runs(function () {
|
2014-08-08 22:06:01 +02:00
|
|
|
test_utils.openRoomsPanel();
|
2014-02-28 03:04:52 +01:00
|
|
|
});
|
2014-04-18 17:42:11 +02:00
|
|
|
waits(501);
|
2014-02-28 03:04:52 +01:00
|
|
|
runs(function () {
|
|
|
|
// Open a new chatroom
|
2014-03-04 14:54:36 +01:00
|
|
|
var roomspanel = converse.chatboxviews.get('controlbox').roomspanel;
|
2014-02-28 03:04:52 +01:00
|
|
|
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');
|
|
|
|
$input.val('lounge');
|
|
|
|
$nick.val('dummy');
|
|
|
|
$server.val('muc.localhost');
|
|
|
|
roomspanel.$el.find('form').submit();
|
|
|
|
});
|
|
|
|
waits(250);
|
|
|
|
runs(function () {
|
2014-08-08 22:06:01 +02:00
|
|
|
test_utils.closeControlBox();
|
2014-02-28 03:04:52 +01:00
|
|
|
});
|
|
|
|
waits(250);
|
|
|
|
runs(function () {});
|
2014-01-19 06:02:18 +01:00
|
|
|
});
|
|
|
|
|
2013-05-11 14:20:07 +02:00
|
|
|
it("shows users currently present in the room", $.proxy(function () {
|
2014-03-04 14:54:36 +01:00
|
|
|
var chatroomview = this.chatboxviews.get('lounge@muc.localhost'),
|
2013-05-14 22:13:05 +02:00
|
|
|
$participant_list;
|
2013-05-11 14:20:07 +02:00
|
|
|
var roster = {}, room = {}, i;
|
2013-11-02 09:56:20 +01:00
|
|
|
for (i=0; i<mock.chatroom_names.length-1; i++) {
|
|
|
|
roster[mock.chatroom_names[i]] = {};
|
2013-05-11 14:20:07 +02:00
|
|
|
chatroomview.onChatRoomRoster(roster, room);
|
2013-05-14 22:13:05 +02:00
|
|
|
$participant_list = chatroomview.$el.find('.participant-list');
|
2013-05-11 14:20:07 +02:00
|
|
|
expect($participant_list.find('li').length).toBe(1+i);
|
2013-11-02 09:56:20 +01:00
|
|
|
expect($($participant_list.find('li')[i]).text()).toBe(mock.chatroom_names[i]);
|
2013-05-11 14:20:07 +02:00
|
|
|
}
|
|
|
|
roster[converse.bare_jid] = {};
|
|
|
|
chatroomview.onChatRoomRoster(roster, room);
|
|
|
|
}, converse));
|
|
|
|
|
2013-05-11 14:34:36 +02:00
|
|
|
it("indicates moderators by means of a special css class and tooltip", $.proxy(function () {
|
2014-03-04 14:54:36 +01:00
|
|
|
var chatroomview = this.chatboxviews.get('lounge@muc.localhost');
|
2013-11-02 09:56:20 +01:00
|
|
|
var roster = {}, idx = mock.chatroom_names.length-1;
|
|
|
|
roster[mock.chatroom_names[idx]] = {};
|
|
|
|
roster[mock.chatroom_names[idx]].role = 'moderator';
|
2013-05-11 14:34:36 +02:00
|
|
|
chatroomview.onChatRoomRoster(roster, {});
|
2013-05-14 22:13:05 +02:00
|
|
|
var occupant = chatroomview.$el.find('.participant-list').find('li');
|
2013-05-11 14:34:36 +02:00
|
|
|
expect(occupant.length).toBe(1);
|
2013-11-02 09:56:20 +01:00
|
|
|
expect($(occupant).text()).toBe(mock.chatroom_names[idx]);
|
2013-05-11 14:34:36 +02:00
|
|
|
expect($(occupant).attr('class')).toBe('moderator');
|
|
|
|
expect($(occupant).attr('title')).toBe('This user is a moderator');
|
|
|
|
}, converse));
|
|
|
|
|
2013-12-16 18:19:25 +01:00
|
|
|
it("shows received groupchat messages", $.proxy(function () {
|
|
|
|
spyOn(converse, 'emit');
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('lounge@muc.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({
|
|
|
|
from: 'lounge@muc.localhost/'+nick,
|
|
|
|
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);
|
|
|
|
expect($chat_content.find('.chat-message-content').text()).toBe(text);
|
2014-07-14 23:29:08 +02:00
|
|
|
expect(converse.emit).toHaveBeenCalledWith('message', message.nodeTree);
|
2013-12-16 18:19:25 +01:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("shows sent groupchat messages", $.proxy(function () {
|
|
|
|
spyOn(converse, 'emit');
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('lounge@muc.localhost');
|
2013-12-16 18:19:25 +01:00
|
|
|
if (!view.$el.find('.chat-area').length) { view.renderChatArea(); }
|
|
|
|
var nick = mock.chatroom_names[0];
|
|
|
|
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({
|
|
|
|
from: 'lounge@muc.localhost/dummy',
|
|
|
|
id: '2',
|
|
|
|
to: 'dummy@localhost.com',
|
|
|
|
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);
|
|
|
|
expect($chat_content.find('.chat-message-content').last().text()).toBe(text);
|
|
|
|
// We don't emit an event if it's our own message
|
|
|
|
expect(converse.emit.callCount, 1);
|
2013-05-14 23:20:59 +02:00
|
|
|
}, converse));
|
|
|
|
|
2014-06-30 19:21:16 +02:00
|
|
|
it("can be saved to, and retrieved from, browserStorage", $.proxy(function () {
|
2013-05-11 14:20:07 +02:00
|
|
|
// We instantiate a new ChatBoxes collection, which by default
|
|
|
|
// will be empty.
|
2014-05-27 19:18:02 +02:00
|
|
|
spyOn(this.chatboxviews, 'trimChats');
|
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();
|
2014-05-27 19:18:02 +02:00
|
|
|
expect(this.chatboxviews.trimChats).toHaveBeenCalled();
|
2014-04-18 17:42:11 +02:00
|
|
|
expect(newchatboxes.length).toEqual(2); // XXX: Includes controlbox, is this a bug?
|
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.
|
|
|
|
attrs = ['id', 'box_id', 'visible'];
|
|
|
|
for (i=0; i<attrs.length; i++) {
|
|
|
|
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();
|
|
|
|
}, converse));
|
|
|
|
|
2014-06-02 05:13:53 +02:00
|
|
|
it("can be minimized by clicking a DOM element with class 'toggle-chatbox-button'", function () {
|
2014-03-14 20:35:43 +01:00
|
|
|
var view = this.chatboxviews.get('lounge@muc.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();
|
|
|
|
trimmedview = trimmed_chatboxes.get(view.model.get('id'));
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
2013-05-11 14:20:07 +02:00
|
|
|
it("can be closed again by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
|
2014-03-04 14:54:36 +01:00
|
|
|
var view = this.chatboxviews.get('lounge@muc.localhost'), chatroom = view.model, $el;
|
2014-05-27 18:34:22 +02:00
|
|
|
spyOn(view, 'close').andCallThrough();
|
2013-12-16 18:19:25 +01:00
|
|
|
spyOn(converse, 'emit');
|
2013-05-11 14:20:07 +02:00
|
|
|
spyOn(converse.connection.muc, 'leave');
|
|
|
|
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();
|
2014-02-28 03:04:52 +01:00
|
|
|
expect(this.connection.muc.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));
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
}, converse));
|
|
|
|
|
|
|
|
describe("When attempting to enter a chatroom", $.proxy(function () {
|
|
|
|
beforeEach($.proxy(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();
|
|
|
|
}, converse));
|
|
|
|
|
|
|
|
afterEach($.proxy(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();
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if the room requires a password", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'auth'})
|
|
|
|
.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 () {
|
|
|
|
var $chat_body = view.$el.find('.chat-body');
|
|
|
|
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
|
|
|
});
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if the room is members-only and the user not included", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'auth'})
|
|
|
|
.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'});
|
2013-05-14 09:43:49 +02:00
|
|
|
expect(view.$el.find('.chat-body p').text()).toBe('You are not on the member list of this room');
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if the user has been banned", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'auth'})
|
|
|
|
.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'});
|
2013-05-14 09:43:49 +02:00
|
|
|
expect(view.$el.find('.chat-body p').text()).toBe('You have been banned from this room');
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if no nickname was specified for the user", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'modify'})
|
|
|
|
.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'});
|
2013-05-14 09:43:49 +02:00
|
|
|
expect(view.$el.find('.chat-body p').text()).toBe('No nickname was specified');
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if the user is not allowed to have created the room", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
|
|
|
|
.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'});
|
2013-05-14 09:43:49 +02:00
|
|
|
expect(view.$el.find('.chat-body p').text()).toBe('You are not allowed to create new rooms');
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if the user's nickname doesn't conform to room policy", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
|
|
|
|
.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'});
|
2013-05-14 22:13:05 +02:00
|
|
|
expect(view.$el.find('.chat-body p').text()).toBe("Your nickname doesn't conform to this room's policies");
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if the user's nickname is already taken", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
|
|
|
|
.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'});
|
2013-05-14 09:43:49 +02:00
|
|
|
expect(view.$el.find('.chat-body p').text()).toBe("Your nickname is already taken");
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if the room doesn't yet exist", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
|
|
|
|
.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'});
|
2013-05-14 09:43:49 +02:00
|
|
|
expect(view.$el.find('.chat-body p').text()).toBe("This room does not (yet) exist");
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
|
|
|
|
it("will show an error message if the room has reached it's maximum number of occupants", $.proxy(function () {
|
|
|
|
var presence = $pres().attrs({
|
2014-04-18 17:42:11 +02:00
|
|
|
from:'coven@chat.shakespeare.lit/thirdwitch',
|
|
|
|
id:'n13mt3l',
|
|
|
|
to:'hag66@shakespeare.lit/pda',
|
|
|
|
type:'error'})
|
2013-05-11 14:20:07 +02:00
|
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc'}).up()
|
|
|
|
.c('error').attrs({by:'coven@chat.shakespeare.lit', type:'cancel'})
|
|
|
|
.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'});
|
2013-05-14 09:43:49 +02:00
|
|
|
expect(view.$el.find('.chat-body p').text()).toBe("This room has reached it's maximum number of occupants");
|
2013-05-11 14:20:07 +02:00
|
|
|
}, converse));
|
|
|
|
}, converse));
|
2014-08-08 22:06:01 +02:00
|
|
|
}, converse, mock, test_utils));
|
2013-05-11 14:20:07 +02:00
|
|
|
}));
|