Forráskód Böngészése

Add some initial tests for the room invite feature. updates #215

JC Brand 10 éve
szülő
commit
18cbe06d58
3 módosított fájl, 37 hozzáadás és 6 törlés
  1. 4 0
      css/converse.css
  2. 5 0
      less/converse.less
  3. 28 6
      spec/chatroom.js

+ 4 - 0
css/converse.css

@@ -610,6 +610,10 @@ span.spinner.hor_centered {
   width: 99px;
   border-bottom: 1px solid #999;
 }
+#conversejs .participants label {
+  margin-top: 5px;
+  display: block;
+}
 #conversejs .participants ul.participant-list li {
   overflow: hidden;
   text-overflow: ellipsis;

+ 5 - 0
less/converse.less

@@ -661,6 +661,11 @@ span.spinner.hor_centered {
     border-bottom: 1px solid #999;
 }
 
+#conversejs .participants label {
+    margin-top: 5px;
+    display: block;
+}
+
 #conversejs .participants ul.participant-list li {
     overflow: hidden;
     text-overflow: ellipsis;

+ 28 - 6
spec/chatroom.js

@@ -12,16 +12,13 @@
             beforeEach(function () {
                 runs(function () {
                     test_utils.closeAllChatBoxes();
-                });
-                waits(250);
-                runs(function () {
                     test_utils.openControlBox();
                 });
-                waits(250);
+                waits(150);
                 runs(function () {
                     test_utils.openRoomsPanel();
                 });
-                waits(501);
+                waits(200);
                 runs(function () {
                     // Open a new chatroom
                     var roomspanel = converse.chatboxviews.get('controlbox').roomspanel;
@@ -37,7 +34,6 @@
                 runs(function () {
                     test_utils.closeControlBox();
                 });
-                waits(250);
                 runs(function () {});
             });
 
@@ -70,6 +66,32 @@
             }, converse));
 
             it("allows the user to invite their roster contacts to enter the chat room", $.proxy(function () {
+                spyOn(converse, 'emit');
+                spyOn(window, 'prompt').andCallFake(function () {
+                    return null;
+                });
+                var roster = {}, $input;
+                var view = this.chatboxviews.get('lounge@muc.localhost');
+                view.$el.find('.chat-area').remove();
+                view.renderChatArea(); // Will init the widget
+                test_utils.createContacts('current'); // We need roster contacts, so that we have someone to invite
+                $input = view.$el.find('input.invited-contact.tt-input');
+                $hint = view.$el.find('input.invited-contact.tt-hint');
+                runs (function () {
+                    expect($input.length).toBe(1);
+                    expect($input.attr('placeholder')).toBe('Type to invite');
+                    $input.val("Felix");
+                    $input.trigger('input');
+                });
+                waits(350); // Needed, due to debounce
+                runs (function () {
+                    expect($input.val()).toBe('Felix');
+                    expect($hint.val()).toBe('Felix Amsel');
+                    var $sugg = view.$el.find('[data-jid="felix.amsel@localhost"]');
+                    expect($sugg.length).toBe(1);
+                    $sugg.trigger('click');
+                    expect(window.prompt).toHaveBeenCalled();
+                });
             }, converse));
 
             it("shows received groupchat messages", $.proxy(function () {