2
0

profiling.js 4.1 KB

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