Bugfix: MUC invite form not shown

This commit is contained in:
JC Brand 2019-02-18 15:23:26 +01:00
parent 5e0c320fb1
commit af0093bd39
4 changed files with 41 additions and 32 deletions

View File

@ -9,6 +9,7 @@
- Rudimentary support for XEP-0333 chat markers
- Better support for XEP-0359 `stanza-id` and `origin-id` elements.
- 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.
- #1405 Status of contacts list are not displayed properly
- #1408 New config option `roomconfig_whitelist`

4
dist/converse.js vendored
View File

@ -55146,8 +55146,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins
initialize() {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
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.features.on('change:open', this.renderInviteWidget, this);
this.chatroomview.model.features.on('change', this.renderRoomFeatures, this);
this.render();
this.model.fetch({
@ -55251,7 +55251,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins
},
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() {

View File

@ -1725,20 +1725,31 @@
// cheat here and emit the event.
_converse.emit('rosterContactsFetched');
await test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
spyOn(_converse, 'emit');
spyOn(window, 'prompt').and.callFake(function () {
return "Please join!";
});
const features = [
'http://jabber.org/protocol/muc',
'jabber:iq:register',
'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');
// XXX: cheating a lttle bit, normally this'll be set after
// receiving the features for the groupchat.
view.model.set('open', 'true');
spyOn(view.model, 'directInvite').and.callThrough();
const chat_area = view.el.querySelector('.chat-area');
chat_area.parentElement.removeChild(chat_area);
expect(view.model.get('affiliation')).toBe('owner');
expect(view.model.features.get('open')).toBe(false);
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();
await test_utils.waitUntil(() => view.el.querySelectorAll('input.invited-contact').length);
const input = view.el.querySelector('input.invited-contact');
expect(input.getAttribute('placeholder')).toBe('Invite');
@ -1755,22 +1766,19 @@
expect(hint.textContent).toBe('Felix Amsel');
expect(input.nextSibling.childNodes.length).toBe(1);
if (typeof(Event) === 'function') {
// Not working on PhantomJS
evt = new Event('mousedown', {'bubbles': true});
evt.button = 0; // For some reason awesomplete wants this
hint.dispatchEvent(evt);
expect(window.prompt).toHaveBeenCalled();
expect(view.model.directInvite).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe(
`<message from="dummy@localhost/resource" `+
`id="${sent_stanza.nodeTree.getAttribute("id")}" `+
`to="felix.amsel@localhost" `+
`xmlns="jabber:client">`+
`<x jid="lounge@localhost" reason="Please join!" xmlns="jabber:x:conference"/>`+
`</message>`
);
}
evt = new Event('mousedown', {'bubbles': true});
evt.button = 0; // For some reason awesomplete wants this
hint.dispatchEvent(evt);
expect(window.prompt).toHaveBeenCalled();
expect(view.model.directInvite).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe(
`<message from="dummy@localhost/resource" `+
`id="${sent_stanza.nodeTree.getAttribute("id")}" `+
`to="felix.amsel@localhost" `+
`xmlns="jabber:client">`+
`<x jid="lounge@localhost" reason="Please join!" xmlns="jabber:x:conference"/>`+
`</message>`
);
done();
}));

View File

@ -1849,8 +1849,8 @@ converse.plugins.add('converse-muc-views', {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
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.features.on('change:open', this.renderInviteWidget, this);
this.chatroomview.model.features.on('change', this.renderRoomFeatures, this);
this.render();
@ -1955,7 +1955,7 @@ converse.plugins.add('converse-muc-views', {
shouldInviteWidgetBeShown () {
return _converse.allow_muc_invitations &&
(this.chatroomview.model.get('open') ||
(this.chatroomview.model.features.get('open') ||
this.chatroomview.model.get('affiliation') === "owner"
);
},