Also test for when XEP-0363 is not supported

Updates #161
This commit is contained in:
JC Brand 2018-04-22 17:47:34 +02:00
parent d73394fa37
commit a15c9e54d0
5 changed files with 52 additions and 8 deletions

View File

@ -7123,8 +7123,7 @@ body.reset {
#conversejs form.converse-form .text-muted.error { #conversejs form.converse-form .text-muted.error {
color: #A53214; } color: #A53214; }
#conversejs form.converse-centered-form { #conversejs form.converse-centered-form {
text-align: center; text-align: center; }
width: 100%; }
#conversejs .chat-textarea-chatbox-selected { #conversejs .chat-textarea-chatbox-selected {
border: 1px solid #578308; border: 1px solid #578308;
margin: 0; } margin: 0; }

View File

@ -7123,8 +7123,7 @@ body.reset {
#conversejs form.converse-form .text-muted.error { #conversejs form.converse-form .text-muted.error {
color: #A53214; } color: #A53214; }
#conversejs form.converse-centered-form { #conversejs form.converse-centered-form {
text-align: center; text-align: center; }
width: 100%; }
#conversejs .chat-textarea-chatbox-selected { #conversejs .chat-textarea-chatbox-selected {
border: 1px solid #578308; border: 1px solid #578308;
margin: 0; } margin: 0; }

View File

@ -440,7 +440,6 @@ body.reset {
} }
&.converse-centered-form { &.converse-centered-form {
text-align: center; text-align: center;
width: 100%;
} }
} }

View File

@ -172,6 +172,51 @@
})); }));
}); });
describe("When not supported", function () {
describe("A file upload toolbar button", function () {
it("does not appear in private chats", mock.initConverseWithAsync(function (done, _converse) {
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
test_utils.createContacts(_converse, 'current');
test_utils.openChatBoxFor(_converse, contact_jid);
test_utils.waitUntilDiscoConfirmed(
_converse, _converse.domain,
[{'category': 'server', 'type':'IM'}],
['http://jabber.org/protocol/disco#items'], [], 'info').then(function () {
test_utils.waitUntilDiscoConfirmed(_converse, _converse.domain, [], [], [], 'items').then(function () {
var view = _converse.chatboxviews.get(contact_jid);
expect(view.el.querySelector('.chat-toolbar .upload-file')).toBe(null);
done();
});
});
}));
it("does not appear in MUC chats", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
test_utils.waitUntilDiscoConfirmed(
_converse, _converse.domain,
[{'category': 'server', 'type':'IM'}],
['http://jabber.org/protocol/disco#items'], [], 'info').then(function () {
test_utils.waitUntilDiscoConfirmed(_converse, _converse.domain, [], [], ['upload.localhost'], 'items').then(function () {
test_utils.waitUntilDiscoConfirmed(_converse, 'upload.localhost', [], [Strophe.NS.HTTPUPLOAD], []).then(function () {
var view = _converse.chatboxviews.get('lounge@localhost');
expect(view.el.querySelector('.chat-toolbar .upload-file')).toBe(null);
done();
});
});
});
});
}));
});
});
describe("When supported", function () { describe("When supported", function () {
describe("A file upload toolbar button", function () { describe("A file upload toolbar button", function () {

View File

@ -334,9 +334,11 @@
addFileUploadButton (options) { addFileUploadButton (options) {
_converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain).then((result) => { _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain).then((result) => {
if (result.length) {
this.el.querySelector('.chat-toolbar').insertAdjacentHTML( this.el.querySelector('.chat-toolbar').insertAdjacentHTML(
'beforeend', 'beforeend',
tpl_toolbar_fileupload({'tooltip_upload_file': __('Choose a file to send')})); tpl_toolbar_fileupload({'tooltip_upload_file': __('Choose a file to send')}));
}
}); });
}, },