Commit af0093bd authored by JC Brand's avatar JC Brand

Bugfix: MUC invite form not shown

parent 5e0c320f
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
- Rudimentary support for XEP-0333 chat markers - Rudimentary support for XEP-0333 chat markers
- Better support for XEP-0359 `stanza-id` and `origin-id` elements. - Better support for XEP-0359 `stanza-id` and `origin-id` elements.
- Bugfix: restore textarea size after sending a message - Bugfix: restore textarea size after sending a message
- Bugfix: MUC invite form not appearing
- #1369 Don't wrongly interpret message with `subject` as a topic change. - #1369 Don't wrongly interpret message with `subject` as a topic change.
- #1405 Status of contacts list are not displayed properly - #1405 Status of contacts list are not displayed properly
- #1408 New config option `roomconfig_whitelist` - #1408 New config option `roomconfig_whitelist`
......
...@@ -55146,8 +55146,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins ...@@ -55146,8 +55146,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins
initialize() { initialize() {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments); Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
this.chatroomview = this.model.chatroomview; this.chatroomview = this.model.chatroomview;
this.chatroomview.model.on('change:open', this.renderInviteWidget, this);
this.chatroomview.model.on('change:affiliation', this.renderInviteWidget, this); this.chatroomview.model.on('change:affiliation', this.renderInviteWidget, this);
this.chatroomview.model.features.on('change:open', this.renderInviteWidget, this);
this.chatroomview.model.features.on('change', this.renderRoomFeatures, this); this.chatroomview.model.features.on('change', this.renderRoomFeatures, this);
this.render(); this.render();
this.model.fetch({ this.model.fetch({
...@@ -55251,7 +55251,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins ...@@ -55251,7 +55251,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins
}, },
shouldInviteWidgetBeShown() { shouldInviteWidgetBeShown() {
return _converse.allow_muc_invitations && (this.chatroomview.model.get('open') || this.chatroomview.model.get('affiliation') === "owner"); return _converse.allow_muc_invitations && (this.chatroomview.model.features.get('open') || this.chatroomview.model.get('affiliation') === "owner");
}, },
initInviteWidget() { initInviteWidget() {
...@@ -1725,20 +1725,31 @@ ...@@ -1725,20 +1725,31 @@
// cheat here and emit the event. // cheat here and emit the event.
_converse.emit('rosterContactsFetched'); _converse.emit('rosterContactsFetched');
await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy'); const features = [
spyOn(_converse, 'emit'); 'http://jabber.org/protocol/muc',
spyOn(window, 'prompt').and.callFake(function () { 'jabber:iq:register',
return "Please join!"; 'muc_passwordprotected',
}); 'muc_hidden',
'muc_temporary',
'muc_membersonly',
'muc_unmoderated',
'muc_anonymous'
]
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy', features);
spyOn(_converse, 'emit').and.callThrough();
spyOn(window, 'prompt').and.callFake(() => "Please join!");
const view = _converse.chatboxviews.get('lounge@localhost'); const view = _converse.chatboxviews.get('lounge@localhost');
const chat_area = view.el.querySelector('.chat-area');
// XXX: cheating a lttle bit, normally this'll be set after expect(view.model.get('affiliation')).toBe('owner');
// receiving the features for the groupchat. expect(view.model.features.get('open')).toBe(false);
view.model.set('open', 'true'); expect(view.el.querySelectorAll('input.invited-contact').length).toBe(1);
view.model.set('affiliation', 'member');
await test_utils.waitUntil(() => view.el.querySelectorAll('input.invited-contact').length === 0);
view.model.features.set('open', 'true');
spyOn(view.model, 'directInvite').and.callThrough(); spyOn(view.model, 'directInvite').and.callThrough();
const chat_area = view.el.querySelector('.chat-area');
chat_area.parentElement.removeChild(chat_area);
await test_utils.waitUntil(() => view.el.querySelectorAll('input.invited-contact').length); await test_utils.waitUntil(() => view.el.querySelectorAll('input.invited-contact').length);
const input = view.el.querySelector('input.invited-contact'); const input = view.el.querySelector('input.invited-contact');
expect(input.getAttribute('placeholder')).toBe('Invite'); expect(input.getAttribute('placeholder')).toBe('Invite');
...@@ -1755,22 +1766,19 @@ ...@@ -1755,22 +1766,19 @@
expect(hint.textContent).toBe('Felix Amsel'); expect(hint.textContent).toBe('Felix Amsel');
expect(input.nextSibling.childNodes.length).toBe(1); expect(input.nextSibling.childNodes.length).toBe(1);
if (typeof(Event) === 'function') { evt = new Event('mousedown', {'bubbles': true});
// Not working on PhantomJS evt.button = 0; // For some reason awesomplete wants this
evt = new Event('mousedown', {'bubbles': true}); hint.dispatchEvent(evt);
evt.button = 0; // For some reason awesomplete wants this expect(window.prompt).toHaveBeenCalled();
hint.dispatchEvent(evt); expect(view.model.directInvite).toHaveBeenCalled();
expect(window.prompt).toHaveBeenCalled(); expect(sent_stanza.toLocaleString()).toBe(
expect(view.model.directInvite).toHaveBeenCalled(); `<message from="dummy@localhost/resource" `+
expect(sent_stanza.toLocaleString()).toBe( `id="${sent_stanza.nodeTree.getAttribute("id")}" `+
`<message from="dummy@localhost/resource" `+ `to="felix.amsel@localhost" `+
`id="${sent_stanza.nodeTree.getAttribute("id")}" `+ `xmlns="jabber:client">`+
`to="felix.amsel@localhost" `+ `<x jid="lounge@localhost" reason="Please join!" xmlns="jabber:x:conference"/>`+
`xmlns="jabber:client">`+ `</message>`
`<x jid="lounge@localhost" reason="Please join!" xmlns="jabber:x:conference"/>`+ );
`</message>`
);
}
done(); done();
})); }));
......
...@@ -1849,8 +1849,8 @@ converse.plugins.add('converse-muc-views', { ...@@ -1849,8 +1849,8 @@ converse.plugins.add('converse-muc-views', {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments); Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
this.chatroomview = this.model.chatroomview; this.chatroomview = this.model.chatroomview;
this.chatroomview.model.on('change:open', this.renderInviteWidget, this);
this.chatroomview.model.on('change:affiliation', this.renderInviteWidget, this); this.chatroomview.model.on('change:affiliation', this.renderInviteWidget, this);
this.chatroomview.model.features.on('change:open', this.renderInviteWidget, this);
this.chatroomview.model.features.on('change', this.renderRoomFeatures, this); this.chatroomview.model.features.on('change', this.renderRoomFeatures, this);
this.render(); this.render();
...@@ -1955,7 +1955,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1955,7 +1955,7 @@ converse.plugins.add('converse-muc-views', {
shouldInviteWidgetBeShown () { shouldInviteWidgetBeShown () {
return _converse.allow_muc_invitations && return _converse.allow_muc_invitations &&
(this.chatroomview.model.get('open') || (this.chatroomview.model.features.get('open') ||
this.chatroomview.model.get('affiliation') === "owner" this.chatroomview.model.get('affiliation') === "owner"
); );
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment