profiling.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. (function (root, factory) {
  2. define(["jasmine", "mock", "converse-core", "test-utils", "utils"], factory);
  3. } (this, function (jasmine, mock, converse, test_utils, u) {
  4. var _ = converse.env._;
  5. var $iq = converse.env.$iq;
  6. describe("Profiling", function() {
  7. xit("adds hundreds of contacts to the roster",
  8. mock.initConverseWithPromises(
  9. null, ['rosterGroupsFetched'], {},
  10. function (done, _converse) {
  11. _converse.roster_groups = false;
  12. test_utils.openControlBox();
  13. expect(_converse.roster.pluck('jid').length).toBe(0);
  14. var stanza = $iq({
  15. to: _converse.connection.jid,
  16. type: 'result',
  17. id: 'roster_1'
  18. }).c('query', {
  19. xmlns: 'jabber:iq:roster'
  20. });
  21. _.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) {
  22. var i;
  23. for (i=0; i<50; i++) {
  24. stanza = stanza.c('item', {
  25. jid: Math.random().toString().replace('0.', '')+'@example.net',
  26. subscription:'both'
  27. }).c('group').t(group).up().up();
  28. }
  29. });
  30. _converse.roster.onReceivedFromServer(stanza.tree());
  31. return test_utils.waitUntil(function () {
  32. var $group = _converse.rosterview.$el.find('.roster-group')
  33. return $group.length && u.isVisible($group[0]);
  34. }).then(function () {
  35. var count = 0;
  36. _converse.roster.each(function (contact) {
  37. if (count < 10) {
  38. contact.set('chat_status', 'online');
  39. count += 1;
  40. }
  41. });
  42. return test_utils.waitUntil(function () {
  43. return _converse.rosterview.$el.find('li.online').length
  44. })
  45. }).then(done);
  46. }));
  47. xit("adds hundreds of contacts to the roster, with roster groups",
  48. mock.initConverseWithPromises(
  49. null, ['rosterGroupsFetched'], {},
  50. function (done, _converse) {
  51. // _converse.show_only_online_users = true;
  52. _converse.roster_groups = true;
  53. test_utils.openControlBox();
  54. expect(_converse.roster.pluck('jid').length).toBe(0);
  55. var stanza = $iq({
  56. to: _converse.connection.jid,
  57. type: 'result',
  58. id: 'roster_1'
  59. }).c('query', {
  60. xmlns: 'jabber:iq:roster'
  61. });
  62. _.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) {
  63. var i;
  64. for (i=0; i<100; i++) {
  65. stanza = stanza.c('item', {
  66. jid: Math.random().toString().replace('0.', '')+'@example.net',
  67. subscription:'both'
  68. }).c('group').t(group).up().up();
  69. }
  70. });
  71. _converse.roster.onReceivedFromServer(stanza.tree());
  72. return test_utils.waitUntil(function () {
  73. var $group = _converse.rosterview.$el.find('.roster-group')
  74. return $group.length && u.isVisible($group[0]);
  75. }).then(function () {
  76. _.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) {
  77. var count = 0;
  78. _converse.roster.each(function (contact) {
  79. if (_.includes(contact.get('groups'), group)) {
  80. if (count < 10) {
  81. contact.set('chat_status', 'online');
  82. count += 1;
  83. }
  84. }
  85. });
  86. });
  87. return test_utils.waitUntil(function () {
  88. return _converse.rosterview.$el.find('li.online').length
  89. })
  90. }).then(done);
  91. }));
  92. });
  93. }));