|
@@ -23,212 +23,90 @@
|
|
|
it("can be bookmarked", mock.initConverseWithPromises(
|
|
|
null, ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
|
|
|
- var sent_stanza, IQ_id;
|
|
|
- var sendIQ = _converse.connection.sendIQ;
|
|
|
- spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
- sent_stanza = iq;
|
|
|
- IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
- });
|
|
|
- spyOn(_converse.connection, 'getUniqueId').and.callThrough();
|
|
|
-
|
|
|
- test_utils.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC');
|
|
|
-
|
|
|
- var jid = 'theplay@conference.shakespeare.lit';
|
|
|
- var view = _converse.chatboxviews.get(jid);
|
|
|
- spyOn(view, 'renderBookmarkForm').and.callThrough();
|
|
|
- spyOn(view, 'closeForm').and.callThrough();
|
|
|
-
|
|
|
- test_utils.waitUntil(function () {
|
|
|
- return !_.isNull(view.el.querySelector('.toggle-bookmark'));
|
|
|
- }, 300).then(function () {
|
|
|
- var $bookmark = $(view.el).find('.icon-pushpin');
|
|
|
- $bookmark[0].click();
|
|
|
- expect(view.renderBookmarkForm).toHaveBeenCalled();
|
|
|
-
|
|
|
- view.el.querySelector('.button-cancel').click();
|
|
|
- expect(view.closeForm).toHaveBeenCalled();
|
|
|
- expect($bookmark.hasClass('on-button'), false);
|
|
|
-
|
|
|
- $bookmark[0].click();
|
|
|
- expect(view.renderBookmarkForm).toHaveBeenCalled();
|
|
|
-
|
|
|
- /* Client uploads data:
|
|
|
- * --------------------
|
|
|
- * <iq from='juliet@capulet.lit/balcony' type='set' id='pip1'>
|
|
|
- * <pubsub xmlns='http://jabber.org/protocol/pubsub'>
|
|
|
- * <publish node='storage:bookmarks'>
|
|
|
- * <item id='current'>
|
|
|
- * <storage xmlns='storage:bookmarks'>
|
|
|
- * <conference name='The Play's the Thing'
|
|
|
- * autojoin='true'
|
|
|
- * jid='theplay@conference.shakespeare.lit'>
|
|
|
- * <nick>JC</nick>
|
|
|
- * </conference>
|
|
|
- * </storage>
|
|
|
- * </item>
|
|
|
- * </publish>
|
|
|
- * <publish-options>
|
|
|
- * <x xmlns='jabber:x:data' type='submit'>
|
|
|
- * <field var='FORM_TYPE' type='hidden'>
|
|
|
- * <value>http://jabber.org/protocol/pubsub#publish-options</value>
|
|
|
- * </field>
|
|
|
- * <field var='pubsub#persist_items'>
|
|
|
- * <value>true</value>
|
|
|
- * </field>
|
|
|
- * <field var='pubsub#access_model'>
|
|
|
- * <value>whitelist</value>
|
|
|
- * </field>
|
|
|
- * </x>
|
|
|
- * </publish-options>
|
|
|
- * </pubsub>
|
|
|
- * </iq>
|
|
|
- */
|
|
|
- expect(view.model.get('bookmarked')).toBeFalsy();
|
|
|
- var $form = $(view.el).find('.chatroom-form');
|
|
|
- $form.find('input[name="name"]').val('Play's the Thing');
|
|
|
- $form.find('input[name="autojoin"]').prop('checked', true);
|
|
|
- $form.find('input[name="nick"]').val('JC');
|
|
|
- view.el.querySelector('.button-primary').click();
|
|
|
-
|
|
|
- expect(view.model.get('bookmarked')).toBeTruthy();
|
|
|
- expect($bookmark.hasClass('on-button'), true);
|
|
|
-
|
|
|
- expect(sent_stanza.toLocaleString()).toBe(
|
|
|
- "<iq type='set' from='dummy@localhost/resource' xmlns='jabber:client' id='"+IQ_id+"'>"+
|
|
|
- "<pubsub xmlns='http://jabber.org/protocol/pubsub'>"+
|
|
|
- "<publish node='storage:bookmarks'>"+
|
|
|
- "<item id='current'>"+
|
|
|
- "<storage xmlns='storage:bookmarks'>"+
|
|
|
- "<conference name='Play&apos;s the Thing' autojoin='true' jid='theplay@conference.shakespeare.lit'>"+
|
|
|
- "<nick>JC</nick>"+
|
|
|
- "</conference>"+
|
|
|
- "</storage>"+
|
|
|
- "</item>"+
|
|
|
- "</publish>"+
|
|
|
- "<publish-options>"+
|
|
|
- "<x xmlns='jabber:x:data' type='submit'>"+
|
|
|
- "<field var='FORM_TYPE' type='hidden'>"+
|
|
|
- "<value>http://jabber.org/protocol/pubsub#publish-options</value>"+
|
|
|
- "</field>"+
|
|
|
- "<field var='pubsub#persist_items'>"+
|
|
|
- "<value>true</value>"+
|
|
|
- "</field>"+
|
|
|
- "<field var='pubsub#access_model'>"+
|
|
|
- "<value>whitelist</value>"+
|
|
|
- "</field>"+
|
|
|
- "</x>"+
|
|
|
- "</publish-options>"+
|
|
|
- "</pubsub>"+
|
|
|
- "</iq>"
|
|
|
- );
|
|
|
-
|
|
|
- /* Server acknowledges successful storage
|
|
|
- *
|
|
|
- * <iq to='juliet@capulet.lit/balcony' type='result' id='pip1'/>
|
|
|
- */
|
|
|
- var stanza = $iq({
|
|
|
- 'to':_converse.connection.jid,
|
|
|
- 'type':'result',
|
|
|
- 'id':IQ_id
|
|
|
- });
|
|
|
- _converse.connection._dataRecv(test_utils.createRequest(stanza));
|
|
|
- // We ignore this IQ stanza... (unless it's an error stanza), so
|
|
|
- // nothing to test for here.
|
|
|
- done();
|
|
|
- });
|
|
|
- }));
|
|
|
-
|
|
|
- it("will be automatically opened if 'autojoin' is set on the bookmark", mock.initConverseWithPromises(
|
|
|
- null, ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
-
|
|
|
- var jid = 'lounge@localhost';
|
|
|
- _converse.bookmarks.create({
|
|
|
- 'jid': jid,
|
|
|
- 'autojoin': false,
|
|
|
- 'name': 'The Lounge',
|
|
|
- 'nick': ' Othello'
|
|
|
- });
|
|
|
- expect(_.isUndefined(_converse.chatboxviews.get(jid))).toBeTruthy();
|
|
|
-
|
|
|
- jid = 'theplay@conference.shakespeare.lit';
|
|
|
- _converse.bookmarks.create({
|
|
|
- 'jid': jid,
|
|
|
- 'autojoin': true,
|
|
|
- 'name': 'The Play',
|
|
|
- 'nick': ' Othello'
|
|
|
- });
|
|
|
- expect(_.isUndefined(_converse.chatboxviews.get(jid))).toBeFalsy();
|
|
|
- done();
|
|
|
- }));
|
|
|
-
|
|
|
- describe("when bookmarked", function () {
|
|
|
-
|
|
|
- it("displays that it's bookmarked through its bookmark icon", mock.initConverseWithPromises(
|
|
|
- null, ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
-
|
|
|
- test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
|
|
|
- var view = _converse.chatboxviews.get('lounge@localhost');
|
|
|
-
|
|
|
- test_utils.waitUntil(function () {
|
|
|
- return !_.isNull(view.el.querySelector('.toggle-bookmark'));
|
|
|
- }, 300).then(function () {
|
|
|
- var bookmark_icon = view.el.querySelector('.icon-pushpin');
|
|
|
- expect(_.includes(bookmark_icon.classList, 'button-on')).toBeFalsy();
|
|
|
- view.model.set('bookmarked', true);
|
|
|
- expect(_.includes(bookmark_icon.classList, 'button-on')).toBeTruthy();
|
|
|
- view.model.set('bookmarked', false);
|
|
|
- expect(_.includes(bookmark_icon.classList, 'button-on')).toBeFalsy();
|
|
|
- done();
|
|
|
- });
|
|
|
- }));
|
|
|
-
|
|
|
- it("can be unbookmarked", mock.initConverseWithPromises(
|
|
|
- null, ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
-
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
var sent_stanza, IQ_id;
|
|
|
var sendIQ = _converse.connection.sendIQ;
|
|
|
+ spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
+ sent_stanza = iq;
|
|
|
+ IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
+ });
|
|
|
+ spyOn(_converse.connection, 'getUniqueId').and.callThrough();
|
|
|
|
|
|
test_utils.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC');
|
|
|
var jid = 'theplay@conference.shakespeare.lit';
|
|
|
var view = _converse.chatboxviews.get(jid);
|
|
|
+ spyOn(view, 'renderBookmarkForm').and.callThrough();
|
|
|
+ spyOn(view, 'closeForm').and.callThrough();
|
|
|
|
|
|
test_utils.waitUntil(function () {
|
|
|
return !_.isNull(view.el.querySelector('.toggle-bookmark'));
|
|
|
}, 300).then(function () {
|
|
|
- spyOn(view, 'toggleBookmark').and.callThrough();
|
|
|
- spyOn(_converse.bookmarks, 'sendBookmarkStanza').and.callThrough();
|
|
|
- view.delegateEvents();
|
|
|
+ var $bookmark = $(view.el).find('.icon-pushpin');
|
|
|
+ $bookmark[0].click();
|
|
|
+ expect(view.renderBookmarkForm).toHaveBeenCalled();
|
|
|
+
|
|
|
+ view.el.querySelector('.button-cancel').click();
|
|
|
+ expect(view.closeForm).toHaveBeenCalled();
|
|
|
+ expect($bookmark.hasClass('on-button'), false);
|
|
|
+
|
|
|
+ $bookmark[0].click();
|
|
|
+ expect(view.renderBookmarkForm).toHaveBeenCalled();
|
|
|
+
|
|
|
+ /* Client uploads data:
|
|
|
+ * --------------------
|
|
|
+ * <iq from='juliet@capulet.lit/balcony' type='set' id='pip1'>
|
|
|
+ * <pubsub xmlns='http://jabber.org/protocol/pubsub'>
|
|
|
+ * <publish node='storage:bookmarks'>
|
|
|
+ * <item id='current'>
|
|
|
+ * <storage xmlns='storage:bookmarks'>
|
|
|
+ * <conference name='The Play's the Thing'
|
|
|
+ * autojoin='true'
|
|
|
+ * jid='theplay@conference.shakespeare.lit'>
|
|
|
+ * <nick>JC</nick>
|
|
|
+ * </conference>
|
|
|
+ * </storage>
|
|
|
+ * </item>
|
|
|
+ * </publish>
|
|
|
+ * <publish-options>
|
|
|
+ * <x xmlns='jabber:x:data' type='submit'>
|
|
|
+ * <field var='FORM_TYPE' type='hidden'>
|
|
|
+ * <value>http://jabber.org/protocol/pubsub#publish-options</value>
|
|
|
+ * </field>
|
|
|
+ * <field var='pubsub#persist_items'>
|
|
|
+ * <value>true</value>
|
|
|
+ * </field>
|
|
|
+ * <field var='pubsub#access_model'>
|
|
|
+ * <value>whitelist</value>
|
|
|
+ * </field>
|
|
|
+ * </x>
|
|
|
+ * </publish-options>
|
|
|
+ * </pubsub>
|
|
|
+ * </iq>
|
|
|
+ */
|
|
|
+ expect(view.model.get('bookmarked')).toBeFalsy();
|
|
|
+ var $form = $(view.el).find('.chatroom-form');
|
|
|
+ $form.find('input[name="name"]').val('Play's the Thing');
|
|
|
+ $form.find('input[name="autojoin"]').prop('checked', true);
|
|
|
+ $form.find('input[name="nick"]').val('JC');
|
|
|
+ view.el.querySelector('.button-primary').click();
|
|
|
|
|
|
- _converse.bookmarks.create({
|
|
|
- 'jid': view.model.get('jid'),
|
|
|
- 'autojoin': false,
|
|
|
- 'name': 'The Play',
|
|
|
- 'nick': ' Othello'
|
|
|
- });
|
|
|
- expect(_converse.bookmarks.length).toBe(1);
|
|
|
expect(view.model.get('bookmarked')).toBeTruthy();
|
|
|
- var $bookmark_icon = $(view.el.querySelector('.icon-pushpin'));
|
|
|
- expect($bookmark_icon.hasClass('button-on')).toBeTruthy();
|
|
|
+ expect($bookmark.hasClass('on-button'), true);
|
|
|
|
|
|
- spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
- sent_stanza = iq;
|
|
|
- IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
- });
|
|
|
- spyOn(_converse.connection, 'getUniqueId').and.callThrough();
|
|
|
- $bookmark_icon[0].click();
|
|
|
- expect(view.toggleBookmark).toHaveBeenCalled();
|
|
|
- expect($bookmark_icon.hasClass('button-on')).toBeFalsy();
|
|
|
- expect(_converse.bookmarks.length).toBe(0);
|
|
|
-
|
|
|
- // Check that an IQ stanza is sent out, containing no
|
|
|
- // conferences to bookmark (since we removed the one and
|
|
|
- // only bookmark).
|
|
|
expect(sent_stanza.toLocaleString()).toBe(
|
|
|
"<iq type='set' from='dummy@localhost/resource' xmlns='jabber:client' id='"+IQ_id+"'>"+
|
|
|
"<pubsub xmlns='http://jabber.org/protocol/pubsub'>"+
|
|
|
"<publish node='storage:bookmarks'>"+
|
|
|
"<item id='current'>"+
|
|
|
- "<storage xmlns='storage:bookmarks'/>"+
|
|
|
+ "<storage xmlns='storage:bookmarks'>"+
|
|
|
+ "<conference name='Play&apos;s the Thing' autojoin='true' jid='theplay@conference.shakespeare.lit'>"+
|
|
|
+ "<nick>JC</nick>"+
|
|
|
+ "</conference>"+
|
|
|
+ "</storage>"+
|
|
|
"</item>"+
|
|
|
"</publish>"+
|
|
|
"<publish-options>"+
|
|
@@ -247,32 +125,186 @@
|
|
|
"</pubsub>"+
|
|
|
"</iq>"
|
|
|
);
|
|
|
+
|
|
|
+ /* Server acknowledges successful storage
|
|
|
+ *
|
|
|
+ * <iq to='juliet@capulet.lit/balcony' type='result' id='pip1'/>
|
|
|
+ */
|
|
|
+ var stanza = $iq({
|
|
|
+ 'to':_converse.connection.jid,
|
|
|
+ 'type':'result',
|
|
|
+ 'id':IQ_id
|
|
|
+ });
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(stanza));
|
|
|
+ // We ignore this IQ stanza... (unless it's an error stanza), so
|
|
|
+ // nothing to test for here.
|
|
|
done();
|
|
|
});
|
|
|
- }));
|
|
|
- });
|
|
|
+ });
|
|
|
+ }));
|
|
|
|
|
|
- describe("and when autojoin is set", function () {
|
|
|
+ it("will be automatically opened if 'autojoin' is set on the bookmark", mock.initConverseWithPromises(
|
|
|
+ null, ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
|
|
|
- it("will be be opened and joined automatically upon login", mock.initConverse(function (_converse) {
|
|
|
- spyOn(_converse.api.rooms, 'open');
|
|
|
- var jid = 'theplay@conference.shakespeare.lit';
|
|
|
- var model = _converse.bookmarks.create({
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
+ var jid = 'lounge@localhost';
|
|
|
+ _converse.bookmarks.create({
|
|
|
'jid': jid,
|
|
|
'autojoin': false,
|
|
|
- 'name': 'The Play',
|
|
|
- 'nick': ''
|
|
|
+ 'name': 'The Lounge',
|
|
|
+ 'nick': ' Othello'
|
|
|
});
|
|
|
- expect(_converse.api.rooms.open).not.toHaveBeenCalled();
|
|
|
- _converse.bookmarks.remove(model);
|
|
|
+ expect(_.isUndefined(_converse.chatboxviews.get(jid))).toBeTruthy();
|
|
|
|
|
|
+ jid = 'theplay@conference.shakespeare.lit';
|
|
|
_converse.bookmarks.create({
|
|
|
'jid': jid,
|
|
|
'autojoin': true,
|
|
|
- 'name': 'Hamlet',
|
|
|
- 'nick': ''
|
|
|
+ 'name': 'The Play',
|
|
|
+ 'nick': ' Othello'
|
|
|
+ });
|
|
|
+ expect(_.isUndefined(_converse.chatboxviews.get(jid))).toBeFalsy();
|
|
|
+ done();
|
|
|
+ });
|
|
|
+ }));
|
|
|
+
|
|
|
+ describe("when bookmarked", function () {
|
|
|
+
|
|
|
+ it("displays that it's bookmarked through its bookmark icon", mock.initConverseWithPromises(
|
|
|
+ null, ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
+
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
+ test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
|
|
|
+ var view = _converse.chatboxviews.get('lounge@localhost');
|
|
|
+
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
+ return !_.isNull(view.el.querySelector('.toggle-bookmark'));
|
|
|
+ }, 300).then(function () {
|
|
|
+ var bookmark_icon = view.el.querySelector('.icon-pushpin');
|
|
|
+ expect(_.includes(bookmark_icon.classList, 'button-on')).toBeFalsy();
|
|
|
+ view.model.set('bookmarked', true);
|
|
|
+ expect(_.includes(bookmark_icon.classList, 'button-on')).toBeTruthy();
|
|
|
+ view.model.set('bookmarked', false);
|
|
|
+ expect(_.includes(bookmark_icon.classList, 'button-on')).toBeFalsy();
|
|
|
+ done();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }));
|
|
|
+
|
|
|
+ it("can be unbookmarked", mock.initConverseWithPromises(
|
|
|
+ null, ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
+
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
+ var sent_stanza, IQ_id;
|
|
|
+ var sendIQ = _converse.connection.sendIQ;
|
|
|
+
|
|
|
+ test_utils.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC');
|
|
|
+ var jid = 'theplay@conference.shakespeare.lit';
|
|
|
+ var view = _converse.chatboxviews.get(jid);
|
|
|
+
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
+ return !_.isNull(view.el.querySelector('.toggle-bookmark'));
|
|
|
+ }, 300).then(function () {
|
|
|
+ spyOn(view, 'toggleBookmark').and.callThrough();
|
|
|
+ spyOn(_converse.bookmarks, 'sendBookmarkStanza').and.callThrough();
|
|
|
+ view.delegateEvents();
|
|
|
+
|
|
|
+ _converse.bookmarks.create({
|
|
|
+ 'jid': view.model.get('jid'),
|
|
|
+ 'autojoin': false,
|
|
|
+ 'name': 'The Play',
|
|
|
+ 'nick': ' Othello'
|
|
|
+ });
|
|
|
+ expect(_converse.bookmarks.length).toBe(1);
|
|
|
+ expect(view.model.get('bookmarked')).toBeTruthy();
|
|
|
+ var $bookmark_icon = $(view.el.querySelector('.icon-pushpin'));
|
|
|
+ expect($bookmark_icon.hasClass('button-on')).toBeTruthy();
|
|
|
+
|
|
|
+ spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
|
|
+ sent_stanza = iq;
|
|
|
+ IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
|
|
+ });
|
|
|
+ spyOn(_converse.connection, 'getUniqueId').and.callThrough();
|
|
|
+ $bookmark_icon[0].click();
|
|
|
+ expect(view.toggleBookmark).toHaveBeenCalled();
|
|
|
+ expect($bookmark_icon.hasClass('button-on')).toBeFalsy();
|
|
|
+ expect(_converse.bookmarks.length).toBe(0);
|
|
|
+
|
|
|
+ // Check that an IQ stanza is sent out, containing no
|
|
|
+ // conferences to bookmark (since we removed the one and
|
|
|
+ // only bookmark).
|
|
|
+ expect(sent_stanza.toLocaleString()).toBe(
|
|
|
+ "<iq type='set' from='dummy@localhost/resource' xmlns='jabber:client' id='"+IQ_id+"'>"+
|
|
|
+ "<pubsub xmlns='http://jabber.org/protocol/pubsub'>"+
|
|
|
+ "<publish node='storage:bookmarks'>"+
|
|
|
+ "<item id='current'>"+
|
|
|
+ "<storage xmlns='storage:bookmarks'/>"+
|
|
|
+ "</item>"+
|
|
|
+ "</publish>"+
|
|
|
+ "<publish-options>"+
|
|
|
+ "<x xmlns='jabber:x:data' type='submit'>"+
|
|
|
+ "<field var='FORM_TYPE' type='hidden'>"+
|
|
|
+ "<value>http://jabber.org/protocol/pubsub#publish-options</value>"+
|
|
|
+ "</field>"+
|
|
|
+ "<field var='pubsub#persist_items'>"+
|
|
|
+ "<value>true</value>"+
|
|
|
+ "</field>"+
|
|
|
+ "<field var='pubsub#access_model'>"+
|
|
|
+ "<value>whitelist</value>"+
|
|
|
+ "</field>"+
|
|
|
+ "</x>"+
|
|
|
+ "</publish-options>"+
|
|
|
+ "</pubsub>"+
|
|
|
+ "</iq>"
|
|
|
+ );
|
|
|
+ done();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }));
|
|
|
+ });
|
|
|
+
|
|
|
+ describe("and when autojoin is set", function () {
|
|
|
+
|
|
|
+ it("will be be opened and joined automatically upon login", mock.initConverseWithPromises(
|
|
|
+ null, ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
+
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
+ spyOn(_converse.api.rooms, 'open');
|
|
|
+ var jid = 'theplay@conference.shakespeare.lit';
|
|
|
+ var model = _converse.bookmarks.create({
|
|
|
+ 'jid': jid,
|
|
|
+ 'autojoin': false,
|
|
|
+ 'name': 'The Play',
|
|
|
+ 'nick': ''
|
|
|
+ });
|
|
|
+ expect(_converse.api.rooms.open).not.toHaveBeenCalled();
|
|
|
+ _converse.bookmarks.remove(model);
|
|
|
+
|
|
|
+ _converse.bookmarks.create({
|
|
|
+ 'jid': jid,
|
|
|
+ 'autojoin': true,
|
|
|
+ 'name': 'Hamlet',
|
|
|
+ 'nick': ''
|
|
|
+ });
|
|
|
+ expect(_converse.api.rooms.open).toHaveBeenCalled();
|
|
|
+ done();
|
|
|
});
|
|
|
- expect(_converse.api.rooms.open).toHaveBeenCalled();
|
|
|
}));
|
|
|
});
|
|
|
});
|
|
@@ -283,53 +315,58 @@
|
|
|
['send'], ['rosterGroupsFetched', 'connected'], {},
|
|
|
function (done, _converse) {
|
|
|
|
|
|
- test_utils.openControlBox().openRoomsPanel(_converse);
|
|
|
-
|
|
|
- test_utils.waitUntil(function () {
|
|
|
- return _converse.bookmarks;
|
|
|
- }, 300).then(function () {
|
|
|
- /* The stored data is automatically pushed to all of the user's
|
|
|
- * connected resources.
|
|
|
- *
|
|
|
- * Publisher receives event notification
|
|
|
- * -------------------------------------
|
|
|
- * <message from='juliet@capulet.lit'
|
|
|
- * to='juliet@capulet.lit/balcony'
|
|
|
- * type='headline'
|
|
|
- * id='rnfoo1'>
|
|
|
- * <event xmlns='http://jabber.org/protocol/pubsub#event'>
|
|
|
- * <items node='storage:bookmarks'>
|
|
|
- * <item id='current'>
|
|
|
- * <storage xmlns='storage:bookmarks'>
|
|
|
- * <conference name='The Play's the Thing'
|
|
|
- * autojoin='true'
|
|
|
- * jid='theplay@conference.shakespeare.lit'>
|
|
|
- * <nick>JC</nick>
|
|
|
- * </conference>
|
|
|
- * </storage>
|
|
|
- * </item>
|
|
|
- * </items>
|
|
|
- * </event>
|
|
|
- * </message>
|
|
|
- */
|
|
|
- var stanza = $msg({
|
|
|
- 'from': 'dummy@localhost',
|
|
|
- 'to': 'dummy@localhost/resource',
|
|
|
- 'type': 'headline',
|
|
|
- 'id': 'rnfoo1'
|
|
|
- }).c('event', {'xmlns': 'http://jabber.org/protocol/pubsub#event'})
|
|
|
- .c('items', {'node': 'storage:bookmarks'})
|
|
|
- .c('item', {'id': 'current'})
|
|
|
- .c('storage', {'xmlns': 'storage:bookmarks'})
|
|
|
- .c('conference', {'name': 'The Play's the Thing',
|
|
|
- 'autojoin': 'true',
|
|
|
- 'jid':'theplay@conference.shakespeare.lit'})
|
|
|
- .c('nick').t('JC');
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
+ test_utils.openControlBox().openRoomsPanel(_converse);
|
|
|
+ test_utils.waitUntil(function () {
|
|
|
+ return _converse.bookmarks;
|
|
|
+ }, 300).then(function () {
|
|
|
+ /* The stored data is automatically pushed to all of the user's
|
|
|
+ * connected resources.
|
|
|
+ *
|
|
|
+ * Publisher receives event notification
|
|
|
+ * -------------------------------------
|
|
|
+ * <message from='juliet@capulet.lit'
|
|
|
+ * to='juliet@capulet.lit/balcony'
|
|
|
+ * type='headline'
|
|
|
+ * id='rnfoo1'>
|
|
|
+ * <event xmlns='http://jabber.org/protocol/pubsub#event'>
|
|
|
+ * <items node='storage:bookmarks'>
|
|
|
+ * <item id='current'>
|
|
|
+ * <storage xmlns='storage:bookmarks'>
|
|
|
+ * <conference name='The Play's the Thing'
|
|
|
+ * autojoin='true'
|
|
|
+ * jid='theplay@conference.shakespeare.lit'>
|
|
|
+ * <nick>JC</nick>
|
|
|
+ * </conference>
|
|
|
+ * </storage>
|
|
|
+ * </item>
|
|
|
+ * </items>
|
|
|
+ * </event>
|
|
|
+ * </message>
|
|
|
+ */
|
|
|
+ var stanza = $msg({
|
|
|
+ 'from': 'dummy@localhost',
|
|
|
+ 'to': 'dummy@localhost/resource',
|
|
|
+ 'type': 'headline',
|
|
|
+ 'id': 'rnfoo1'
|
|
|
+ }).c('event', {'xmlns': 'http://jabber.org/protocol/pubsub#event'})
|
|
|
+ .c('items', {'node': 'storage:bookmarks'})
|
|
|
+ .c('item', {'id': 'current'})
|
|
|
+ .c('storage', {'xmlns': 'storage:bookmarks'})
|
|
|
+ .c('conference', {'name': 'The Play's the Thing',
|
|
|
+ 'autojoin': 'true',
|
|
|
+ 'jid':'theplay@conference.shakespeare.lit'})
|
|
|
+ .c('nick').t('JC');
|
|
|
|
|
|
- _converse.connection._dataRecv(test_utils.createRequest(stanza));
|
|
|
- expect(_converse.bookmarks.length).toBe(1);
|
|
|
- expect(_converse.chatboxviews.get('theplay@conference.shakespeare.lit')).not.toBeUndefined();
|
|
|
- done();
|
|
|
+ _converse.connection._dataRecv(test_utils.createRequest(stanza));
|
|
|
+ expect(_converse.bookmarks.length).toBe(1);
|
|
|
+ expect(_converse.chatboxviews.get('theplay@conference.shakespeare.lit')).not.toBeUndefined();
|
|
|
+ done();
|
|
|
+ });
|
|
|
});
|
|
|
}));
|
|
|
|
|
@@ -337,9 +374,11 @@
|
|
|
['send'], ['chatBoxesFetched', 'roomsPanelRendered', 'rosterGroupsFetched'], {},
|
|
|
function (done, _converse) {
|
|
|
|
|
|
- test_utils.waitUntil(function () {
|
|
|
- return _converse.bookmarks;
|
|
|
- }, 300).then(function () {
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
/* Client requests all items
|
|
|
* -------------------------
|
|
|
*
|
|
@@ -420,9 +459,11 @@
|
|
|
it("shows a list of bookmarks", mock.initConverseWithPromises(
|
|
|
['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
|
|
|
- test_utils.waitUntil(function () {
|
|
|
- return _converse.bookmarks;
|
|
|
- }, 300).then(function () {
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
|
|
|
test_utils.openControlBox().openRoomsPanel(_converse);
|
|
|
var IQ_id;
|
|
@@ -495,9 +536,11 @@
|
|
|
it("remembers the toggle state of the bookmarks list", mock.initConverseWithPromises(
|
|
|
['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
|
|
|
|
|
|
- test_utils.waitUntil(function () {
|
|
|
- return _converse.bookmarks;
|
|
|
- }, 300).then(function () {
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
var IQ_id;
|
|
|
expect(_.filter(_converse.connection.send.calls.all(), function (call) {
|
|
|
var stanza = call.args[0];
|
|
@@ -561,9 +604,11 @@
|
|
|
{ hide_open_bookmarks: true },
|
|
|
function (done, _converse) {
|
|
|
|
|
|
- test_utils.waitUntil(function () {
|
|
|
- return _converse.bookmarks;
|
|
|
- }, 300).then(function () {
|
|
|
+ test_utils.waitUntilDiscoConfirmed(
|
|
|
+ _converse, _converse.bare_jid,
|
|
|
+ [{'category': 'pubsub', 'type': 'pep'}],
|
|
|
+ ['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
+ ).then(function () {
|
|
|
test_utils.openControlBox().openRoomsPanel(_converse);
|
|
|
// XXX Create bookmarks view here, otherwise we need to mock stanza
|
|
|
// traffic for it to get created.
|