|
@@ -60,49 +60,49 @@
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
|
|
|
|
|
|
+ let jid, room, chatroomview;
|
|
|
|
+
|
|
test_utils.createContacts(_converse, 'current');
|
|
test_utils.createContacts(_converse, 'current');
|
|
- test_utils.waitUntil(function () {
|
|
|
|
- return $(_converse.rosterview.el).find('.roster-group .group-toggle').length;
|
|
|
|
- }, 300).then(function () {
|
|
|
|
- test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
|
|
|
|
- var jid = 'lounge@localhost';
|
|
|
|
- var room = _converse.api.rooms.get(jid);
|
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
|
-
|
|
|
|
- var chatroomview = _converse.chatboxviews.get(jid);
|
|
|
|
- expect(chatroomview.is_chatroom).toBeTruthy();
|
|
|
|
-
|
|
|
|
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
|
|
|
|
- chatroomview.close();
|
|
|
|
-
|
|
|
|
- // Test with mixed case
|
|
|
|
- test_utils.openAndEnterChatRoom(_converse, 'Leisure', 'localhost', 'dummy').then(function () {
|
|
|
|
- jid = 'Leisure@localhost';
|
|
|
|
- room = _converse.api.rooms.get(jid);
|
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
|
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
|
|
|
|
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
|
|
|
|
-
|
|
|
|
- jid = 'leisure@localhost';
|
|
|
|
- room = _converse.api.rooms.get(jid);
|
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
|
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
|
|
|
|
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
|
|
|
|
-
|
|
|
|
- jid = 'leiSure@localhost';
|
|
|
|
- room = _converse.api.rooms.get(jid);
|
|
|
|
- expect(room instanceof Object).toBeTruthy();
|
|
|
|
- chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
|
|
|
|
- expect(u.isVisible(chatroomview.el)).toBeTruthy();
|
|
|
|
- chatroomview.close();
|
|
|
|
-
|
|
|
|
- // Non-existing room
|
|
|
|
- jid = 'lounge2@localhost';
|
|
|
|
- room = _converse.api.rooms.get(jid);
|
|
|
|
- expect(typeof room === 'undefined').toBeTruthy();
|
|
|
|
- done();
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ test_utils.waitUntil(() => _converse.rosterview.el.querySelectorAll('.roster-group .group-toggle').length, 300)
|
|
|
|
+ .then(() => test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy'))
|
|
|
|
+ .then(() => {
|
|
|
|
+ jid = 'lounge@localhost';
|
|
|
|
+ room = _converse.api.rooms.get(jid);
|
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
|
+
|
|
|
|
+ chatroomview = _converse.chatboxviews.get(jid);
|
|
|
|
+ expect(chatroomview.is_chatroom).toBeTruthy();
|
|
|
|
+
|
|
|
|
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
|
|
|
|
+ chatroomview.close();
|
|
|
|
+
|
|
|
|
+ // Test with mixed case
|
|
|
|
+ return test_utils.openAndEnterChatRoom(_converse, 'Leisure', 'localhost', 'dummy');
|
|
|
|
+ }).then(() => {
|
|
|
|
+ jid = 'Leisure@localhost';
|
|
|
|
+ room = _converse.api.rooms.get(jid);
|
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
|
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
|
|
|
|
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
|
|
|
|
+
|
|
|
|
+ jid = 'leisure@localhost';
|
|
|
|
+ room = _converse.api.rooms.get(jid);
|
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
|
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
|
|
|
|
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
|
|
|
|
+
|
|
|
|
+ jid = 'leiSure@localhost';
|
|
|
|
+ room = _converse.api.rooms.get(jid);
|
|
|
|
+ expect(room instanceof Object).toBeTruthy();
|
|
|
|
+ chatroomview = _converse.chatboxviews.get(jid.toLowerCase());
|
|
|
|
+ expect(u.isVisible(chatroomview.el)).toBeTruthy();
|
|
|
|
+ chatroomview.close();
|
|
|
|
+
|
|
|
|
+ // Non-existing room
|
|
|
|
+ jid = 'lounge2@localhost';
|
|
|
|
+ room = _converse.api.rooms.get(jid);
|
|
|
|
+ expect(typeof room === 'undefined').toBeTruthy();
|
|
|
|
+ done();
|
|
});
|
|
});
|
|
}));
|
|
}));
|
|
|
|
|
|
@@ -1240,8 +1240,9 @@
|
|
var occupants = view.el.querySelector('.occupant-list').querySelectorAll('li');
|
|
var occupants = view.el.querySelector('.occupant-list').querySelectorAll('li');
|
|
expect(occupants.length).toBe(1);
|
|
expect(occupants.length).toBe(1);
|
|
expect($(occupants).first().find('.occupant-nick').text().trim()).toBe("dummy");
|
|
expect($(occupants).first().find('.occupant-nick').text().trim()).toBe("dummy");
|
|
- expect($(occupants).first().find('.badge').length).toBe(1);
|
|
|
|
- expect($(occupants).first().find('.badge').first().text()).toBe('Member');
|
|
|
|
|
|
+ expect($(occupants).first().find('.badge').length).toBe(2);
|
|
|
|
+ expect($(occupants).first().find('.badge').first().text()).toBe('Owner');
|
|
|
|
+ expect($(occupants).first().find('.badge').last().text()).toBe('Moderator');
|
|
|
|
|
|
var presence = $pres({
|
|
var presence = $pres({
|
|
to:'dummy@localhost/pda',
|
|
to:'dummy@localhost/pda',
|
|
@@ -1255,15 +1256,15 @@
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
|
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
- occupants = view.el.querySelector('.occupant-list').querySelectorAll('li');
|
|
|
|
|
|
+ occupants = view.el.querySelectorAll('.occupant-list li');
|
|
expect(occupants.length).toBe(2);
|
|
expect(occupants.length).toBe(2);
|
|
- expect($(occupants).first().find('.occupant-nick').text().trim()).toBe("moderatorman");
|
|
|
|
- expect($(occupants).last().find('.occupant-nick').text().trim()).toBe("dummy");
|
|
|
|
- expect($(occupants).first().find('.badge').length).toBe(2);
|
|
|
|
- expect($(occupants).first().find('.badge').first().text()).toBe('Admin');
|
|
|
|
- expect($(occupants).first().find('.badge').last().text()).toBe('Moderator');
|
|
|
|
|
|
+ expect($(occupants).first().find('.occupant-nick').text().trim()).toBe("dummy");
|
|
|
|
+ expect($(occupants).last().find('.occupant-nick').text().trim()).toBe("moderatorman");
|
|
|
|
+ expect($(occupants).last().find('.badge').length).toBe(2);
|
|
|
|
+ expect($(occupants).last().find('.badge').first().text()).toBe('Admin');
|
|
|
|
+ expect($(occupants).last().find('.badge').last().text()).toBe('Moderator');
|
|
|
|
|
|
- expect($(occupants).first().attr('title')).toBe(
|
|
|
|
|
|
+ expect($(occupants).last().attr('title')).toBe(
|
|
contact_jid + ' This user is a moderator. Click to mention moderatorman in your message.'
|
|
contact_jid + ' This user is a moderator. Click to mention moderatorman in your message.'
|
|
);
|
|
);
|
|
|
|
|
|
@@ -1706,10 +1707,10 @@
|
|
})
|
|
})
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
.c('item').attrs({
|
|
.c('item').attrs({
|
|
- affiliation: 'member',
|
|
|
|
|
|
+ affiliation: 'owner',
|
|
jid: 'dummy@localhost/pda',
|
|
jid: 'dummy@localhost/pda',
|
|
nick: 'newnick',
|
|
nick: 'newnick',
|
|
- role: 'participant'
|
|
|
|
|
|
+ role: 'moderator'
|
|
}).up()
|
|
}).up()
|
|
.c('status').attrs({code:'303'}).up()
|
|
.c('status').attrs({code:'303'}).up()
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
@@ -1730,9 +1731,9 @@
|
|
})
|
|
})
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
.c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
.c('item').attrs({
|
|
.c('item').attrs({
|
|
- affiliation: 'member',
|
|
|
|
|
|
+ affiliation: 'owner',
|
|
jid: 'dummy@localhost/pda',
|
|
jid: 'dummy@localhost/pda',
|
|
- role: 'participant'
|
|
|
|
|
|
+ role: 'moderator'
|
|
}).up()
|
|
}).up()
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
.c('status').attrs({code:'110'}).nodeTree;
|
|
|
|
|
|
@@ -2047,7 +2048,7 @@
|
|
expect(view.model.get('minimized')).toBeFalsy();
|
|
expect(view.model.get('minimized')).toBeFalsy();
|
|
expect(_converse.emit.calls.count(), 3);
|
|
expect(_converse.emit.calls.count(), 3);
|
|
done();
|
|
done();
|
|
-
|
|
|
|
|
|
+
|
|
});
|
|
});
|
|
}));
|
|
}));
|
|
|
|
|
|
@@ -2075,7 +2076,7 @@
|
|
|
|
|
|
describe("Each chat groupchat can take special commands", function () {
|
|
describe("Each chat groupchat can take special commands", function () {
|
|
|
|
|
|
- it("/help to show the available commands",
|
|
|
|
|
|
+ it("takes /help to show the available commands",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
@@ -2111,10 +2112,176 @@
|
|
expect(info_messages.pop().textContent).toBe('/ban: Ban user from groupchat');
|
|
expect(info_messages.pop().textContent).toBe('/ban: Ban user from groupchat');
|
|
expect(info_messages.pop().textContent).toBe('/admin: Change user\'s affiliation to admin');
|
|
expect(info_messages.pop().textContent).toBe('/admin: Change user\'s affiliation to admin');
|
|
done();
|
|
done();
|
|
- });
|
|
|
|
|
|
+ }).catch(_.partial(console.error, _));
|
|
|
|
+ }));
|
|
|
|
+
|
|
|
|
+ it("takes /member to make an occupant a member",
|
|
|
|
+ mock.initConverseWithPromises(
|
|
|
|
+ null, ['rosterGroupsFetched'], {},
|
|
|
|
+ function (done, _converse) {
|
|
|
|
+
|
|
|
|
+ let iq_stanza, view;
|
|
|
|
+
|
|
|
|
+ test_utils.openAndEnterChatRoom(_converse, 'lounge', 'muc.localhost', 'dummy')
|
|
|
|
+ .then(() => {
|
|
|
|
+
|
|
|
|
+ view = _converse.chatboxviews.get('lounge@muc.localhost');
|
|
|
|
+ /* We don't show join/leave messages for existing occupants. We
|
|
|
|
+ * know about them because we receive their presences before we
|
|
|
|
+ * receive our own.
|
|
|
|
+ */
|
|
|
|
+ const presence = $pres({
|
|
|
|
+ to: 'dummy@localhost/resource',
|
|
|
|
+ from: 'lounge@muc.localhost/marc'
|
|
|
|
+ }).c('x', {xmlns: Strophe.NS.MUC_USER})
|
|
|
|
+ .c('item', {
|
|
|
|
+ 'affiliation': 'none',
|
|
|
|
+ 'jid': 'marc@localhost/_converse.js-290929789',
|
|
|
|
+ 'role': 'participant'
|
|
|
|
+ });
|
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
|
+ expect(view.model.occupants.length).toBe(2);
|
|
|
|
+
|
|
|
|
+ const textarea = view.el.querySelector('.chat-textarea');
|
|
|
|
+ let sent_stanza;
|
|
|
|
+ spyOn(_converse.connection, 'send').and.callFake((stanza) => {
|
|
|
|
+ sent_stanza = stanza;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // First check that an error message appears when a
|
|
|
|
+ // non-existent nick is used.
|
|
|
|
+ textarea.value = '/member chris Welcome to the club!';
|
|
|
|
+ view.keyPressed({
|
|
|
|
+ target: textarea,
|
|
|
|
+ preventDefault: _.noop,
|
|
|
|
+ keyCode: 13
|
|
|
|
+ });
|
|
|
|
+ expect(_converse.connection.send).not.toHaveBeenCalled();
|
|
|
|
+ expect(view.el.querySelectorAll('.chat-error').length).toBe(1);
|
|
|
|
+ expect(view.el.querySelector('.chat-error').textContent.trim())
|
|
|
|
+ .toBe(`Error: Can't find a groupchat participant with the nickname "chris"`)
|
|
|
|
+
|
|
|
|
+ // Now test with an existing nick
|
|
|
|
+ textarea.value = '/member marc Welcome to the club!';
|
|
|
|
+ view.keyPressed({
|
|
|
|
+ target: textarea,
|
|
|
|
+ preventDefault: _.noop,
|
|
|
|
+ keyCode: 13
|
|
|
|
+ });
|
|
|
|
+ expect(_converse.connection.send).toHaveBeenCalled();
|
|
|
|
+ expect(sent_stanza.outerHTML).toBe(
|
|
|
|
+ `<iq to="lounge@muc.localhost" type="set" xmlns="jabber:client" id="${sent_stanza.getAttribute('id')}">`+
|
|
|
|
+ `<query xmlns="http://jabber.org/protocol/muc#admin">`+
|
|
|
|
+ `<item affiliation="member" jid="marc@localhost">`+
|
|
|
|
+ `<reason>Welcome to the club!</reason>`+
|
|
|
|
+ `</item>`+
|
|
|
|
+ `</query>`+
|
|
|
|
+ `</iq>`);
|
|
|
|
+
|
|
|
|
+ const result = $iq({
|
|
|
|
+ "xmlns": "jabber:client",
|
|
|
|
+ "type": "result",
|
|
|
|
+ "to": "dummy@localhost/resource",
|
|
|
|
+ "from": "lounge@muc.localhost",
|
|
|
|
+ "id": sent_stanza.getAttribute('id')
|
|
|
|
+ });
|
|
|
|
+ _converse.connection.IQ_stanzas = [];
|
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(result));
|
|
|
|
+
|
|
|
|
+ return test_utils.waitUntil(() => {
|
|
|
|
+ return _.filter(
|
|
|
|
+ _converse.connection.IQ_stanzas,
|
|
|
|
+ (iq) => {
|
|
|
|
+ const node = iq.nodeTree.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="member"]');
|
|
|
|
+ if (node) { iq_stanza = iq.nodeTree;}
|
|
|
|
+ return node;
|
|
|
|
+ }).length;
|
|
|
|
+ });
|
|
|
|
+ }).then(() => {
|
|
|
|
+ expect(iq_stanza.outerHTML).toBe(
|
|
|
|
+ `<iq to="lounge@muc.localhost" type="get" xmlns="jabber:client" id="${iq_stanza.getAttribute('id')}">`+
|
|
|
|
+ `<query xmlns="http://jabber.org/protocol/muc#admin">`+
|
|
|
|
+ `<item affiliation="member"/>`+
|
|
|
|
+ `</query>`+
|
|
|
|
+ `</iq>`)
|
|
|
|
+ expect(view.model.occupants.length).toBe(2);
|
|
|
|
+
|
|
|
|
+ const result = $iq({
|
|
|
|
+ "xmlns": "jabber:client",
|
|
|
|
+ "type": "result",
|
|
|
|
+ "to": "dummy@localhost/resource",
|
|
|
|
+ "from": "lounge@muc.localhost",
|
|
|
|
+ "id": iq_stanza.getAttribute("id")
|
|
|
|
+ }).c("query", {"xmlns": "http://jabber.org/protocol/muc#admin"})
|
|
|
|
+ .c("item", {"jid": "marc", "affiliation": "member"});
|
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(result));
|
|
|
|
+
|
|
|
|
+ expect(view.model.occupants.length).toBe(2);
|
|
|
|
+ return test_utils.waitUntil(() => {
|
|
|
|
+ return _.filter(
|
|
|
|
+ _converse.connection.IQ_stanzas,
|
|
|
|
+ (iq) => {
|
|
|
|
+ const node = iq.nodeTree.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="owner"]');
|
|
|
|
+ if (node) { iq_stanza = iq.nodeTree;}
|
|
|
|
+ return node;
|
|
|
|
+ }).length;
|
|
|
|
+ });
|
|
|
|
+ }).then(() => {
|
|
|
|
+ expect(iq_stanza.outerHTML).toBe(
|
|
|
|
+ `<iq to="lounge@muc.localhost" type="get" xmlns="jabber:client" id="${iq_stanza.getAttribute('id')}">`+
|
|
|
|
+ `<query xmlns="http://jabber.org/protocol/muc#admin">`+
|
|
|
|
+ `<item affiliation="owner"/>`+
|
|
|
|
+ `</query>`+
|
|
|
|
+ `</iq>`)
|
|
|
|
+ expect(view.model.occupants.length).toBe(2);
|
|
|
|
+
|
|
|
|
+ const result = $iq({
|
|
|
|
+ "xmlns": "jabber:client",
|
|
|
|
+ "type": "result",
|
|
|
|
+ "to": "dummy@localhost/resource",
|
|
|
|
+ "from": "lounge@muc.localhost",
|
|
|
|
+ "id": iq_stanza.getAttribute("id")
|
|
|
|
+ }).c("query", {"xmlns": "http://jabber.org/protocol/muc#admin"})
|
|
|
|
+ .c("item", {"jid": "dummy@localhost", "affiliation": "owner"});
|
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(result));
|
|
|
|
+
|
|
|
|
+ expect(view.model.occupants.length).toBe(2);
|
|
|
|
+ return test_utils.waitUntil(() => {
|
|
|
|
+ return _.filter(
|
|
|
|
+ _converse.connection.IQ_stanzas,
|
|
|
|
+ (iq) => {
|
|
|
|
+ const node = iq.nodeTree.querySelector('iq[to="lounge@muc.localhost"][type="get"] item[affiliation="admin"]');
|
|
|
|
+ if (node) { iq_stanza = iq.nodeTree;}
|
|
|
|
+ return node;
|
|
|
|
+ }).length;
|
|
|
|
+ });
|
|
|
|
+ }).then(() => {
|
|
|
|
+ expect(iq_stanza.outerHTML).toBe(
|
|
|
|
+ `<iq to="lounge@muc.localhost" type="get" xmlns="jabber:client" id="${iq_stanza.getAttribute('id')}">`+
|
|
|
|
+ `<query xmlns="http://jabber.org/protocol/muc#admin">`+
|
|
|
|
+ `<item affiliation="admin"/>`+
|
|
|
|
+ `</query>`+
|
|
|
|
+ `</iq>`)
|
|
|
|
+ expect(view.model.occupants.length).toBe(2);
|
|
|
|
+
|
|
|
|
+ const result = $iq({
|
|
|
|
+ "xmlns": "jabber:client",
|
|
|
|
+ "type": "result",
|
|
|
|
+ "to": "dummy@localhost/resource",
|
|
|
|
+ "from": "lounge@muc.localhost",
|
|
|
|
+ "id": iq_stanza.getAttribute("id")
|
|
|
|
+ }).c("query", {"xmlns": "http://jabber.org/protocol/muc#admin"})
|
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(result));
|
|
|
|
+
|
|
|
|
+ return test_utils.waitUntil(() => view.el.querySelectorAll('.badge').length > 1);
|
|
|
|
+ }).then(() => {
|
|
|
|
+ expect(view.model.occupants.length).toBe(2);
|
|
|
|
+ expect(view.el.querySelectorAll('.occupant').length).toBe(2);
|
|
|
|
+ done();
|
|
|
|
+ }).catch(_.partial(console.error, _));
|
|
}));
|
|
}));
|
|
|
|
|
|
- it("/topic to set the groupchat topic",
|
|
|
|
|
|
+ it("takes /topic to set the groupchat topic",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
@@ -2169,7 +2336,7 @@
|
|
}).catch(_.partial(console.error, _));
|
|
}).catch(_.partial(console.error, _));
|
|
}));
|
|
}));
|
|
|
|
|
|
- it("/clear to clear messages",
|
|
|
|
|
|
+ it("takes /clear to clear messages",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
@@ -2192,7 +2359,7 @@
|
|
}).catch(_.partial(console.error, _));
|
|
}).catch(_.partial(console.error, _));
|
|
}));
|
|
}));
|
|
|
|
|
|
- it("/owner to make a user an owner",
|
|
|
|
|
|
+ it("takes /owner to make a user an owner",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
@@ -2219,9 +2386,7 @@
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
- "Error: the \"owner\" command takes two arguments, the user's nickname and optionally a reason.",
|
|
|
|
- true
|
|
|
|
- );
|
|
|
|
|
|
+ "Error: the \"owner\" command takes two arguments, the user's nickname and optionally a reason.");
|
|
expect(view.model.setAffiliation).not.toHaveBeenCalled();
|
|
expect(view.model.setAffiliation).not.toHaveBeenCalled();
|
|
|
|
|
|
// Call now with the correct amount of arguments.
|
|
// Call now with the correct amount of arguments.
|
|
@@ -2245,7 +2410,7 @@
|
|
}).catch(_.partial(console.error, _));
|
|
}).catch(_.partial(console.error, _));
|
|
}));
|
|
}));
|
|
|
|
|
|
- it("/ban to ban a user",
|
|
|
|
|
|
+ it("takes /ban to ban a user",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
@@ -2272,9 +2437,7 @@
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
- "Error: the \"ban\" command takes two arguments, the user's nickname and optionally a reason.",
|
|
|
|
- true
|
|
|
|
- );
|
|
|
|
|
|
+ "Error: the \"ban\" command takes two arguments, the user's nickname and optionally a reason.");
|
|
expect(view.model.setAffiliation).not.toHaveBeenCalled();
|
|
expect(view.model.setAffiliation).not.toHaveBeenCalled();
|
|
// Call now with the correct amount of arguments.
|
|
// Call now with the correct amount of arguments.
|
|
// XXX: Calling onMessageSubmitted directly, trying
|
|
// XXX: Calling onMessageSubmitted directly, trying
|
|
@@ -2297,7 +2460,7 @@
|
|
}).catch(_.partial(console.error, _));
|
|
}).catch(_.partial(console.error, _));
|
|
}));
|
|
}));
|
|
|
|
|
|
- it("/kick to kick a user",
|
|
|
|
|
|
+ it("takes /kick to kick a user",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
@@ -2325,9 +2488,7 @@
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
- "Error: the \"kick\" command takes two arguments, the user's nickname and optionally a reason.",
|
|
|
|
- true
|
|
|
|
- );
|
|
|
|
|
|
+ "Error: the \"kick\" command takes two arguments, the user's nickname and optionally a reason.");
|
|
expect(view.modifyRole).not.toHaveBeenCalled();
|
|
expect(view.modifyRole).not.toHaveBeenCalled();
|
|
// Call now with the correct amount of arguments.
|
|
// Call now with the correct amount of arguments.
|
|
// XXX: Calling onMessageSubmitted directly, trying
|
|
// XXX: Calling onMessageSubmitted directly, trying
|
|
@@ -2376,7 +2537,7 @@
|
|
}));
|
|
}));
|
|
|
|
|
|
|
|
|
|
- it("/op and /deop to make a user a moderator or not",
|
|
|
|
|
|
+ it("takes /op and /deop to make a user a moderator or not",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
@@ -2431,9 +2592,7 @@
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
- "Error: the \"op\" command takes two arguments, the user's nickname and optionally a reason.",
|
|
|
|
- true
|
|
|
|
- );
|
|
|
|
|
|
+ "Error: the \"op\" command takes two arguments, the user's nickname and optionally a reason.");
|
|
|
|
|
|
expect(view.modifyRole).not.toHaveBeenCalled();
|
|
expect(view.modifyRole).not.toHaveBeenCalled();
|
|
// Call now with the correct amount of arguments.
|
|
// Call now with the correct amount of arguments.
|
|
@@ -2516,12 +2675,13 @@
|
|
}).catch(_.partial(console.error, _));
|
|
}).catch(_.partial(console.error, _));
|
|
}));
|
|
}));
|
|
|
|
|
|
- it("/mute and /voice to mute and unmute a user",
|
|
|
|
|
|
+ it("takes /mute and /voice to mute and unmute a user",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched'], {},
|
|
null, ['rosterGroupsFetched'], {},
|
|
function (done, _converse) {
|
|
function (done, _converse) {
|
|
|
|
|
|
- test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
|
|
|
|
|
|
+ test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy')
|
|
|
|
+ .then(() => {
|
|
var sent_IQ, IQ_id;
|
|
var sent_IQ, IQ_id;
|
|
var sendIQ = _converse.connection.sendIQ;
|
|
var sendIQ = _converse.connection.sendIQ;
|
|
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
@@ -2571,9 +2731,7 @@
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.onMessageSubmitted).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.validateRoleChangeCommand).toHaveBeenCalled();
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
- "Error: the \"mute\" command takes two arguments, the user's nickname and optionally a reason.",
|
|
|
|
- true
|
|
|
|
- );
|
|
|
|
|
|
+ "Error: the \"mute\" command takes two arguments, the user's nickname and optionally a reason.");
|
|
expect(view.modifyRole).not.toHaveBeenCalled();
|
|
expect(view.modifyRole).not.toHaveBeenCalled();
|
|
// Call now with the correct amount of arguments.
|
|
// Call now with the correct amount of arguments.
|
|
// XXX: Calling onMessageSubmitted directly, trying
|
|
// XXX: Calling onMessageSubmitted directly, trying
|
|
@@ -2659,6 +2817,19 @@
|
|
|
|
|
|
describe("When attempting to enter a groupchat", function () {
|
|
describe("When attempting to enter a groupchat", function () {
|
|
|
|
|
|
|
|
+ it("will use the nickname set in the global settings if the user doesn't have a VCard nickname",
|
|
|
|
+ mock.initConverseWithPromises(
|
|
|
|
+ null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'nickname': 'Benedict-Cucumberpatch'},
|
|
|
|
+ function (done, _converse) {
|
|
|
|
+
|
|
|
|
+ test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost')
|
|
|
|
+ .then(function () {
|
|
|
|
+ const view = _converse.chatboxviews.get('problematic@muc.localhost');
|
|
|
|
+ expect(view.model.get('nick')).toBe('Benedict-Cucumberpatch');
|
|
|
|
+ done();
|
|
|
|
+ }).catch(_.partial(console.error, _));
|
|
|
|
+ }));
|
|
|
|
+
|
|
it("will show an error message if the groupchat requires a password",
|
|
it("will show an error message if the groupchat requires a password",
|
|
mock.initConverseWithPromises(
|
|
mock.initConverseWithPromises(
|
|
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
|
|
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
|
|
@@ -3324,30 +3495,9 @@
|
|
var view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
|
|
var view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
|
|
var $chat_content = $(view.el).find('.chat-content');
|
|
var $chat_content = $(view.el).find('.chat-content');
|
|
|
|
|
|
- /* <presence to="dummy@localhost/_converse.js-29092160"
|
|
|
|
- * from="coven@chat.shakespeare.lit/some1">
|
|
|
|
- * <x xmlns="http://jabber.org/protocol/muc#user">
|
|
|
|
- * <item affiliation="owner" jid="dummy@localhost/_converse.js-29092160" role="moderator"/>
|
|
|
|
- * <status code="110"/>
|
|
|
|
- * </x>
|
|
|
|
- * </presence></body>
|
|
|
|
- */
|
|
|
|
- var presence = $pres({
|
|
|
|
- to: 'dummy@localhost/_converse.js-29092160',
|
|
|
|
- from: 'coven@chat.shakespeare.lit/some1'
|
|
|
|
- }).c('x', {xmlns: Strophe.NS.MUC_USER})
|
|
|
|
- .c('item', {
|
|
|
|
- 'affiliation': 'owner',
|
|
|
|
- 'jid': 'dummy@localhost/_converse.js-29092160',
|
|
|
|
- 'role': 'moderator'
|
|
|
|
- }).up()
|
|
|
|
- .c('status', {code: '110'});
|
|
|
|
- _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:first').html()).toBe("some1 has entered the groupchat");
|
|
expect($chat_content.find('div.chat-info:first').html()).toBe("some1 has entered the groupchat");
|
|
- expect($chat_content.find('div.chat-info:last').html()).toBe("some1 is now a moderator");
|
|
|
|
|
|
|
|
- presence = $pres({
|
|
|
|
|
|
+ let presence = $pres({
|
|
to: 'dummy@localhost/_converse.js-29092160',
|
|
to: 'dummy@localhost/_converse.js-29092160',
|
|
from: 'coven@chat.shakespeare.lit/newguy'
|
|
from: 'coven@chat.shakespeare.lit/newguy'
|
|
})
|
|
})
|
|
@@ -3358,7 +3508,7 @@
|
|
'role': 'participant'
|
|
'role': 'participant'
|
|
});
|
|
});
|
|
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
- expect($chat_content[0].querySelectorAll('div.chat-info').length).toBe(3);
|
|
|
|
|
|
+ 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 groupchat");
|
|
expect($chat_content.find('div.chat-info:last').html()).toBe("newguy has entered the groupchat");
|
|
|
|
|
|
presence = $pres({
|
|
presence = $pres({
|
|
@@ -3372,7 +3522,7 @@
|
|
'role': 'participant'
|
|
'role': 'participant'
|
|
});
|
|
});
|
|
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
- expect($chat_content[0].querySelectorAll('div.chat-info').length).toBe(4);
|
|
|
|
|
|
+ expect($chat_content[0].querySelectorAll('div.chat-info').length).toBe(3);
|
|
expect($chat_content.find('div.chat-info:last').html()).toBe("nomorenicks has entered the groupchat");
|
|
expect($chat_content.find('div.chat-info:last').html()).toBe("nomorenicks has entered the groupchat");
|
|
|
|
|
|
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
|
|
// See XEP-0085 http://xmpp.org/extensions/xep-0085.html#definitions
|
|
@@ -3389,11 +3539,10 @@
|
|
|
|
|
|
// Check that the notification appears inside the chatbox in the DOM
|
|
// Check that the notification appears inside the chatbox in the DOM
|
|
var events = view.el.querySelectorAll('.chat-event');
|
|
var events = view.el.querySelectorAll('.chat-event');
|
|
- expect(events.length).toBe(4);
|
|
|
|
|
|
+ expect(events.length).toBe(3);
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
- expect(events[1].textContent).toEqual('some1 is now a moderator');
|
|
|
|
- expect(events[2].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
- expect(events[3].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
+ expect(events[1].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
+ expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
var notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
var notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
expect(notifications.length).toBe(1);
|
|
expect(notifications.length).toBe(1);
|
|
@@ -3414,11 +3563,10 @@
|
|
view.model.onMessage(msg);
|
|
view.model.onMessage(msg);
|
|
|
|
|
|
events = view.el.querySelectorAll('.chat-event');
|
|
events = view.el.querySelectorAll('.chat-event');
|
|
- expect(events.length).toBe(4);
|
|
|
|
|
|
+ expect(events.length).toBe(3);
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
- expect(events[1].textContent).toEqual('some1 is now a moderator');
|
|
|
|
- expect(events[2].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
- expect(events[3].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
+ expect(events[1].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
+ expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
expect(notifications.length).toBe(1);
|
|
expect(notifications.length).toBe(1);
|
|
@@ -3435,11 +3583,10 @@
|
|
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
|
|
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
|
|
view.model.onMessage(msg);
|
|
view.model.onMessage(msg);
|
|
events = view.el.querySelectorAll('.chat-event');
|
|
events = view.el.querySelectorAll('.chat-event');
|
|
- expect(events.length).toBe(4);
|
|
|
|
|
|
+ expect(events.length).toBe(3);
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
- expect(events[1].textContent).toEqual('some1 is now a moderator');
|
|
|
|
- expect(events[2].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
- expect(events[3].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
+ expect(events[1].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
+ expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
expect(notifications.length).toBe(2);
|
|
expect(notifications.length).toBe(2);
|
|
@@ -3458,7 +3605,7 @@
|
|
view.model.onMessage(msg);
|
|
view.model.onMessage(msg);
|
|
|
|
|
|
var messages = view.el.querySelectorAll('.message');
|
|
var messages = view.el.querySelectorAll('.message');
|
|
- expect(messages.length).toBe(8);
|
|
|
|
|
|
+ expect(messages.length).toBe(7);
|
|
expect(view.el.querySelectorAll('.chat-msg').length).toBe(1);
|
|
expect(view.el.querySelectorAll('.chat-msg').length).toBe(1);
|
|
expect(view.el.querySelector('.chat-msg .chat-msg__text').textContent).toBe('hello world');
|
|
expect(view.el.querySelector('.chat-msg .chat-msg__text').textContent).toBe('hello world');
|
|
|
|
|
|
@@ -3466,11 +3613,10 @@
|
|
// via timeout.
|
|
// via timeout.
|
|
timeout_functions[0]();
|
|
timeout_functions[0]();
|
|
events = view.el.querySelectorAll('.chat-event');
|
|
events = view.el.querySelectorAll('.chat-event');
|
|
- expect(events.length).toBe(4);
|
|
|
|
|
|
+ expect(events.length).toBe(3);
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
- expect(events[1].textContent).toEqual('some1 is now a moderator');
|
|
|
|
- expect(events[2].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
- expect(events[3].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
+ expect(events[1].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
+ expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
expect(notifications.length).toBe(1);
|
|
expect(notifications.length).toBe(1);
|
|
@@ -3478,11 +3624,10 @@
|
|
|
|
|
|
timeout_functions[1]();
|
|
timeout_functions[1]();
|
|
events = view.el.querySelectorAll('.chat-event');
|
|
events = view.el.querySelectorAll('.chat-event');
|
|
- expect(events.length).toBe(4);
|
|
|
|
|
|
+ expect(events.length).toBe(3);
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
expect(events[0].textContent).toEqual('some1 has entered the groupchat');
|
|
- expect(events[1].textContent).toEqual('some1 is now a moderator');
|
|
|
|
- expect(events[2].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
- expect(events[3].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
+ expect(events[1].textContent).toEqual('newguy has entered the groupchat');
|
|
|
|
+ expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
|
|
|
|
|
|
notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
notifications = view.el.querySelectorAll('.chat-state-notification');
|
|
expect(notifications.length).toBe(0);
|
|
expect(notifications.length).toBe(0);
|