2014-10-24 18:58:42 +02:00
|
|
|
(function (root, factory) {
|
2018-06-03 16:40:20 +02:00
|
|
|
define(["jasmine", "mock", "test-utils"], factory);
|
|
|
|
} (this, function (jasmine, mock, test_utils) {
|
2016-12-20 10:30:20 +01:00
|
|
|
var _ = converse.env._;
|
|
|
|
var $iq = converse.env.$iq;
|
2019-06-27 11:27:05 +02:00
|
|
|
var $pres = converse.env.$pres;
|
2018-06-03 16:40:20 +02:00
|
|
|
var u = converse.env.utils;
|
2015-02-01 16:15:34 +01:00
|
|
|
|
2014-10-24 18:58:42 +02:00
|
|
|
describe("Profiling", function() {
|
2019-06-27 11:27:05 +02:00
|
|
|
|
|
|
|
it("shows users currently present in the groupchat",
|
|
|
|
mock.initConverse(
|
|
|
|
null, ['rosterGroupsFetched'], {'muc_show_join_leave': false},
|
|
|
|
async function (done, _converse) {
|
|
|
|
|
|
|
|
test_utils.openControlBox();
|
2019-07-03 14:18:46 +02:00
|
|
|
await test_utils.openAndEnterChatRoom(_converse, 'lounge@montague.lit', 'romeo');
|
2019-06-27 11:27:05 +02:00
|
|
|
const view = _converse.chatboxviews.get('lounge@montague.lit'),
|
|
|
|
occupants = view.el.querySelector('.occupant-list');
|
|
|
|
_.rangeRight(3000, 0).forEach(i => {
|
|
|
|
const name = `User ${i.toString().padStart(5, '0')}`;
|
|
|
|
const presence = $pres({
|
|
|
|
'to': 'romeo@montague.lit/orchard',
|
|
|
|
'from': 'lounge@montague.lit/'+name
|
|
|
|
}).c('x').attrs({xmlns:'http://jabber.org/protocol/muc#user'})
|
|
|
|
.c('item').attrs({
|
|
|
|
affiliation: 'none',
|
|
|
|
jid: name.replace(/ /g,'.').toLowerCase() + '@montague.lit',
|
|
|
|
});
|
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
|
|
|
|
|
|
|
// expect(occupants.querySelectorAll('li').length).toBe(1+i);
|
|
|
|
// const model = view.model.occupants.where({'nick': name})[0];
|
|
|
|
// const index = view.model.occupants.indexOf(model);
|
|
|
|
// expect(occupants.querySelectorAll('li .occupant-nick')[index].textContent.trim()).toBe(name);
|
|
|
|
});
|
|
|
|
done();
|
|
|
|
}));
|
|
|
|
|
2017-12-20 13:17:58 +01:00
|
|
|
xit("adds hundreds of contacts to the roster",
|
2019-02-12 14:21:45 +01:00
|
|
|
mock.initConverse(
|
2017-12-20 13:17:58 +01:00
|
|
|
null, ['rosterGroupsFetched'], {},
|
|
|
|
function (done, _converse) {
|
2014-10-24 18:58:42 +02:00
|
|
|
|
2016-12-20 10:30:20 +01:00
|
|
|
_converse.roster_groups = false;
|
2017-12-20 13:17:58 +01:00
|
|
|
test_utils.openControlBox();
|
|
|
|
|
|
|
|
expect(_converse.roster.pluck('jid').length).toBe(0);
|
2014-10-26 17:12:59 +01:00
|
|
|
var stanza = $iq({
|
2017-12-20 13:17:58 +01:00
|
|
|
to: _converse.connection.jid,
|
2014-10-26 17:12:59 +01:00
|
|
|
type: 'result',
|
|
|
|
id: 'roster_1'
|
|
|
|
}).c('query', {
|
|
|
|
xmlns: 'jabber:iq:roster'
|
|
|
|
});
|
|
|
|
_.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) {
|
|
|
|
var i;
|
2015-05-01 14:34:20 +02:00
|
|
|
for (i=0; i<50; i++) {
|
2014-10-26 17:12:59 +01:00
|
|
|
stanza = stanza.c('item', {
|
|
|
|
jid: Math.random().toString().replace('0.', '')+'@example.net',
|
|
|
|
subscription:'both'
|
|
|
|
}).c('group').t(group).up().up();
|
|
|
|
}
|
|
|
|
});
|
2017-12-20 13:17:58 +01:00
|
|
|
_converse.roster.onReceivedFromServer(stanza.tree());
|
|
|
|
|
|
|
|
return test_utils.waitUntil(function () {
|
|
|
|
var $group = _converse.rosterview.$el.find('.roster-group')
|
|
|
|
return $group.length && u.isVisible($group[0]);
|
|
|
|
}).then(function () {
|
|
|
|
var count = 0;
|
|
|
|
_converse.roster.each(function (contact) {
|
|
|
|
if (count < 10) {
|
|
|
|
contact.set('chat_status', 'online');
|
|
|
|
count += 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return test_utils.waitUntil(function () {
|
|
|
|
return _converse.rosterview.$el.find('li.online').length
|
|
|
|
})
|
|
|
|
}).then(done);
|
2016-11-03 11:01:09 +01:00
|
|
|
}));
|
2014-10-24 22:24:05 +02:00
|
|
|
|
2017-12-20 13:17:58 +01:00
|
|
|
xit("adds hundreds of contacts to the roster, with roster groups",
|
2019-02-12 14:21:45 +01:00
|
|
|
mock.initConverse(
|
2017-12-20 13:17:58 +01:00
|
|
|
null, ['rosterGroupsFetched'], {},
|
|
|
|
function (done, _converse) {
|
2019-06-27 11:27:05 +02:00
|
|
|
|
2016-12-20 10:30:20 +01:00
|
|
|
// _converse.show_only_online_users = true;
|
|
|
|
_converse.roster_groups = true;
|
2017-12-20 13:17:58 +01:00
|
|
|
test_utils.openControlBox();
|
|
|
|
|
|
|
|
expect(_converse.roster.pluck('jid').length).toBe(0);
|
2014-10-24 22:24:05 +02:00
|
|
|
var stanza = $iq({
|
2017-12-20 13:17:58 +01:00
|
|
|
to: _converse.connection.jid,
|
2014-10-24 18:58:42 +02:00
|
|
|
type: 'result',
|
|
|
|
id: 'roster_1'
|
|
|
|
}).c('query', {
|
2014-10-24 22:24:05 +02:00
|
|
|
xmlns: 'jabber:iq:roster'
|
|
|
|
});
|
|
|
|
_.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) {
|
2014-10-25 12:33:08 +02:00
|
|
|
var i;
|
2014-10-26 23:11:58 +01:00
|
|
|
for (i=0; i<100; i++) {
|
2014-10-24 22:24:05 +02:00
|
|
|
stanza = stanza.c('item', {
|
2014-10-25 12:33:08 +02:00
|
|
|
jid: Math.random().toString().replace('0.', '')+'@example.net',
|
2014-10-24 22:24:05 +02:00
|
|
|
subscription:'both'
|
2014-10-25 12:33:08 +02:00
|
|
|
}).c('group').t(group).up().up();
|
2014-10-24 22:24:05 +02:00
|
|
|
}
|
|
|
|
});
|
2017-12-20 13:17:58 +01:00
|
|
|
_converse.roster.onReceivedFromServer(stanza.tree());
|
|
|
|
|
|
|
|
return test_utils.waitUntil(function () {
|
|
|
|
var $group = _converse.rosterview.$el.find('.roster-group')
|
|
|
|
return $group.length && u.isVisible($group[0]);
|
|
|
|
}).then(function () {
|
|
|
|
_.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) {
|
|
|
|
var count = 0;
|
|
|
|
_converse.roster.each(function (contact) {
|
|
|
|
if (_.includes(contact.get('groups'), group)) {
|
|
|
|
if (count < 10) {
|
|
|
|
contact.set('chat_status', 'online');
|
|
|
|
count += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return test_utils.waitUntil(function () {
|
|
|
|
return _converse.rosterview.$el.find('li.online').length
|
|
|
|
})
|
|
|
|
}).then(done);
|
2016-11-03 11:01:09 +01:00
|
|
|
}));
|
2014-10-24 18:58:42 +02:00
|
|
|
});
|
|
|
|
}));
|