Jelajahi Sumber

Fix failing bookmarks tests

JC Brand 7 tahun lalu
induk
melakukan
7b8a244163
3 mengubah file dengan 22 tambahan dan 21 penghapusan
  1. 20 19
      spec/bookmarks.js
  2. 1 1
      src/converse-bookmarks.js
  3. 1 1
      src/templates/bookmarks_list.html

+ 20 - 19
spec/bookmarks.js

@@ -45,7 +45,7 @@
                 test_utils.waitUntil(function () {
                 test_utils.waitUntil(function () {
                     return !_.isNull(view.el.querySelector('.toggle-bookmark'));
                     return !_.isNull(view.el.querySelector('.toggle-bookmark'));
                 }, 300).then(function () {
                 }, 300).then(function () {
-                    var $bookmark = $(view.el).find('.icon-pushpin');
+                    var $bookmark = $(view.el).find('.toggle-bookmark');
                     $bookmark[0].click();
                     $bookmark[0].click();
                     expect(view.renderBookmarkForm).toHaveBeenCalled();
                     expect(view.renderBookmarkForm).toHaveBeenCalled();
 
 
@@ -92,7 +92,7 @@
                     $form.find('input[name="name"]').val('Play's the Thing');
                     $form.find('input[name="name"]').val('Play's the Thing');
                     $form.find('input[name="autojoin"]').prop('checked', true);
                     $form.find('input[name="autojoin"]').prop('checked', true);
                     $form.find('input[name="nick"]').val('JC');
                     $form.find('input[name="nick"]').val('JC');
-                    view.el.querySelector('.button-primary').click();
+                    view.el.querySelector('.btn-primary').click();
 
 
                     expect(view.model.get('bookmarked')).toBeTruthy();
                     expect(view.model.get('bookmarked')).toBeTruthy();
                     expect($bookmark.hasClass('on-button'), true);
                     expect($bookmark.hasClass('on-button'), true);
@@ -188,7 +188,7 @@
                     test_utils.waitUntil(function () {
                     test_utils.waitUntil(function () {
                         return !_.isNull(view.el.querySelector('.toggle-bookmark'));
                         return !_.isNull(view.el.querySelector('.toggle-bookmark'));
                     }, 300).then(function () {
                     }, 300).then(function () {
-                        var bookmark_icon = view.el.querySelector('.icon-pushpin');
+                        var bookmark_icon = view.el.querySelector('.toggle-bookmark');
                         expect(_.includes(bookmark_icon.classList, 'button-on')).toBeFalsy();
                         expect(_.includes(bookmark_icon.classList, 'button-on')).toBeFalsy();
                         view.model.set('bookmarked', true);
                         view.model.set('bookmarked', true);
                         expect(_.includes(bookmark_icon.classList, 'button-on')).toBeTruthy();
                         expect(_.includes(bookmark_icon.classList, 'button-on')).toBeTruthy();
@@ -229,7 +229,7 @@
                         });
                         });
                         expect(_converse.bookmarks.length).toBe(1);
                         expect(_converse.bookmarks.length).toBe(1);
                         expect(view.model.get('bookmarked')).toBeTruthy();
                         expect(view.model.get('bookmarked')).toBeTruthy();
-                        var $bookmark_icon = $(view.el.querySelector('.icon-pushpin'));
+                        var $bookmark_icon = $(view.el.querySelector('.toggle-bookmark'));
                         expect($bookmark_icon.hasClass('button-on')).toBeTruthy();
                         expect($bookmark_icon.hasClass('button-on')).toBeTruthy();
 
 
                         spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
                         spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
@@ -463,6 +463,7 @@
                     [{'category': 'pubsub', 'type': 'pep'}],
                     [{'category': 'pubsub', 'type': 'pep'}],
                     ['http://jabber.org/protocol/pubsub#publish-options']
                     ['http://jabber.org/protocol/pubsub#publish-options']
                 ).then(function () {
                 ).then(function () {
+                    test_utils.openControlBox();
 
 
                     var IQ_id;
                     var IQ_id;
                     expect(_.filter(_converse.connection.send.calls.all(), function (call) {
                     expect(_.filter(_converse.connection.send.calls.all(), function (call) {
@@ -513,19 +514,18 @@
                     _converse.connection._dataRecv(test_utils.createRequest(stanza));
                     _converse.connection._dataRecv(test_utils.createRequest(stanza));
 
 
                     test_utils.waitUntil(function () {
                     test_utils.waitUntil(function () {
-                        return $('#chatrooms dl.bookmarks dd').length;
+                        return $('#chatrooms div.bookmarks.rooms-list .room-item').length;
                     }, 300).then(function () {
                     }, 300).then(function () {
-                        expect($('#chatrooms dl.bookmarks dd').length).toBe(4);
-                        expect($('#chatrooms dl.bookmarks dd a').text().trim()).toBe(
-                            "1st Bookmark  Another room  Bookmark with a very very long name that will be shortened  The Play's the Thing")
+                        expect($('#chatrooms div.bookmarks.rooms-list .room-item').length).toBe(4);
+                        expect($('#chatrooms div.bookmarks.rooms-list .room-item a').text().trim()).toBe(
+                            "1st Bookmark  Another room  Bookmark with a very very long name that will be shortened  The Play's the Thing")
 
 
                         spyOn(window, 'confirm').and.returnValue(true);
                         spyOn(window, 'confirm').and.returnValue(true);
-                        $('#chatrooms dl.bookmarks dd:nth-child(2) a:nth-child(2)')[0].click();
+                        $('#chatrooms .bookmarks.rooms-list .room-item:nth-child(2) a:nth-child(2)')[0].click();
                         expect(window.confirm).toHaveBeenCalled();
                         expect(window.confirm).toHaveBeenCalled();
-
                         return test_utils.waitUntil(function () {
                         return test_utils.waitUntil(function () {
-                            return $('#chatrooms dl.bookmarks dd a').text().trim() ===
-                                "1st Bookmark  Bookmark with a very very long name that will be shortened  The Play's the Thing";
+                            return $('#chatrooms .bookmarks.rooms-list .room-item a').text().trim() ===
+                                "1st Bookmark  Bookmark with a very very long name that will be shortened  The Play's the Thing";
                         }, 300)
                         }, 300)
                     }).then(done);
                     }).then(done);
                 });
                 });
@@ -534,6 +534,8 @@
             it("remembers the toggle state of the bookmarks list", mock.initConverseWithPromises(
             it("remembers the toggle state of the bookmarks list", mock.initConverseWithPromises(
                 ['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
                 ['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
 
 
+                test_utils.openControlBox();
+
                 test_utils.waitUntilDiscoConfirmed(
                 test_utils.waitUntilDiscoConfirmed(
                     _converse, _converse.bare_jid,
                     _converse, _converse.bare_jid,
                     [{'category': 'pubsub', 'type': 'pep'}],
                     [{'category': 'pubsub', 'type': 'pep'}],
@@ -573,19 +575,18 @@
                         'name':  'The Play',
                         'name':  'The Play',
                         'nick': ''
                         'nick': ''
                     });
                     });
-
                     test_utils.waitUntil(function () {
                     test_utils.waitUntil(function () {
-                        return $('#chatrooms dl.bookmarks dd:visible').length;
+                        return $('#chatrooms .bookmarks.rooms-list .room-item:visible').length;
                     }, 300).then(function () {
                     }, 300).then(function () {
-                        expect($('#chatrooms dl.bookmarks').hasClass('collapsed')).toBeFalsy();
-                        expect($('#chatrooms dl.bookmarks dd:visible').length).toBe(1);
+                        expect($('#chatrooms .bookmarks.rooms-list').hasClass('collapsed')).toBeFalsy();
+                        expect($('#chatrooms .bookmarks.rooms-list .room-item:visible').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();
                         $('#chatrooms .bookmarks-toggle')[0].click();
-                        expect($('#chatrooms dl.bookmarks').hasClass('collapsed')).toBeTruthy();
+                        expect($('#chatrooms .bookmarks.rooms-list').hasClass('collapsed')).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();
                         $('#chatrooms .bookmarks-toggle')[0].click();
-                        expect($('#chatrooms dl.bookmarks').hasClass('collapsed')).toBeFalsy();
-                        expect($('#chatrooms dl.bookmarks dd:visible').length).toBe(1);
+                        expect($('#chatrooms .bookmarks.rooms-list').hasClass('collapsed')).toBeFalsy();
+                        expect($('#chatrooms .bookmarks.rooms-list .room-item:visible').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();
                     });
                     });

+ 1 - 1
src/converse-bookmarks.js

@@ -427,7 +427,7 @@
                         'info_remove_bookmark': __('Unbookmark this room'),
                         'info_remove_bookmark': __('Unbookmark this room'),
                         'info_title': __('Show more information on this room'),
                         'info_title': __('Show more information on this room'),
                         'jid': this.model.get('jid'),
                         'jid': this.model.get('jid'),
-                        'name': this.model.get('name'),
+                        'name': Strophe.xmlunescape(this.model.get('name')),
                         'open_title': __('Click to open this room')
                         'open_title': __('Click to open this room')
                     });
                     });
                 }
                 }

+ 1 - 1
src/templates/bookmarks_list.html

@@ -1,2 +1,2 @@
 <a href="#" class="rooms-toggle bookmarks-toggle icon-{{{o.toggle_state}}}" title="{{{o.desc_bookmarks}}}">{{{o.label_bookmarks}}}</a>
 <a href="#" class="rooms-toggle bookmarks-toggle icon-{{{o.toggle_state}}}" title="{{{o.desc_bookmarks}}}">{{{o.label_bookmarks}}}</a>
-<dl class="bookmarks rooms-list {[ if (o.toggle_state !== o._converse.OPENED) { ]} hidden {[ } ]}"></dl>
+<div class="bookmarks rooms-list {[ if (o.toggle_state !== o._converse.OPENED) { ]} hidden {[ } ]}"></div>