2020-12-29 12:52:53 +01:00
|
|
|
/* global mock, converse, _ */
|
2020-04-22 13:11:48 +02:00
|
|
|
|
2020-10-27 11:57:23 +01:00
|
|
|
const { Strophe, u, sizzle, $iq } = converse.env;
|
2020-09-25 13:17:56 +02:00
|
|
|
|
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
describe("A chat room", function () {
|
|
|
|
|
2020-10-27 22:48:22 +01:00
|
|
|
it("can be bookmarked", mock.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
['chatBoxesFetched'], {}, async function (done, _converse) {
|
2020-04-22 13:11:48 +02:00
|
|
|
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.waitUntilDiscoConfirmed(
|
|
|
|
_converse, _converse.bare_jid,
|
|
|
|
[{'category': 'pubsub', 'type': 'pep'}],
|
|
|
|
['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
|
);
|
|
|
|
const { u, $iq } = converse.env;
|
|
|
|
spyOn(_converse.connection, 'getUniqueId').and.callThrough();
|
|
|
|
|
2020-10-27 22:48:22 +01:00
|
|
|
const nick = 'JC';
|
|
|
|
const muc_jid = 'theplay@conference.shakespeare.lit';
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC');
|
2020-10-27 22:48:22 +01:00
|
|
|
await mock.getRoomFeatures(_converse, muc_jid, []);
|
|
|
|
await mock.waitForReservedNick(_converse, muc_jid, nick);
|
|
|
|
await mock.receiveOwnMUCPresence(_converse, muc_jid, nick);
|
|
|
|
const view = _converse.chatboxviews.get(muc_jid);
|
|
|
|
await u.waitUntil(() => (view.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED));
|
|
|
|
await mock.returnMemberLists(_converse, muc_jid, [], ['member', 'admin', 'owner']);
|
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
spyOn(view, 'renderBookmarkForm').and.callThrough();
|
|
|
|
spyOn(view, 'closeForm').and.callThrough();
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelector('.toggle-bookmark') !== null);
|
|
|
|
const toggle = view.querySelector('.toggle-bookmark');
|
2020-04-22 13:11:48 +02:00
|
|
|
expect(toggle.title).toBe('Bookmark this groupchat');
|
|
|
|
toggle.click();
|
|
|
|
expect(view.renderBookmarkForm).toHaveBeenCalled();
|
|
|
|
|
2020-12-08 12:54:14 +01:00
|
|
|
view.querySelector('.button-cancel').click();
|
2020-04-22 13:11:48 +02:00
|
|
|
expect(view.closeForm).toHaveBeenCalled();
|
|
|
|
expect(u.hasClass('on-button', toggle), false);
|
|
|
|
expect(toggle.title).toBe('Bookmark this groupchat');
|
|
|
|
|
|
|
|
toggle.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();
|
2020-12-08 12:54:14 +01:00
|
|
|
const form = view.querySelector('.chatroom-form');
|
2020-04-22 13:11:48 +02:00
|
|
|
form.querySelector('input[name="name"]').value = 'Play's the Thing';
|
|
|
|
form.querySelector('input[name="autojoin"]').checked = 'checked';
|
|
|
|
form.querySelector('input[name="nick"]').value = 'JC';
|
|
|
|
|
2020-10-27 22:48:22 +01:00
|
|
|
const IQ_stanzas = _converse.connection.IQ_stanzas;
|
2020-12-08 12:54:14 +01:00
|
|
|
view.querySelector('.muc-bookmark-form .btn-primary').click();
|
2020-04-22 13:11:48 +02:00
|
|
|
|
2020-10-27 22:48:22 +01:00
|
|
|
const sent_stanza = await u.waitUntil(
|
|
|
|
() => IQ_stanzas.filter(s => sizzle('iq publish[node="storage:bookmarks"]', s).length).pop());
|
2020-09-25 13:17:56 +02:00
|
|
|
expect(Strophe.serialize(sent_stanza)).toBe(
|
2020-10-27 22:48:22 +01:00
|
|
|
`<iq from="romeo@montague.lit/orchard" id="${sent_stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
|
2020-04-22 13:11:48 +02:00
|
|
|
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
|
|
|
|
`<publish node="storage:bookmarks">`+
|
|
|
|
`<item id="current">`+
|
|
|
|
`<storage xmlns="storage:bookmarks">`+
|
|
|
|
`<conference autojoin="true" jid="theplay@conference.shakespeare.lit" name="Play&apos;s the Thing">`+
|
|
|
|
`<nick>JC</nick>`+
|
|
|
|
`</conference>`+
|
|
|
|
`</storage>`+
|
|
|
|
`</item>`+
|
|
|
|
`</publish>`+
|
|
|
|
`<publish-options>`+
|
|
|
|
`<x type="submit" xmlns="jabber:x:data">`+
|
|
|
|
`<field type="hidden" var="FORM_TYPE">`+
|
|
|
|
`<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
|
2020-10-27 22:48:22 +01:00
|
|
|
*
|
|
|
|
* <iq to='juliet@capulet.lit/balcony' type='result' id='pip1'/>
|
|
|
|
*/
|
2020-04-22 13:11:48 +02:00
|
|
|
const stanza = $iq({
|
|
|
|
'to':_converse.connection.jid,
|
|
|
|
'type':'result',
|
2020-10-27 22:48:22 +01:00
|
|
|
'id': sent_stanza.getAttribute('id')
|
2020-04-22 13:11:48 +02:00
|
|
|
});
|
|
|
|
_converse.connection._dataRecv(mock.createRequest(stanza));
|
|
|
|
await u.waitUntil(() => view.model.get('bookmarked'));
|
|
|
|
expect(view.model.get('bookmarked')).toBeTruthy();
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelector('.toggle-bookmark')?.title === 'Unbookmark this groupchat');
|
|
|
|
expect(u.hasClass('on-button', view.querySelector('.toggle-bookmark')), true);
|
2020-04-22 13:11:48 +02:00
|
|
|
// 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.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
[], {}, async function (done, _converse) {
|
2020-04-22 13:11:48 +02:00
|
|
|
|
2020-12-29 12:52:53 +01:00
|
|
|
const { u } = converse.env;
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.waitUntilDiscoConfirmed(
|
|
|
|
_converse, _converse.bare_jid,
|
|
|
|
[{'category': 'pubsub', 'type': 'pep'}],
|
|
|
|
['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
|
);
|
|
|
|
await u.waitUntil(() => _converse.bookmarks);
|
|
|
|
let jid = 'lounge@montague.lit';
|
|
|
|
_converse.bookmarks.create({
|
|
|
|
'jid': jid,
|
|
|
|
'autojoin': false,
|
|
|
|
'name': 'The Lounge',
|
|
|
|
'nick': ' Othello'
|
|
|
|
});
|
|
|
|
expect(_converse.chatboxviews.get(jid) === undefined).toBeTruthy();
|
|
|
|
|
|
|
|
jid = 'theplay@conference.shakespeare.lit';
|
|
|
|
_converse.bookmarks.create({
|
|
|
|
'jid': jid,
|
|
|
|
'autojoin': true,
|
|
|
|
'name': 'The Play',
|
|
|
|
'nick': ' Othello'
|
|
|
|
});
|
|
|
|
await new Promise(resolve => _converse.api.listen.once('chatRoomViewInitialized', resolve));
|
|
|
|
expect(_.isUndefined(_converse.chatboxviews.get(jid))).toBeFalsy();
|
|
|
|
|
|
|
|
// Check that we don't auto-join if muc_respect_autojoin is false
|
|
|
|
_converse.muc_respect_autojoin = false;
|
|
|
|
jid = 'balcony@conference.shakespeare.lit';
|
|
|
|
_converse.bookmarks.create({
|
|
|
|
'jid': jid,
|
|
|
|
'autojoin': true,
|
|
|
|
'name': 'Balcony',
|
|
|
|
'nick': ' Othello'
|
|
|
|
});
|
|
|
|
expect(_converse.chatboxviews.get(jid) === undefined).toBe(true);
|
|
|
|
done();
|
|
|
|
}));
|
2016-06-27 23:50:38 +02:00
|
|
|
|
2019-10-11 23:33:30 +02:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
describe("when bookmarked", function () {
|
|
|
|
|
2021-01-26 14:01:37 +01:00
|
|
|
it("will use the nickname from the bookmark", mock.initConverse([], {}, async function (done, _converse) {
|
2020-04-22 13:11:48 +02:00
|
|
|
const { u } = converse.env;
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.waitUntilBookmarksReturned(_converse);
|
|
|
|
const muc_jid = 'coven@chat.shakespeare.lit';
|
|
|
|
_converse.bookmarks.create({
|
|
|
|
'jid': muc_jid,
|
|
|
|
'autojoin': false,
|
|
|
|
'name': 'The Play',
|
|
|
|
'nick': 'Othello'
|
|
|
|
});
|
|
|
|
spyOn(_converse.ChatRoom.prototype, 'getAndPersistNickname').and.callThrough();
|
|
|
|
const room_creation_promise = _converse.api.rooms.open(muc_jid);
|
|
|
|
await mock.getRoomFeatures(_converse, muc_jid);
|
|
|
|
const room = await room_creation_promise;
|
|
|
|
await u.waitUntil(() => room.getAndPersistNickname.calls.count());
|
|
|
|
expect(room.get('nick')).toBe('Othello');
|
|
|
|
done();
|
|
|
|
}));
|
2016-06-27 23:50:38 +02:00
|
|
|
|
2021-01-26 14:01:37 +01:00
|
|
|
it("displays that it's bookmarked through its bookmark icon", mock.initConverse([], {}, async function (done, _converse) {
|
2019-05-21 12:05:47 +02:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
const { u } = converse.env;
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
mock.waitUntilDiscoConfirmed(
|
2018-02-08 09:49:05 +01:00
|
|
|
_converse, _converse.bare_jid,
|
|
|
|
[{'category': 'pubsub', 'type': 'pep'}],
|
|
|
|
['http://jabber.org/protocol/pubsub#publish-options']
|
2018-11-22 12:15:35 +01:00
|
|
|
);
|
2020-04-22 13:11:48 +02:00
|
|
|
await _converse.api.rooms.open(`lounge@montague.lit`);
|
|
|
|
const view = _converse.chatboxviews.get('lounge@montague.lit');
|
2020-12-08 12:54:14 +01:00
|
|
|
expect(view.querySelector('.chatbox-title__text .fa-bookmark')).toBe(null);
|
2020-04-22 13:11:48 +02:00
|
|
|
_converse.bookmarks.create({
|
|
|
|
'jid': view.model.get('jid'),
|
|
|
|
'autojoin': false,
|
|
|
|
'name': 'The lounge',
|
|
|
|
'nick': ' some1'
|
|
|
|
});
|
|
|
|
view.model.set('bookmarked', true);
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelector('.chatbox-title__text .fa-bookmark') !== null);
|
2020-04-22 13:11:48 +02:00
|
|
|
view.model.set('bookmarked', false);
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelector('.chatbox-title__text .fa-bookmark') === null);
|
2020-04-22 13:11:48 +02:00
|
|
|
done();
|
|
|
|
}));
|
|
|
|
|
2021-01-26 14:01:37 +01:00
|
|
|
it("can be unbookmarked", mock.initConverse([], {}, async function (done, _converse) {
|
2020-04-22 13:11:48 +02:00
|
|
|
|
|
|
|
const { u, Strophe } = converse.env;
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.waitUntilBookmarksReturned(_converse);
|
|
|
|
const muc_jid = 'theplay@conference.shakespeare.lit';
|
|
|
|
await _converse.api.rooms.open(muc_jid);
|
|
|
|
const view = _converse.chatboxviews.get(muc_jid);
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelector('.toggle-bookmark'));
|
2020-04-22 13:11:48 +02:00
|
|
|
|
|
|
|
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'
|
2018-02-08 09:49:05 +01:00
|
|
|
});
|
2018-11-22 12:15:35 +01:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
expect(_converse.bookmarks.length).toBe(1);
|
|
|
|
await u.waitUntil(() => _converse.chatboxes.length >= 1);
|
|
|
|
expect(view.model.get('bookmarked')).toBeTruthy();
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelector('.chatbox-title__text .fa-bookmark') !== null);
|
2020-04-22 13:11:48 +02:00
|
|
|
spyOn(_converse.connection, 'getUniqueId').and.callThrough();
|
2020-12-08 12:54:14 +01:00
|
|
|
const bookmark_icon = view.querySelector('.toggle-bookmark');
|
2020-04-22 13:11:48 +02:00
|
|
|
bookmark_icon.click();
|
|
|
|
expect(view.toggleBookmark).toHaveBeenCalled();
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelector('.chatbox-title__text .fa-bookmark') === null);
|
2020-04-22 13:11:48 +02:00
|
|
|
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).
|
|
|
|
const sent_stanza = _converse.connection.IQ_stanzas.pop();
|
|
|
|
expect(Strophe.serialize(sent_stanza)).toBe(
|
|
|
|
`<iq from="romeo@montague.lit/orchard" id="${sent_stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
|
2018-11-22 12:15:35 +01:00
|
|
|
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`+
|
|
|
|
`<publish node="storage:bookmarks">`+
|
|
|
|
`<item id="current">`+
|
2020-04-22 13:11:48 +02:00
|
|
|
`<storage xmlns="storage:bookmarks"/>`+
|
2018-11-22 12:15:35 +01:00
|
|
|
`</item>`+
|
|
|
|
`</publish>`+
|
|
|
|
`<publish-options>`+
|
|
|
|
`<x type="submit" xmlns="jabber:x:data">`+
|
|
|
|
`<field type="hidden" var="FORM_TYPE">`+
|
|
|
|
`<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();
|
2018-02-08 09:49:05 +01:00
|
|
|
}));
|
2020-04-22 13:11:48 +02:00
|
|
|
});
|
2016-09-23 09:41:55 +02:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
describe("and when autojoin is set", function () {
|
2018-11-22 12:15:35 +01:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
it("will be be opened and joined automatically upon login", mock.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
[], {}, async function (done, _converse) {
|
2016-09-23 09:41:55 +02:00
|
|
|
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.waitUntilBookmarksReturned(_converse);
|
|
|
|
spyOn(_converse.api.rooms, 'create').and.callThrough();
|
|
|
|
const jid = 'theplay@conference.shakespeare.lit';
|
|
|
|
const model = _converse.bookmarks.create({
|
2018-11-22 12:15:35 +01:00
|
|
|
'jid': jid,
|
|
|
|
'autojoin': false,
|
|
|
|
'name': 'The Play',
|
2020-04-22 13:11:48 +02:00
|
|
|
'nick': ''
|
2018-02-08 09:49:05 +01:00
|
|
|
});
|
2020-04-22 13:11:48 +02:00
|
|
|
expect(_converse.api.rooms.create).not.toHaveBeenCalled();
|
|
|
|
_converse.bookmarks.remove(model);
|
2019-03-27 08:34:36 +01:00
|
|
|
_converse.bookmarks.create({
|
|
|
|
'jid': jid,
|
|
|
|
'autojoin': true,
|
2020-04-22 13:11:48 +02:00
|
|
|
'name': 'Hamlet',
|
|
|
|
'nick': ''
|
2019-03-27 08:34:36 +01:00
|
|
|
});
|
2020-04-22 13:11:48 +02:00
|
|
|
expect(_converse.api.rooms.create).toHaveBeenCalled();
|
2018-11-22 12:15:35 +01:00
|
|
|
done();
|
2018-02-08 09:49:05 +01:00
|
|
|
}));
|
2016-06-27 23:50:38 +02:00
|
|
|
});
|
2020-04-22 13:11:48 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("Bookmarks", function () {
|
|
|
|
|
|
|
|
it("can be pushed from the XMPP server", mock.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
['connected', 'chatBoxesFetched'], {}, async function (done, _converse) {
|
2020-04-22 13:11:48 +02:00
|
|
|
|
|
|
|
const { $msg, u } = converse.env;
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.waitUntilBookmarksReturned(_converse);
|
|
|
|
|
|
|
|
/* The stored data is automatically pushed to all of the user's
|
2020-10-23 16:06:05 +02:00
|
|
|
* 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>
|
|
|
|
*/
|
|
|
|
let stanza = $msg({
|
2020-04-22 13:11:48 +02:00
|
|
|
'from': 'romeo@montague.lit',
|
2020-10-23 16:06:05 +02:00
|
|
|
'to': _converse.jid,
|
2020-04-22 13:11:48 +02:00
|
|
|
'type': 'headline',
|
2020-10-23 16:06:05 +02:00
|
|
|
'id': u.getUniqueId()
|
2020-04-22 13:11:48 +02:00
|
|
|
}).c('event', {'xmlns': 'http://jabber.org/protocol/pubsub#event'})
|
|
|
|
.c('items', {'node': 'storage:bookmarks'})
|
|
|
|
.c('item', {'id': 'current'})
|
|
|
|
.c('storage', {'xmlns': 'storage:bookmarks'})
|
2020-10-23 16:06:05 +02:00
|
|
|
.c('conference', {
|
|
|
|
'name': 'The Play's the Thing',
|
|
|
|
'autojoin': 'true',
|
|
|
|
'jid':'theplay@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC').up().up()
|
|
|
|
.c('conference', {
|
|
|
|
'name': 'Another bookmark',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid':'another@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC');
|
2020-04-22 13:11:48 +02:00
|
|
|
_converse.connection._dataRecv(mock.createRequest(stanza));
|
|
|
|
await u.waitUntil(() => _converse.bookmarks.length);
|
2020-10-23 16:06:05 +02:00
|
|
|
expect(_converse.bookmarks.length).toBe(2);
|
|
|
|
expect(_converse.bookmarks.map(b => b.get('name'))).toEqual(['Another bookmark', 'The Play's the Thing']);
|
|
|
|
expect(_converse.chatboxviews.get('theplay@conference.shakespeare.lit')).not.toBeUndefined();
|
|
|
|
|
|
|
|
stanza = $msg({
|
|
|
|
'from': 'romeo@montague.lit',
|
|
|
|
'to': _converse.jid,
|
|
|
|
'type': 'headline',
|
|
|
|
'id': u.getUniqueId()
|
|
|
|
}).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').up().up()
|
|
|
|
.c('conference', {
|
|
|
|
'name': 'Second bookmark',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid':'another@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC').up().up()
|
|
|
|
.c('conference', {
|
|
|
|
'name': 'Yet another bookmark',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid':'yab@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC');
|
|
|
|
_converse.connection._dataRecv(mock.createRequest(stanza));
|
|
|
|
|
|
|
|
await u.waitUntil(() => _converse.bookmarks.length === 3);
|
|
|
|
expect(_converse.bookmarks.map(b => b.get('name'))).toEqual(['Second bookmark', 'The Play's the Thing', 'Yet another bookmark']);
|
2020-04-22 13:11:48 +02:00
|
|
|
expect(_converse.chatboxviews.get('theplay@conference.shakespeare.lit')).not.toBeUndefined();
|
2020-10-23 16:06:05 +02:00
|
|
|
expect(Object.keys(_converse.chatboxviews.getAll()).length).toBe(2);
|
2020-04-22 13:11:48 +02:00
|
|
|
done();
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it("can be retrieved from the XMPP server", mock.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
['chatBoxesFetched'], {},
|
2020-04-22 13:11:48 +02:00
|
|
|
async function (done, _converse) {
|
2016-06-27 23:50:38 +02:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
const { Strophe, sizzle, u, $iq } = converse.env;
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.waitUntilDiscoConfirmed(
|
|
|
|
_converse, _converse.bare_jid,
|
|
|
|
[{'category': 'pubsub', 'type': 'pep'}],
|
|
|
|
['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
|
);
|
|
|
|
/* Client requests all items
|
2021-01-26 09:58:16 +01:00
|
|
|
* -------------------------
|
|
|
|
*
|
|
|
|
* <iq from='juliet@capulet.lit/randomID' type='get' id='retrieve1'>
|
|
|
|
* <pubsub xmlns='http://jabber.org/protocol/pubsub'>
|
|
|
|
* <items node='storage:bookmarks'/>
|
|
|
|
* </pubsub>
|
|
|
|
* </iq>
|
|
|
|
*/
|
2020-04-22 13:11:48 +02:00
|
|
|
const IQ_stanzas = _converse.connection.IQ_stanzas;
|
|
|
|
const sent_stanza = await u.waitUntil(
|
|
|
|
() => IQ_stanzas.filter(s => sizzle('items[node="storage:bookmarks"]', s).length).pop());
|
|
|
|
|
|
|
|
expect(Strophe.serialize(sent_stanza)).toBe(
|
|
|
|
`<iq from="romeo@montague.lit/orchard" id="${sent_stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
|
|
|
|
'<pubsub xmlns="http://jabber.org/protocol/pubsub">'+
|
|
|
|
'<items node="storage:bookmarks"/>'+
|
|
|
|
'</pubsub>'+
|
|
|
|
'</iq>');
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Server returns all items
|
|
|
|
* ------------------------
|
|
|
|
* <iq type='result'
|
|
|
|
* to='juliet@capulet.lit/randomID'
|
|
|
|
* id='retrieve1'>
|
|
|
|
* <pubsub xmlns='http://jabber.org/protocol/pubsub'>
|
|
|
|
* <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>
|
|
|
|
* </pubsub>
|
|
|
|
* </iq>
|
|
|
|
*/
|
|
|
|
expect(_converse.bookmarks.models.length).toBe(0);
|
|
|
|
|
|
|
|
spyOn(_converse.bookmarks, 'onBookmarksReceived').and.callThrough();
|
|
|
|
var stanza = $iq({'to': _converse.connection.jid, 'type':'result', 'id':sent_stanza.getAttribute('id')})
|
|
|
|
.c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
|
2018-11-22 12:15:35 +01:00
|
|
|
.c('items', {'node': 'storage:bookmarks'})
|
|
|
|
.c('item', {'id': 'current'})
|
|
|
|
.c('storage', {'xmlns': 'storage:bookmarks'})
|
2020-04-22 13:11:48 +02:00
|
|
|
.c('conference', {
|
|
|
|
'name': 'The Play's the Thing',
|
|
|
|
'autojoin': 'true',
|
|
|
|
'jid': 'theplay@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC').up().up()
|
|
|
|
.c('conference', {
|
|
|
|
'name': 'Another room',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid': 'another@conference.shakespeare.lit'
|
|
|
|
}); // Purposefully exclude the <nick> element to test #1043
|
|
|
|
_converse.connection._dataRecv(mock.createRequest(stanza));
|
|
|
|
await u.waitUntil(() => _converse.bookmarks.onBookmarksReceived.calls.count());
|
|
|
|
await _converse.api.waitUntil('bookmarksInitialized');
|
|
|
|
expect(_converse.bookmarks.models.length).toBe(2);
|
|
|
|
expect(_converse.bookmarks.findWhere({'jid': 'theplay@conference.shakespeare.lit'}).get('autojoin')).toBe(true);
|
|
|
|
expect(_converse.bookmarks.findWhere({'jid': 'another@conference.shakespeare.lit'}).get('autojoin')).toBe(false);
|
|
|
|
done();
|
|
|
|
}));
|
|
|
|
|
2021-01-26 09:58:16 +01:00
|
|
|
describe("The bookmarks list", function () {
|
2020-04-22 13:11:48 +02:00
|
|
|
|
|
|
|
it("shows a list of bookmarks", mock.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
[], {}, async function (done, _converse) {
|
2017-07-11 10:41:11 +02:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.waitUntilDiscoConfirmed(
|
2018-02-08 09:49:05 +01:00
|
|
|
_converse, _converse.bare_jid,
|
|
|
|
[{'category': 'pubsub', 'type': 'pep'}],
|
|
|
|
['http://jabber.org/protocol/pubsub#publish-options']
|
2018-10-26 10:15:01 +02:00
|
|
|
);
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
mock.openControlBox(_converse);
|
|
|
|
|
2018-11-18 19:14:22 +01:00
|
|
|
const IQ_stanzas = _converse.connection.IQ_stanzas;
|
|
|
|
const sent_stanza = await u.waitUntil(
|
|
|
|
() => IQ_stanzas.filter(s => sizzle('items[node="storage:bookmarks"]', s).length).pop());
|
2018-10-26 10:15:01 +02:00
|
|
|
|
2018-11-18 19:14:22 +01:00
|
|
|
expect(Strophe.serialize(sent_stanza)).toBe(
|
|
|
|
`<iq from="romeo@montague.lit/orchard" id="${sent_stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
|
2018-10-26 10:15:01 +02:00
|
|
|
'<pubsub xmlns="http://jabber.org/protocol/pubsub">'+
|
|
|
|
'<items node="storage:bookmarks"/>'+
|
|
|
|
'</pubsub>'+
|
2020-04-22 13:11:48 +02:00
|
|
|
'</iq>'
|
|
|
|
);
|
|
|
|
|
|
|
|
const stanza = $iq({'to': _converse.connection.jid, 'type':'result', 'id':sent_stanza.getAttribute('id')})
|
2018-10-26 10:15:01 +02:00
|
|
|
.c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
|
|
|
|
.c('items', {'node': 'storage:bookmarks'})
|
|
|
|
.c('item', {'id': 'current'})
|
|
|
|
.c('storage', {'xmlns': 'storage:bookmarks'})
|
|
|
|
.c('conference', {
|
|
|
|
'name': 'The Play's the Thing',
|
2020-04-22 13:11:48 +02:00
|
|
|
'autojoin': 'false',
|
2018-10-26 10:15:01 +02:00
|
|
|
'jid': 'theplay@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC').up().up()
|
2020-04-22 13:11:48 +02:00
|
|
|
.c('conference', {
|
|
|
|
'name': '1st Bookmark',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid': 'first@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC').up().up()
|
|
|
|
.c('conference', {
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid': 'noname@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC').up().up()
|
|
|
|
.c('conference', {
|
|
|
|
'name': 'Bookmark with a very very long name that will be shortened',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid': 'longname@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC').up().up()
|
2018-10-26 10:15:01 +02:00
|
|
|
.c('conference', {
|
|
|
|
'name': 'Another room',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid': 'another@conference.shakespeare.lit'
|
2020-04-22 13:11:48 +02:00
|
|
|
}).c('nick').t('JC').up().up();
|
|
|
|
_converse.connection._dataRecv(mock.createRequest(stanza));
|
|
|
|
|
|
|
|
await u.waitUntil(() => document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length);
|
|
|
|
expect(document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length).toBe(5);
|
|
|
|
let els = document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item a.list-item-link');
|
|
|
|
expect(els[0].textContent).toBe("1st Bookmark");
|
|
|
|
expect(els[1].textContent).toBe("Another room");
|
|
|
|
expect(els[2].textContent).toBe("Bookmark with a very very long name that will be shortened");
|
|
|
|
expect(els[3].textContent).toBe("noname@conference.shakespeare.lit");
|
|
|
|
expect(els[4].textContent).toBe("The Play's the Thing");
|
|
|
|
|
|
|
|
spyOn(window, 'confirm').and.returnValue(true);
|
|
|
|
document.querySelector('#chatrooms .bookmarks.rooms-list .room-item:nth-child(2) a:nth-child(2)').click();
|
|
|
|
expect(window.confirm).toHaveBeenCalled();
|
|
|
|
await u.waitUntil(() => document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length === 4)
|
|
|
|
els = document.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item a.list-item-link');
|
|
|
|
expect(els[0].textContent).toBe("1st Bookmark");
|
|
|
|
expect(els[1].textContent).toBe("Bookmark with a very very long name that will be shortened");
|
|
|
|
expect(els[2].textContent).toBe("noname@conference.shakespeare.lit");
|
|
|
|
expect(els[3].textContent).toBe("The Play's the Thing");
|
2018-10-26 10:15:01 +02:00
|
|
|
done();
|
|
|
|
}));
|
|
|
|
|
2020-10-27 11:57:23 +01:00
|
|
|
it("can be used to open a MUC from a bookmark", mock.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
[], {'view_mode': 'fullscreen'}, async function (done, _converse) {
|
2020-10-27 11:57:23 +01:00
|
|
|
|
|
|
|
const api = _converse.api;
|
|
|
|
await mock.waitUntilDiscoConfirmed(
|
|
|
|
_converse, _converse.bare_jid,
|
|
|
|
[{'category': 'pubsub', 'type': 'pep'}],
|
|
|
|
['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
|
);
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-10-27 11:57:23 +01:00
|
|
|
await mock.openControlBox(_converse);
|
|
|
|
const view = await _converse.chatboxviews.get('controlbox');
|
|
|
|
const IQ_stanzas = _converse.connection.IQ_stanzas;
|
|
|
|
const sent_stanza = await u.waitUntil(
|
|
|
|
() => IQ_stanzas.filter(s => sizzle('items[node="storage:bookmarks"]', s).length).pop());
|
|
|
|
const stanza = $iq({'to': _converse.connection.jid, 'type':'result', 'id':sent_stanza.getAttribute('id')})
|
|
|
|
.c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
|
|
|
|
.c('items', {'node': 'storage:bookmarks'})
|
|
|
|
.c('item', {'id': 'current'})
|
|
|
|
.c('storage', {'xmlns': 'storage:bookmarks'})
|
|
|
|
.c('conference', {
|
|
|
|
'name': 'The Play's the Thing',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid': 'theplay@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC').up().up()
|
|
|
|
.c('conference', {
|
|
|
|
'name': '1st Bookmark',
|
|
|
|
'autojoin': 'false',
|
|
|
|
'jid': 'first@conference.shakespeare.lit'
|
|
|
|
}).c('nick').t('JC');
|
|
|
|
_converse.connection._dataRecv(mock.createRequest(stanza));
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length);
|
|
|
|
expect(view.querySelectorAll('#chatrooms div.bookmarks.rooms-list .room-item').length).toBe(2);
|
|
|
|
view.querySelector('.bookmarks.rooms-list .open-room').click();
|
2020-10-27 11:57:23 +01:00
|
|
|
await u.waitUntil(() => _converse.chatboxes.length === 2);
|
|
|
|
expect((await api.rooms.get('first@conference.shakespeare.lit')).get('hidden')).toBe(false);
|
|
|
|
|
2020-12-08 12:54:14 +01:00
|
|
|
await u.waitUntil(() => view.querySelectorAll('.list-container--bookmarks .available-chatroom:not(.hidden)').length === 1);
|
|
|
|
view.querySelector('.list-container--bookmarks .available-chatroom:not(.hidden) .open-room').click();
|
2020-10-27 11:57:23 +01:00
|
|
|
await u.waitUntil(() => _converse.chatboxes.length === 3);
|
|
|
|
expect((await api.rooms.get('first@conference.shakespeare.lit')).get('hidden')).toBe(true);
|
|
|
|
expect((await api.rooms.get('theplay@conference.shakespeare.lit')).get('hidden')).toBe(false);
|
|
|
|
|
2020-12-08 12:54:14 +01:00
|
|
|
view.querySelector('.list-container--openrooms .open-room:first-child').click();
|
|
|
|
await u.waitUntil(() => view.querySelector('.list-item.open').getAttribute('data-room-jid') === 'first@conference.shakespeare.lit');
|
2020-10-27 11:57:23 +01:00
|
|
|
expect((await api.rooms.get('first@conference.shakespeare.lit')).get('hidden')).toBe(false);
|
|
|
|
expect((await api.rooms.get('theplay@conference.shakespeare.lit')).get('hidden')).toBe(true);
|
|
|
|
done();
|
|
|
|
}));
|
2017-05-23 14:59:37 +02:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
it("remembers the toggle state of the bookmarks list", mock.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
[], {}, async function (done, _converse) {
|
2017-05-23 14:59:37 +02:00
|
|
|
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.openControlBox(_converse);
|
|
|
|
await mock.waitUntilDiscoConfirmed(
|
|
|
|
_converse, _converse.bare_jid,
|
|
|
|
[{'category': 'pubsub', 'type': 'pep'}],
|
|
|
|
['http://jabber.org/protocol/pubsub#publish-options']
|
|
|
|
);
|
2017-05-23 14:59:37 +02:00
|
|
|
|
2020-04-22 13:11:48 +02:00
|
|
|
const { Strophe, u, sizzle, $iq } = converse.env;
|
|
|
|
const IQ_stanzas = _converse.connection.IQ_stanzas;
|
|
|
|
const sent_stanza = await u.waitUntil(
|
|
|
|
() => IQ_stanzas.filter(s => sizzle('iq items[node="storage:bookmarks"]', s).length).pop());
|
|
|
|
|
|
|
|
expect(Strophe.serialize(sent_stanza)).toBe(
|
|
|
|
`<iq from="romeo@montague.lit/orchard" id="${sent_stanza.getAttribute('id')}" type="get" xmlns="jabber:client">`+
|
|
|
|
'<pubsub xmlns="http://jabber.org/protocol/pubsub">'+
|
|
|
|
'<items node="storage:bookmarks"/>'+
|
|
|
|
'</pubsub>'+
|
|
|
|
'</iq>'
|
|
|
|
);
|
|
|
|
const stanza = $iq({'to': _converse.connection.jid, 'type':'result', 'id': sent_stanza.getAttribute('id')})
|
|
|
|
.c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
|
|
|
|
.c('items', {'node': 'storage:bookmarks'})
|
|
|
|
.c('item', {'id': 'current'})
|
|
|
|
.c('storage', {'xmlns': 'storage:bookmarks'});
|
|
|
|
_converse.connection._dataRecv(mock.createRequest(stanza));
|
|
|
|
await _converse.api.waitUntil('bookmarksInitialized');
|
2018-11-22 12:15:35 +01:00
|
|
|
|
|
|
|
_converse.bookmarks.create({
|
2020-04-22 13:11:48 +02:00
|
|
|
'jid': 'theplay@conference.shakespeare.lit',
|
2018-11-22 12:15:35 +01:00
|
|
|
'autojoin': false,
|
|
|
|
'name': 'The Play',
|
2020-04-22 13:11:48 +02:00
|
|
|
'nick': ''
|
2018-02-07 17:30:44 +01:00
|
|
|
});
|
2021-01-26 09:58:16 +01:00
|
|
|
const chats_el = document.querySelector('converse-chats');
|
2020-04-22 13:11:48 +02:00
|
|
|
const selector = '#chatrooms .bookmarks.rooms-list .room-item';
|
2021-01-26 09:58:16 +01:00
|
|
|
await u.waitUntil(() => sizzle(selector, chats_el).filter(u.isVisible).length);
|
|
|
|
expect(u.hasClass('collapsed', sizzle('#chatrooms .bookmarks.rooms-list', chats_el).pop())).toBeFalsy();
|
|
|
|
expect(sizzle(selector, chats_el).filter(u.isVisible).length).toBe(1);
|
|
|
|
|
|
|
|
const bookmarks_el = chats_el.querySelector('converse-bookmarks');
|
|
|
|
expect(bookmarks_el.model.get('toggle-state')).toBe(_converse.OPENED);
|
|
|
|
sizzle('#chatrooms .bookmarks-toggle', chats_el).pop().click();
|
|
|
|
expect(u.hasClass('collapsed', sizzle('#chatrooms .bookmarks.rooms-list', chats_el).pop())).toBeTruthy();
|
|
|
|
expect(bookmarks_el.model.get('toggle-state')).toBe(_converse.CLOSED);
|
|
|
|
sizzle('#chatrooms .bookmarks-toggle', chats_el).pop().click();
|
|
|
|
expect(u.hasClass('collapsed', sizzle('#chatrooms .bookmarks.rooms-list', chats_el).pop())).toBeFalsy();
|
|
|
|
expect(sizzle(selector, chats_el).filter(u.isVisible).length).toBe(1);
|
|
|
|
expect(bookmarks_el.model.get('toggle-state')).toBe(_converse.OPENED);
|
2018-11-22 12:15:35 +01:00
|
|
|
done();
|
2017-05-23 14:59:37 +02:00
|
|
|
}));
|
|
|
|
});
|
2020-04-22 12:10:39 +02:00
|
|
|
});
|
2020-04-22 13:11:48 +02:00
|
|
|
|
|
|
|
describe("When hide_open_bookmarks is true and a bookmarked room is opened", function () {
|
|
|
|
|
|
|
|
it("can be closed", mock.initConverse(
|
2021-01-26 14:01:37 +01:00
|
|
|
[], { hide_open_bookmarks: true }, async function (done, _converse) {
|
2020-04-22 13:11:48 +02:00
|
|
|
|
2021-01-26 14:01:37 +01:00
|
|
|
await mock.waitForRoster(_converse, 'current', 0);
|
2020-04-22 13:11:48 +02:00
|
|
|
await mock.openControlBox(_converse);
|
|
|
|
await mock.waitUntilBookmarksReturned(_converse);
|
|
|
|
|
|
|
|
// Check that it's there
|
|
|
|
const jid = 'room@conference.example.org';
|
|
|
|
_converse.bookmarks.create({
|
|
|
|
'jid': jid,
|
|
|
|
'autojoin': false,
|
|
|
|
'name': 'The Play',
|
|
|
|
'nick': ' Othello'
|
|
|
|
});
|
|
|
|
expect(_converse.bookmarks.length).toBe(1);
|
|
|
|
|
|
|
|
const u = converse.env.utils;
|
2021-01-26 09:58:16 +01:00
|
|
|
const bookmarks_el = document.querySelector('converse-bookmarks');
|
|
|
|
await u.waitUntil(() => bookmarks_el.querySelectorAll(".open-room").length, 500);
|
|
|
|
const room_els = bookmarks_el.querySelectorAll(".open-room");
|
2020-04-22 13:11:48 +02:00
|
|
|
expect(room_els.length).toBe(1);
|
|
|
|
|
2021-01-26 09:58:16 +01:00
|
|
|
const bookmark = bookmarks_el.querySelector(".open-room");
|
2020-04-22 13:11:48 +02:00
|
|
|
bookmark.click();
|
|
|
|
await u.waitUntil(() => _converse.chatboxviews.get(jid));
|
|
|
|
|
2021-01-26 09:58:16 +01:00
|
|
|
expect(u.hasClass('hidden', bookmarks_el.querySelector(".available-chatroom"))).toBeTruthy();
|
2020-04-22 13:11:48 +02:00
|
|
|
// Check that it reappears once the room is closed
|
|
|
|
const view = _converse.chatboxviews.get(jid);
|
|
|
|
view.close();
|
2021-01-26 09:58:16 +01:00
|
|
|
await u.waitUntil(() => !u.hasClass('hidden', bookmarks_el.querySelector(".available-chatroom")));
|
2020-04-22 13:11:48 +02:00
|
|
|
done();
|
|
|
|
}));
|
|
|
|
});
|