Remove jquery from tests

This commit is contained in:
JC Brand 2019-04-06 16:31:42 +02:00
parent 1a22a94491
commit 5532a9ec63
14 changed files with 500 additions and 579 deletions

46
dist/converse.js vendored
View File

@ -47993,8 +47993,14 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
'info_toggle_bookmark': this.model.get('bookmarked') ? __('Unbookmark this groupchat') : __('Bookmark this groupchat'), 'info_toggle_bookmark': this.model.get('bookmarked') ? __('Unbookmark this groupchat') : __('Bookmark this groupchat'),
'bookmarked': this.model.get('bookmarked') 'bookmarked': this.model.get('bookmarked')
})); }));
const close_button = this.el.querySelector('.close-chatbox-button'); const buttons_row = this.el.querySelector('.chatbox-buttons');
close_button.insertAdjacentHTML('afterend', bookmark_button); const close_button = buttons_row.querySelector('.close-chatbox-button');
if (close_button) {
close_button.insertAdjacentHTML('afterend', bookmark_button);
} else {
buttons_row.insertAdjacentHTML('beforeEnd', bookmark_button);
}
}, },
async renderHeading() { async renderHeading() {
@ -52743,10 +52749,18 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
const div = document.createElement('div'); const div = document.createElement('div');
div.innerHTML = html; div.innerHTML = html;
const button = div.querySelector('.close-chatbox-button'); const buttons_row = div.querySelector('.chatbox-buttons');
button.insertAdjacentHTML('afterend', templates_chatbox_minimize_html__WEBPACK_IMPORTED_MODULE_2___default()({ const button = buttons_row.querySelector('.close-chatbox-button');
const minimize_el = templates_chatbox_minimize_html__WEBPACK_IMPORTED_MODULE_2___default()({
'info_minimize': __('Minimize this chat box') 'info_minimize': __('Minimize this chat box')
})); });
if (button) {
button.insertAdjacentHTML('afterend', minimize_el);
} else {
buttons_row.insertAdjacentHTML('beforeEnd', minimize_el);
}
return div.innerHTML; return div.innerHTML;
} }
@ -53601,7 +53615,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
'submit form': 'showRooms', 'submit form': 'showRooms',
'click a.room-info': 'toggleRoomInfo', 'click a.room-info': 'toggleRoomInfo',
'change input[name=nick]': 'setNick', 'change input[name=nick]': 'setNick',
'change input[name=server]': 'setDomain', 'change input[name=server]': 'setDomainFromEvent',
'click .open-room': 'openRoom' 'click .open-room': 'openRoom'
}, },
@ -53726,12 +53740,12 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
showRooms(ev) { showRooms(ev) {
ev.preventDefault(); ev.preventDefault();
const data = new FormData(ev.target); const data = new FormData(ev.target);
this.model.save('muc_domain', Strophe.getDomainFromJid(data.get('server'))); this.model.setDomain(data.get('server'));
this.updateRoomsList(); this.updateRoomsList();
}, },
setDomain(ev) { setDomainFromEvent(ev) {
this.model.save('muc_domain', Strophe.getDomainFromJid(ev.target.value)); this.model.setDomain(ev.target.value);
}, },
setNick(ev) { setNick(ev) {
@ -53778,7 +53792,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
parseRoomDataFromEvent(form) { parseRoomDataFromEvent(form) {
const data = new FormData(form); const data = new FormData(form);
const jid = data.get('chatroom'); const jid = data.get('chatroom');
this.model.save('muc_domain', Strophe.getDomainFromJid(jid));
let nick; let nick;
if (_converse.locked_muc_nickname) { if (_converse.locked_muc_nickname) {
@ -53812,6 +53825,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
jid = `${Strophe.escapeNode(data.jid)}@${_converse.muc_domain}`; jid = `${Strophe.escapeNode(data.jid)}@${_converse.muc_domain}`;
} else { } else {
jid = data.jid; jid = data.jid;
this.model.setDomain(jid);
} }
_converse.api.rooms.open(jid, _.extend(data, { _converse.api.rooms.open(jid, _.extend(data, {
@ -55504,7 +55518,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
}); });
function setMUCDomain(domain, controlboxview) { function setMUCDomain(domain, controlboxview) {
_converse.muc_domain = domain;
controlboxview.roomspanel.model.save('muc_domain', Strophe.getDomainFromJid(domain)); controlboxview.roomspanel.model.save('muc_domain', Strophe.getDomainFromJid(domain));
} }
@ -60557,7 +60570,7 @@ __webpack_require__.r(__webpack_exports__);
/* END: Removable components */ /* END: Removable components */
const WHITELISTED_PLUGINS = ['converse-autocomplete', 'converse-bookmarks', 'converse-caps', 'converse-chatboxviews', 'converse-chatview', 'converse-controlbox', 'converse-dragresize', 'converse-embedded', 'converse-fullscreen', 'converse-headline', 'converse-mam-views', 'converse-message-view', 'converse-minimize', 'converse-modal', 'converse-muc-views', 'converse-notification', 'converse-oauth', 'converse-omemo', 'converse-profile', 'converse-push', 'converse-register', 'converse-roomslist', 'converse-rosterview', 'converse-singleton']; const WHITELISTED_PLUGINS = ['converse-autocomplete', 'converse-bookmarks', 'converse-caps', 'converse-chatboxviews', 'converse-chatview', 'converse-controlbox', 'converse-dragresize', 'converse-embedded', 'converse-fullscreen', 'converse-headline', 'converse-mam-views', 'converse-message-view', 'converse-minimize', 'converse-modal', 'converse-muc-views', 'converse-notification', 'converse-omemo', 'converse-profile', 'converse-push', 'converse-register', 'converse-roomslist', 'converse-rosterview', 'converse-singleton'];
const initialize = _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_22__["default"].initialize; const initialize = _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_22__["default"].initialize;
_converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_22__["default"].initialize = function (settings, callback) { _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_22__["default"].initialize = function (settings, callback) {
@ -67921,10 +67934,17 @@ _converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-muc
_converse.RoomsPanelModel = Backbone.Model.extend({ _converse.RoomsPanelModel = Backbone.Model.extend({
defaults: function defaults() { defaults: function defaults() {
return { return {
'muc_domain': '', 'muc_domain': _converse.muc_domain,
'nick': _converse.getDefaultMUCNickname() 'nick': _converse.getDefaultMUCNickname()
}; };
},
setDomain(jid) {
if (!_converse.locked_muc_domain) {
this.save('muc_domain', Strophe.getDomainFromJid(jid));
}
} }
}); });
/** /**
* A direct MUC invitation to join a groupchat has been received * A direct MUC invitation to join a groupchat has been received

6
package-lock.json generated
View File

@ -8091,12 +8091,6 @@
"integrity": "sha1-elSbvZ/+FYWwzQoZHiAwVb7ldLQ=", "integrity": "sha1-elSbvZ/+FYWwzQoZHiAwVb7ldLQ=",
"dev": true "dev": true
}, },
"jquery": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz",
"integrity": "sha1-XE2d5lKvbNCncBVKYxu6ErAVx4c=",
"dev": true
},
"js-base64": { "js-base64": {
"version": "2.4.9", "version": "2.4.9",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.9.tgz", "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.9.tgz",

View File

@ -60,7 +60,6 @@
"install": "^0.9.5", "install": "^0.9.5",
"jasmine-core": "2.99.1", "jasmine-core": "2.99.1",
"jed": "1.1.1", "jed": "1.1.1",
"jquery": "3.2.1",
"jsdoc": "^3.5.5", "jsdoc": "^3.5.5",
"lerna": "^3.13.1", "lerna": "^3.13.1",
"lodash-template-loader": "^2.0.0", "lodash-template-loader": "^2.0.0",

View File

@ -3,11 +3,10 @@
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine", "jasmine",
"jquery",
"mock", "mock",
"test-utils" "test-utils"
], factory); ], factory);
} (this, function (jasmine, $, mock, test_utils) { } (this, function (jasmine, mock, test_utils) {
"use strict"; "use strict";
const $iq = converse.env.$iq, const $iq = converse.env.$iq,
$msg = converse.env.$msg, $msg = converse.env.$msg,
@ -604,16 +603,18 @@
'name': 'The Play', 'name': 'The Play',
'nick': '' 'nick': ''
}); });
await test_utils.waitUntil(() => $('#chatrooms .bookmarks.rooms-list .room-item:visible').length); const el = _converse.chatboxviews.el
expect($('#chatrooms .bookmarks.rooms-list').hasClass('collapsed')).toBeFalsy(); const selector = '#chatrooms .bookmarks.rooms-list .room-item';
expect($('#chatrooms .bookmarks.rooms-list .room-item:visible').length).toBe(1); await test_utils.waitUntil(() => sizzle(selector, el).filter(u.isVisible).length);
expect(u.hasClass('collapsed', sizzle('#chatrooms .bookmarks.rooms-list', el).pop())).toBeFalsy();
expect(sizzle(selector, el).filter(u.isVisible).length).toBe(1);
expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.OPENED); expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.OPENED);
$('#chatrooms .bookmarks-toggle')[0].click(); sizzle('#chatrooms .bookmarks-toggle', el).pop().click();
expect($('#chatrooms .bookmarks.rooms-list').hasClass('collapsed')).toBeTruthy(); expect(u.hasClass('collapsed', sizzle('#chatrooms .bookmarks.rooms-list', el).pop())).toBeTruthy();
expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.CLOSED); expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.CLOSED);
$('#chatrooms .bookmarks-toggle')[0].click(); sizzle('#chatrooms .bookmarks-toggle', el).pop().click();
expect($('#chatrooms .bookmarks.rooms-list').hasClass('collapsed')).toBeFalsy(); expect(u.hasClass('collapsed', sizzle('#chatrooms .bookmarks.rooms-list', el).pop())).toBeFalsy();
expect($('#chatrooms .bookmarks.rooms-list .room-item:visible').length).toBe(1); expect(sizzle(selector, el).filter(u.isVisible).length).toBe(1);
expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.OPENED); expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.OPENED);
done(); done();
})); }));

View File

@ -1,14 +1,13 @@
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine", "jasmine",
"jquery",
"mock", "mock",
"test-utils"], factory); "test-utils"], factory);
} (this, function (jasmine, $, mock, test_utils) { } (this, function (jasmine, mock, test_utils) {
"use strict"; "use strict";
var Strophe = converse.env.Strophe; const Strophe = converse.env.Strophe;
var $iq = converse.env.$iq; const $iq = converse.env.$iq;
var _ = converse.env._; const _ = converse.env._;
describe("Service Discovery", function () { describe("Service Discovery", function () {
@ -19,8 +18,8 @@
null, ['discoInitialized'], {}, null, ['discoInitialized'], {},
function (done, _converse) { function (done, _converse) {
var IQ_stanzas = _converse.connection.IQ_stanzas; const IQ_stanzas = _converse.connection.IQ_stanzas;
var IQ_ids = _converse.connection.IQ_ids; const IQ_ids = _converse.connection.IQ_ids;
test_utils.waitUntil(function () { test_utils.waitUntil(function () {
return _.filter(IQ_stanzas, function (iq) { return _.filter(IQ_stanzas, function (iq) {
return iq.nodeTree.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]'); return iq.nodeTree.querySelector('iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]');

View File

@ -1,11 +1,10 @@
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine", "jasmine",
"jquery",
"mock", "mock",
"test-utils" "test-utils"
], factory); ], factory);
} (this, function (jasmine, $, mock, test_utils) { } (this, function (jasmine, mock, test_utils) {
"use strict"; "use strict";
var $msg = converse.env.$msg, var $msg = converse.env.$msg,
_ = converse.env._, _ = converse.env._,

View File

@ -11,7 +11,7 @@
it("shows chats that have been minimized", it("shows chats that have been minimized",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { async function (done, _converse) {
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
_converse.api.trigger('rosterContactsFetched'); _converse.api.trigger('rosterContactsFetched');
@ -21,36 +21,32 @@
_converse.minimized_chats.initToggle(); _converse.minimized_chats.initToggle();
let contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; let contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
let chatview; await test_utils.openChatBoxFor(_converse, contact_jid)
test_utils.openChatBoxFor(_converse, contact_jid) let chatview = _converse.chatboxviews.get(contact_jid);
.then(() => { expect(chatview.model.get('minimized')).toBeFalsy();
chatview = _converse.chatboxviews.get(contact_jid); expect(u.isVisible(_converse.minimized_chats.el)).toBe(false);
expect(chatview.model.get('minimized')).toBeFalsy(); chatview.el.querySelector('.toggle-chatbox-button').click();
expect($(_converse.minimized_chats.el).is(':visible')).toBeFalsy(); expect(chatview.model.get('minimized')).toBeTruthy();
chatview.el.querySelector('.toggle-chatbox-button').click(); expect(u.isVisible(_converse.minimized_chats.el)).toBe(true);
expect(chatview.model.get('minimized')).toBeTruthy(); expect(_converse.minimized_chats.keys().length).toBe(1);
expect($(_converse.minimized_chats.el).is(':visible')).toBeTruthy(); expect(_converse.minimized_chats.keys()[0]).toBe(contact_jid);
expect(_converse.minimized_chats.keys().length).toBe(1);
expect(_converse.minimized_chats.keys()[0]).toBe(contact_jid);
contact_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost'; contact_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
return test_utils.openChatBoxFor(_converse, contact_jid); await test_utils.openChatBoxFor(_converse, contact_jid);
}).then(() => { chatview = _converse.chatboxviews.get(contact_jid);
chatview = _converse.chatboxviews.get(contact_jid); expect(chatview.model.get('minimized')).toBeFalsy();
expect(chatview.model.get('minimized')).toBeFalsy(); chatview.el.querySelector('.toggle-chatbox-button').click();
chatview.el.querySelector('.toggle-chatbox-button').click(); expect(chatview.model.get('minimized')).toBeTruthy();
expect(chatview.model.get('minimized')).toBeTruthy(); expect(u.isVisible(_converse.minimized_chats.el)).toBe(true);
expect($(_converse.minimized_chats.el).is(':visible')).toBeTruthy(); expect(_converse.minimized_chats.keys().length).toBe(2);
expect(_converse.minimized_chats.keys().length).toBe(2); expect(_.includes(_converse.minimized_chats.keys(), contact_jid)).toBeTruthy();
expect(_.includes(_converse.minimized_chats.keys(), contact_jid)).toBeTruthy(); done();
done();
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL))
})); }));
it("can be toggled to hide or show minimized chats", it("can be toggled to hide or show minimized chats",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { async function (done, _converse) {
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
_converse.api.trigger('rosterContactsFetched'); _converse.api.trigger('rosterContactsFetched');
@ -60,22 +56,19 @@
_converse.minimized_chats.initToggle(); _converse.minimized_chats.initToggle();
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
test_utils.openChatBoxFor(_converse, contact_jid) await test_utils.openChatBoxFor(_converse, contact_jid);
.then(() => { const chatview = _converse.chatboxviews.get(contact_jid);
const chatview = _converse.chatboxviews.get(contact_jid); expect(u.isVisible(_converse.minimized_chats.el)).toBeFalsy();
expect(u.isVisible(_converse.minimized_chats.el)).toBeFalsy(); chatview.model.set({'minimized': true});
chatview.model.set({'minimized': true}); expect(u.isVisible(_converse.minimized_chats.el)).toBeTruthy();
expect(u.isVisible(_converse.minimized_chats.el)).toBeTruthy(); expect(_converse.minimized_chats.keys().length).toBe(1);
expect(_converse.minimized_chats.keys().length).toBe(1); expect(_converse.minimized_chats.keys()[0]).toBe(contact_jid);
expect(_converse.minimized_chats.keys()[0]).toBe(contact_jid); expect(u.isVisible(_converse.minimized_chats.el.querySelector('.minimized-chats-flyout'))).toBeTruthy();
expect(u.isVisible(_converse.minimized_chats.el.querySelector('.minimized-chats-flyout'))).toBeTruthy(); expect(_converse.minimized_chats.toggleview.model.get('collapsed')).toBeFalsy();
expect(_converse.minimized_chats.toggleview.model.get('collapsed')).toBeFalsy(); _converse.minimized_chats.el.querySelector('#toggle-minimized-chats').click();
_converse.minimized_chats.el.querySelector('#toggle-minimized-chats').click(); await test_utils.waitUntil(() => u.isVisible(_converse.minimized_chats.el.querySelector('.minimized-chats-flyout')));
return test_utils.waitUntil(() => u.isVisible(_converse.minimized_chats.el.querySelector('.minimized-chats-flyout'))); expect(_converse.minimized_chats.toggleview.model.get('collapsed')).toBeTruthy();
}).then(() => { done();
expect(_converse.minimized_chats.toggleview.model.get('collapsed')).toBeTruthy();
done();
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL))
})); }));
it("shows the number messages received to minimized chats", it("shows the number messages received to minimized chats",

View File

@ -1231,7 +1231,7 @@
/* Server responds with the configuration form. /* Server responds with the configuration form.
* See: // https://xmpp.org/extensions/xep-0045.html#example-165 * See: // https://xmpp.org/extensions/xep-0045.html#example-165
*/ */
var config_stanza = $iq({from: 'coven@chat.shakespeare.lit', const config_stanza = $iq({from: 'coven@chat.shakespeare.lit',
'id': IQ_id, 'id': IQ_id,
'to': 'dummy@localhost/desktop', 'to': 'dummy@localhost/desktop',
'type': 'result'}) 'type': 'result'})
@ -1712,7 +1712,7 @@
it("allows the user to invite their roster contacts to enter the groupchat", it("allows the user to invite their roster contacts to enter the groupchat",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {}, null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'view_mode': 'fullscreen'},
async function (done, _converse) { async function (done, _converse) {
test_utils.createContacts(_converse, 'current'); // We need roster contacts, so that we have someone to invite test_utils.createContacts(_converse, 'current'); // We need roster contacts, so that we have someone to invite

View File

@ -1,6 +1,6 @@
(function (root, factory) { (function (root, factory) {
define(["jquery", "jasmine", "mock", "test-utils"], factory); define(["jasmine", "mock", "test-utils"], factory);
} (this, function ($, jasmine, mock, test_utils) { } (this, function (jasmine, mock, test_utils) {
"use strict"; "use strict";
const Strophe = converse.env.Strophe, const Strophe = converse.env.Strophe,
_ = converse.env._, _ = converse.env._,

View File

@ -1,10 +1,9 @@
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine", "jasmine",
"jquery",
"mock", "mock",
"test-utils"], factory); "test-utils"], factory);
} (this, function (jasmine, $, mock, test_utils) { } (this, function (jasmine, mock, test_utils) {
"use strict"; "use strict";
const Strophe = converse.env.Strophe; const Strophe = converse.env.Strophe;
const $iq = converse.env.$iq; const $iq = converse.env.$iq;
@ -212,16 +211,16 @@
expect(_converse.roster.updateContact).toHaveBeenCalled(); expect(_converse.roster.updateContact).toHaveBeenCalled();
// Check that the user is now properly shown as a pending // Check that the user is now properly shown as a pending
// contact in the roster. // contact in the roster.
await test_utils.waitUntil(function () { await test_utils.waitUntil(() => {
var $header = $('a:contains("Pending contacts")'); const header = sizzle('a:contains("Pending contacts")', _converse.rosterview.el).pop();
var $contacts = $header.parent().find('li:visible'); const contacts = _.filter(header.parentElement.querySelectorAll('li'), u.isVisible);
return $contacts.length; return contacts.length;
}, 600); }, 600);
var $header = $('a:contains("Pending contacts")'); let header = sizzle('a:contains("Pending contacts")', _converse.rosterview.el).pop();
var $contacts = $header.parent().find('li'); let contacts = header.parentElement.querySelectorAll('li');
expect($contacts.length).toBe(1); expect(contacts.length).toBe(1);
expect($contacts.is(':visible')).toBeTruthy(); expect(u.isVisible(contacts[0])).toBe(true);
spyOn(contact, "ackSubscribe").and.callThrough(); spyOn(contact, "ackSubscribe").and.callThrough();
/* Here we assume the "happy path" that the contact /* Here we assume the "happy path" that the contact
@ -285,10 +284,10 @@
const header = sizzle('a:contains("My contacts")', _converse.rosterview.el); const header = sizzle('a:contains("My contacts")', _converse.rosterview.el);
return sizzle('li', header[0].parentNode).filter(l => u.isVisible(l)).length; return sizzle('li', header[0].parentNode).filter(l => u.isVisible(l)).length;
}, 600); }, 600);
const header = sizzle('a:contains("My contacts")', _converse.rosterview.el); header = sizzle('a:contains("My contacts")', _converse.rosterview.el);
expect(header.length).toBe(1); expect(header.length).toBe(1);
expect(u.isVisible(header[0])).toBeTruthy(); expect(u.isVisible(header[0])).toBeTruthy();
const contacts = header[0].parentNode.querySelectorAll('li'); contacts = header[0].parentNode.querySelectorAll('li');
expect(contacts.length).toBe(1); expect(contacts.length).toBe(1);
// Check that it has the right classes and text // Check that it has the right classes and text
expect(u.hasClass('to', contacts[0])).toBeTruthy(); expect(u.hasClass('to', contacts[0])).toBeTruthy();
@ -360,8 +359,8 @@
expect(_converse.roster.updateContact).toHaveBeenCalled(); expect(_converse.roster.updateContact).toHaveBeenCalled();
// The class on the contact will now have switched. // The class on the contact will now have switched.
expect($contacts.hasClass('to')).toBeFalsy(); expect(u.hasClass('to', contacts[0])).toBe(false);
expect($contacts.hasClass('both')).toBeTruthy(); expect(u.hasClass('both', contacts[0])).toBe(true);
done(); done();
})); }));
@ -471,11 +470,11 @@
sent_IQ = iq; sent_IQ = iq;
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
const $header = $('a:contains("My contacts")'); const header = sizzle('a:contains("My contacts")', _converse.rosterview.el).pop();
await test_utils.waitUntil(() => $header.parent().find('li').length); await test_utils.waitUntil(() => header.parentElement.querySelectorAll('li').length);
// remove the first user // remove the first user
$header.parent().find('li .remove-xmpp-contact').get(0).click(); header.parentElement.querySelector('li .remove-xmpp-contact').click();
expect(window.confirm).toHaveBeenCalled(); expect(window.confirm).toHaveBeenCalled();
/* Section 8.6 Removing a Roster Item and Cancelling All /* Section 8.6 Removing a Roster Item and Cancelling All
@ -515,17 +514,18 @@
it("Receiving a subscription request", mock.initConverse( it("Receiving a subscription request", mock.initConverse(
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { async function (done, _converse) {
spyOn(_converse.api, "trigger"); spyOn(_converse.api, "trigger");
test_utils.openControlBox(_converse); test_utils.openControlBox(_converse);
test_utils.createContacts(_converse, 'current'); // Create some contacts so that we can test positioning // Create some contacts so that we can test positioning
test_utils.createContacts(_converse, 'current');
/* <presence /* <presence
* from='user@example.com' * from='user@example.com'
* to='contact@example.org' * to='contact@example.org'
* type='subscribe'/> * type='subscribe'/>
*/ */
var stanza = $pres({ const stanza = $pres({
'to': _converse.bare_jid, 'to': _converse.bare_jid,
'from': 'contact@example.org', 'from': 'contact@example.org',
'type': 'subscribe' 'type': 'subscribe'
@ -533,19 +533,17 @@
'xmlns': Strophe.NS.NICK, 'xmlns': Strophe.NS.NICK,
}).t('Clint Contact'); }).t('Clint Contact');
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
return test_utils.waitUntil(function () { await test_utils.waitUntil(() => {
var $header = $('a:contains("Contact requests")'); const header = sizzle('a:contains("Contact requests")', _converse.rosterview.el).pop();
var $contacts = $header.parent().find('li:visible'); const contacts = _.filter(header.parentElement.querySelectorAll('li'), u.isVisible);
return $contacts.length; return contacts.length;
}, 600).then(function () { }, 300);
expect(_converse.api.trigger).toHaveBeenCalledWith('contactRequest', jasmine.any(Object)); expect(_converse.api.trigger).toHaveBeenCalledWith('contactRequest', jasmine.any(Object));
var $header = $('a:contains("Contact requests")'); const header = sizzle('a:contains("Contact requests")', _converse.rosterview.el).pop();
expect($header.length).toBe(1); expect(u.isVisible(header)).toBe(true);
expect($header.is(":visible")).toBeTruthy(); const contacts = header.parentElement.querySelectorAll('li');
var $contacts = $header.parent().find('li'); expect(contacts.length).toBe(1);
expect($contacts.length).toBe(1); done();
done();
});
})); }));
}); });
}); });

View File

@ -319,7 +319,7 @@
max-age="0">iVBORw0KGgoAAAANSUhEUgAAALQAAAA8BAMAAAA9AI20AAAAMFBMVEX///8AAADf39+fn59fX19/f3+/v78fHx8/Pz9PT08bGxsvLy9jY2NTU1MXFxcnJyc84bkWAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAERUlEQVRYhe1WTXMaRxDdDxY4JWpYvDinpVyxdATLin0MiRLlCHEi+7hYUcVHTSI7urhK6yr5//gn5N/4Z7inX89+CQkTcFUO6gOwS8/r7tdvesbzvoT5ROR5JJ9bB97xAK22XWAY1WznlnUr7QaAzSOsWufXQ6wH/FmO60b4D936LJr8TWRwW4SNgOsodZr8m4vZUoRt2xZ3xHXgna1FCE5+f5aWwPU//bXgg8eHjyqPp4aXJeOlwLUIt0O39zOvPWW3WfHmCCkli816FxlK0rnFGKZ484dN+eIXsw1R+G+JfjwgOpMnm+r5SxA63gS2Q8MchO1RLN8jSn4W4F5OPed2evhTthKLG3bsfjLL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wBT/m+VvZNIhz7ayabQLSeRQDmYkjt0KlmHDa555v9DzFxx+CCvCG4K3dbx6mTYtfPs1Dgdh0i3W+cl4lnnhblMKKBBA23X1Ezc3E5ZoPS5KHjPiU1rKTviYe1fTsa6e3UwXGWI4ykB8uiGqkmA6Cbf3K4JTH3LOBlbX+yPWll57LKVeH8CTEvyVPV2TXL8kPnPqtA51CaFYxOH2rJoZunSnvsSj48WiaDccl6KEgiMSarITsa+rWWBnqFloYlT1qWW2GKw9nPSbEvoVHFst967XgNQjxdA66Q6VFEUh488xfaSo7cHB52XYzA4eRlVteeT8ostWfuPea0oF6MwzlwgZE9gQI+uUV0gzK+WlpUrNI8juhhX/OyNwZnRrsDfxOqS1aDR+gC6NUPvJpvQeVZ9eiNr9aDUuddY3bLnA4tH4r/49UboznH1ia8PV/uP3WUB3dxtzj1uxfDZgbEbZx17Itwrf0Jyc8N4en+5dhivtKeYjGJ8yXgUzKvSU/uWJZmsuAYtseDku+K3zMHi4lC1h0suPmtZaEp2tm3hEV2lXwb6zu7szv6f9glF5rPGT5xR7AAAAABJRU5ErkJggg==</data>
<instructions>You need a client that supports x:data and CAPTCHA to register</instructions> <instructions>You need a client that supports x:data and CAPTCHA to register</instructions>
</query> </query>
</iq`); </iq>`);
_converse.connection._dataRecv(test_utils.createRequest(stanza)); _converse.connection._dataRecv(test_utils.createRequest(stanza));
expect(registerview.form_type).toBe('xform'); expect(registerview.form_type).toBe('xform');
expect(registerview.el.querySelectorAll('#converse-register input[required="required"]').length).toBe(3); expect(registerview.el.querySelectorAll('#converse-register input[required="required"]').length).toBe(3);

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,5 @@
(function (root, factory) { (function (root, factory) {
define([ define([
"jquery",
"jasmine", "jasmine",
"converse-core", "converse-core",
"mock", "mock",
@ -9,7 +8,7 @@
"transcripts" "transcripts"
], factory ], factory
); );
} (this, function ($, jasmine, converse, mock, test_utils, utils, transcripts) { } (this, function (jasmine, converse, mock, test_utils, utils, transcripts) {
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
var _ = converse.env._; var _ = converse.env._;
var IGNORED_TAGS = [ var IGNORED_TAGS = [

View File

@ -46383,10 +46383,17 @@ _converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-muc
_converse.RoomsPanelModel = Backbone.Model.extend({ _converse.RoomsPanelModel = Backbone.Model.extend({
defaults: function defaults() { defaults: function defaults() {
return { return {
'muc_domain': '', 'muc_domain': _converse.muc_domain,
'nick': _converse.getDefaultMUCNickname() 'nick': _converse.getDefaultMUCNickname()
}; };
},
setDomain(jid) {
if (!_converse.locked_muc_domain) {
this.save('muc_domain', Strophe.getDomainFromJid(jid));
}
} }
}); });
/** /**
* A direct MUC invitation to join a groupchat has been received * A direct MUC invitation to join a groupchat has been received