|
@@ -2107,7 +2107,7 @@
|
|
|
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"`)
|
|
|
+ .toBe(`Error: couldn't find a groupchat participant "chris"`)
|
|
|
|
|
|
// Now test with an existing nick
|
|
|
textarea.value = '/member marc Welcome to the club!';
|
|
@@ -2312,18 +2312,33 @@
|
|
|
null, ['rosterGroupsFetched'], {},
|
|
|
function (done, _converse) {
|
|
|
|
|
|
+ let sent_IQ, IQ_id;
|
|
|
+ const sendIQ = _converse.connection.sendIQ;
|
|
|
+ spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
+ sent_IQ = iq;
|
|
|
+ IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
+ });
|
|
|
+
|
|
|
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
|
|
|
- var sent_IQ, IQ_id;
|
|
|
- var sendIQ = _converse.connection.sendIQ;
|
|
|
- spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
- sent_IQ = iq;
|
|
|
- IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
- });
|
|
|
var view = _converse.chatboxviews.get('lounge@localhost');
|
|
|
spyOn(view, 'onMessageSubmitted').and.callThrough();
|
|
|
spyOn(view.model, 'setAffiliation').and.callThrough();
|
|
|
spyOn(view, 'showErrorMessage').and.callThrough();
|
|
|
spyOn(view, 'validateRoleChangeCommand').and.callThrough();
|
|
|
+
|
|
|
+ let presence = $pres({
|
|
|
+ 'from': 'lounge@localhost/annoyingGuy',
|
|
|
+ 'id':'27C55F89-1C6A-459A-9EB5-77690145D624',
|
|
|
+ 'to': 'dummy@localhost/desktop'
|
|
|
+ })
|
|
|
+ .c('x', { 'xmlns': 'http://jabber.org/protocol/muc#user'})
|
|
|
+ .c('item', {
|
|
|
+ 'jid': 'annoyingguy@localhost',
|
|
|
+ 'affiliation': 'member',
|
|
|
+ 'role': 'participant'
|
|
|
+ });
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
+
|
|
|
var textarea = view.el.querySelector('.chat-textarea')
|
|
|
textarea.value = '/owner';
|
|
|
view.keyPressed({
|
|
@@ -2337,23 +2352,42 @@
|
|
|
"Error: the \"owner\" command takes two arguments, the user's nickname and optionally a reason.");
|
|
|
expect(view.model.setAffiliation).not.toHaveBeenCalled();
|
|
|
|
|
|
+ view.onMessageSubmitted('/owner nobody You\'re responsible');
|
|
|
+ expect(view.showErrorMessage).toHaveBeenCalledWith(
|
|
|
+ 'Error: couldn\'t find a groupchat participant "nobody"');
|
|
|
+ expect(view.model.setAffiliation).not.toHaveBeenCalled();
|
|
|
+
|
|
|
// Call now with the correct amount of arguments.
|
|
|
// XXX: Calling onMessageSubmitted directly, trying
|
|
|
// again via triggering Event doesn't work for some weird
|
|
|
// reason.
|
|
|
- view.onMessageSubmitted('/owner annoyingGuy@localhost You\'re responsible');
|
|
|
- expect(view.validateRoleChangeCommand.calls.count()).toBe(2);
|
|
|
- expect(view.showErrorMessage.calls.count()).toBe(1);
|
|
|
+ view.onMessageSubmitted('/owner annoyingGuy You\'re responsible');
|
|
|
+ expect(view.validateRoleChangeCommand.calls.count()).toBe(3);
|
|
|
expect(view.model.setAffiliation).toHaveBeenCalled();
|
|
|
+ expect(view.showErrorMessage.calls.count()).toBe(2);
|
|
|
// Check that the member list now gets updated
|
|
|
expect(sent_IQ.toLocaleString()).toBe(
|
|
|
"<iq to='lounge@localhost' type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+
|
|
|
"<query xmlns='http://jabber.org/protocol/muc#admin'>"+
|
|
|
- "<item affiliation='owner' jid='annoyingGuy@localhost'>"+
|
|
|
+ "<item affiliation='owner' jid='annoyingGuy'>"+
|
|
|
"<reason>You're responsible</reason>"+
|
|
|
"</item>"+
|
|
|
"</query>"+
|
|
|
"</iq>");
|
|
|
+
|
|
|
+ presence = $pres({
|
|
|
+ 'from': 'lounge@localhost/annoyingGuy',
|
|
|
+ 'id':'27C55F89-1C6A-459A-9EB5-77690145D628',
|
|
|
+ 'to': 'dummy@localhost/desktop'
|
|
|
+ })
|
|
|
+ .c('x', { 'xmlns': 'http://jabber.org/protocol/muc#user'})
|
|
|
+ .c('item', {
|
|
|
+ 'jid': 'annoyingguy@localhost',
|
|
|
+ 'affiliation': 'owner',
|
|
|
+ 'role': 'participant'
|
|
|
+ });
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
+ expect(view.el.querySelectorAll('.chat-info')[4].textContent).toBe("annoyingGuy is now an owner of this groupchat");
|
|
|
done();
|
|
|
}).catch(_.partial(console.error, _));
|
|
|
}));
|
|
@@ -2363,19 +2397,35 @@
|
|
|
null, ['rosterGroupsFetched'], {},
|
|
|
function (done, _converse) {
|
|
|
|
|
|
- test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
|
|
|
- var sent_IQ, IQ_id;
|
|
|
- var sendIQ = _converse.connection.sendIQ;
|
|
|
- spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
- sent_IQ = iq;
|
|
|
- IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
- });
|
|
|
- var view = _converse.chatboxviews.get('lounge@localhost');
|
|
|
+ let sent_IQ, IQ_id;
|
|
|
+ const sendIQ = _converse.connection.sendIQ;
|
|
|
+ spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
+ sent_IQ = iq;
|
|
|
+ IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
+ });
|
|
|
+
|
|
|
+ test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy')
|
|
|
+ .then(() => {
|
|
|
+ const view = _converse.chatboxviews.get('lounge@localhost');
|
|
|
spyOn(view, 'onMessageSubmitted').and.callThrough();
|
|
|
spyOn(view.model, 'setAffiliation').and.callThrough();
|
|
|
spyOn(view, 'showErrorMessage').and.callThrough();
|
|
|
spyOn(view, 'validateRoleChangeCommand').and.callThrough();
|
|
|
- var textarea = view.el.querySelector('.chat-textarea')
|
|
|
+
|
|
|
+ let presence = $pres({
|
|
|
+ 'from': 'lounge@localhost/annoyingGuy',
|
|
|
+ 'id':'27C55F89-1C6A-459A-9EB5-77690145D624',
|
|
|
+ 'to': 'dummy@localhost/desktop'
|
|
|
+ })
|
|
|
+ .c('x', { 'xmlns': 'http://jabber.org/protocol/muc#user'})
|
|
|
+ .c('item', {
|
|
|
+ 'jid': 'annoyingguy@localhost',
|
|
|
+ 'affiliation': 'member',
|
|
|
+ 'role': 'participant'
|
|
|
+ });
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
+
|
|
|
+ const textarea = view.el.querySelector('.chat-textarea')
|
|
|
textarea.value = '/ban';
|
|
|
view.keyPressed({
|
|
|
target: textarea,
|
|
@@ -2388,10 +2438,11 @@
|
|
|
"Error: the \"ban\" command takes two arguments, the user's nickname and optionally a reason.");
|
|
|
expect(view.model.setAffiliation).not.toHaveBeenCalled();
|
|
|
// Call now with the correct amount of arguments.
|
|
|
+
|
|
|
// XXX: Calling onMessageSubmitted directly, trying
|
|
|
// again via triggering Event doesn't work for some weird
|
|
|
// reason.
|
|
|
- view.onMessageSubmitted('/ban annoyingGuy@localhost You\'re annoying');
|
|
|
+ view.onMessageSubmitted('/ban annoyingGuy You\'re annoying');
|
|
|
expect(view.validateRoleChangeCommand.calls.count()).toBe(2);
|
|
|
expect(view.showErrorMessage.calls.count()).toBe(1);
|
|
|
expect(view.model.setAffiliation).toHaveBeenCalled();
|
|
@@ -2399,11 +2450,27 @@
|
|
|
expect(sent_IQ.toLocaleString()).toBe(
|
|
|
"<iq to='lounge@localhost' type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+
|
|
|
"<query xmlns='http://jabber.org/protocol/muc#admin'>"+
|
|
|
- "<item affiliation='outcast' jid='annoyingGuy@localhost'>"+
|
|
|
+ "<item affiliation='outcast' jid='annoyingGuy'>"+
|
|
|
"<reason>You're annoying</reason>"+
|
|
|
"</item>"+
|
|
|
"</query>"+
|
|
|
"</iq>");
|
|
|
+
|
|
|
+ presence = $pres({
|
|
|
+ 'from': 'lounge@localhost/annoyingGuy',
|
|
|
+ 'id':'27C55F89-1C6A-459A-9EB5-77690145D628',
|
|
|
+ 'to': 'dummy@localhost/desktop'
|
|
|
+ })
|
|
|
+ .c('x', { 'xmlns': 'http://jabber.org/protocol/muc#user'})
|
|
|
+ .c('item', {
|
|
|
+ 'jid': 'annoyingguy@localhost',
|
|
|
+ 'affiliation': 'outcast',
|
|
|
+ 'role': 'participant'
|
|
|
+ });
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
+ expect(
|
|
|
+ view.el.querySelectorAll('.chat-info')[3].textContent).toBe(
|
|
|
+ "annoyingGuy has been banned from this groupchat");
|
|
|
done();
|
|
|
}).catch(_.partial(console.error, _));
|
|
|
}));
|
|
@@ -2413,19 +2480,33 @@
|
|
|
null, ['rosterGroupsFetched'], {},
|
|
|
function (done, _converse) {
|
|
|
|
|
|
+ let sent_IQ, IQ_id;
|
|
|
+ const sendIQ = _converse.connection.sendIQ;
|
|
|
+ spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
+ sent_IQ = iq;
|
|
|
+ IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
+ });
|
|
|
+
|
|
|
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
|
|
|
- var sent_IQ, IQ_id;
|
|
|
- var sendIQ = _converse.connection.sendIQ;
|
|
|
- spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
- sent_IQ = iq;
|
|
|
- IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
- });
|
|
|
- var view = _converse.chatboxviews.get('lounge@localhost');
|
|
|
+ const view = _converse.chatboxviews.get('lounge@localhost');
|
|
|
spyOn(view, 'onMessageSubmitted').and.callThrough();
|
|
|
spyOn(view, 'modifyRole').and.callThrough();
|
|
|
spyOn(view, 'showErrorMessage').and.callThrough();
|
|
|
spyOn(view, 'validateRoleChangeCommand').and.callThrough();
|
|
|
|
|
|
+ let presence = $pres({
|
|
|
+ 'from': 'lounge@localhost/annoyingGuy',
|
|
|
+ 'id':'27C55F89-1C6A-459A-9EB5-77690145D624',
|
|
|
+ 'to': 'dummy@localhost/desktop'
|
|
|
+ })
|
|
|
+ .c('x', { 'xmlns': 'http://jabber.org/protocol/muc#user'})
|
|
|
+ .c('item', {
|
|
|
+ 'jid': 'annoyingguy@localhost',
|
|
|
+ 'affiliation': 'none',
|
|
|
+ 'role': 'participant'
|
|
|
+ });
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
+
|
|
|
var textarea = view.el.querySelector('.chat-textarea')
|
|
|
textarea.value = '/kick';
|
|
|
view.keyPressed({
|
|
@@ -2465,7 +2546,7 @@
|
|
|
* </x>
|
|
|
* </presence>
|
|
|
*/
|
|
|
- var presence = $pres({
|
|
|
+ presence = $pres({
|
|
|
'from': 'lounge@localhost/annoyingGuy',
|
|
|
'to': 'dummy@localhost/desktop',
|
|
|
'type': 'unavailable'
|
|
@@ -2477,9 +2558,8 @@
|
|
|
}).up()
|
|
|
.c('status', {'code': '307'});
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
- expect(
|
|
|
- view.el.querySelectorAll('.chat-info')[2].textContent).toBe(
|
|
|
- "annoyingGuy has been kicked out");
|
|
|
+ expect(view.el.querySelectorAll('.chat-info')[3].textContent).toBe("annoyingGuy has been kicked out");
|
|
|
+ expect(view.el.querySelectorAll('.chat-info').length).toBe(4);
|
|
|
done();
|
|
|
}).catch(_.partial(console.error, _));
|
|
|
}));
|