Commit a15c9e54 authored by JC Brand's avatar JC Brand

Also test for when XEP-0363 is not supported

Updates #161
parent d73394fa
...@@ -7123,8 +7123,7 @@ body.reset { ...@@ -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; }
......
...@@ -7123,8 +7123,7 @@ body.reset { ...@@ -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; }
......
...@@ -440,7 +440,6 @@ body.reset { ...@@ -440,7 +440,6 @@ body.reset {
} }
&.converse-centered-form { &.converse-centered-form {
text-align: center; text-align: center;
width: 100%;
} }
} }
......
...@@ -172,6 +172,51 @@ ...@@ -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 () {
......
...@@ -334,9 +334,11 @@ ...@@ -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) => {
this.el.querySelector('.chat-toolbar').insertAdjacentHTML( if (result.length) {
'beforeend', this.el.querySelector('.chat-toolbar').insertAdjacentHTML(
tpl_toolbar_fileupload({'tooltip_upload_file': __('Choose a file to send')})); 'beforeend',
tpl_toolbar_fileupload({'tooltip_upload_file': __('Choose a file to send')}));
}
}); });
}, },
......
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