Commit 876a07b3 authored by JC Brand's avatar JC Brand

Fix the failing tests

parent 1405d9cb
......@@ -8360,7 +8360,7 @@ body.reset {
color: #3AA569;
font-size: 14px;
line-height: 14px;
padding: 0.5rem 1rem; }
padding: 0.35rem 1rem; }
#conversejs .message.chat-info.badge {
color: white; }
#conversejs .message.chat-info.chat-state-notification {
......@@ -8408,9 +8408,13 @@ body.reset {
margin-left: 0; }
#conversejs .message.chat-msg .chat-msg-text {
padding: 0;
color: #666; }
color: #666;
word-wrap: break-word;
word-break: break-all; }
#conversejs .message.chat-msg .chat-msg-text .emojione {
margin-bottom: -6px; }
#conversejs .message.chat-msg .chat-msg-media audio {
width: 100%; }
#conversejs .message.chat-msg .avatar {
margin-top: 0.5em;
background: #818479;
......@@ -8425,7 +8429,8 @@ body.reset {
#conversejs .message.chat-msg .chat-msg-heading .chat-msg-author {
font-weight: bold; }
#conversejs .message.chat-msg .chat-msg-heading .chat-msg-time {
padding-left: 0.5em; }
padding-left: 0.25em;
color: #9d9d9d; }
#conversejs .message.chat-msg.chat-action .chat-msg-heading {
margin-top: 0; }
#conversejs .message.chat-msg.chat-msg-followup {
......
......@@ -8548,7 +8548,7 @@ body {
color: #3AA569;
font-size: 14px;
line-height: 20px;
padding: 0.5rem 1rem; }
padding: 0.35rem 1rem; }
#conversejs .message.chat-info.badge {
color: white; }
#conversejs .message.chat-info.chat-state-notification {
......@@ -8596,9 +8596,13 @@ body {
margin-left: 0; }
#conversejs .message.chat-msg .chat-msg-text {
padding: 0;
color: #666; }
color: #666;
word-wrap: break-word;
word-break: break-all; }
#conversejs .message.chat-msg .chat-msg-text .emojione {
margin-bottom: -6px; }
#conversejs .message.chat-msg .chat-msg-media audio {
width: 100%; }
#conversejs .message.chat-msg .avatar {
margin-top: 0.5em;
background: #818479;
......@@ -8613,7 +8617,8 @@ body {
#conversejs .message.chat-msg .chat-msg-heading .chat-msg-author {
font-weight: bold; }
#conversejs .message.chat-msg .chat-msg-heading .chat-msg-time {
padding-left: 0.5em; }
padding-left: 0.25em;
color: #9d9d9d; }
#conversejs .message.chat-msg.chat-action .chat-msg-heading {
margin-top: 0; }
#conversejs .message.chat-msg.chat-msg-followup {
......
......@@ -46,11 +46,11 @@
<div class="chat-msg-content">
<span class="chat-msg-heading">
<span class="chat-msg-author">Romeo Montague</span>
<span class="chat-msg-time text-muted">15:31</span>
<span class="chat-msg-time">15:31</span>
</span>
<p class="chat-msg-text">
<span class="chat-msg-text">
He jests at scars that never felt a wound.
</p>
</span>
</div>
</div>
......@@ -64,11 +64,11 @@
<div class="chat-msg-content">
<span class="chat-msg-heading">
<span class="chat-msg-author">Romeo Montague</span>
<span class="chat-msg-time text-muted">15:31</span>
<span class="chat-msg-time">15:31</span>
</span>
<p class="chat-msg-text">
<span class="chat-msg-text">
But soft, what light through yonder window breaks?
</p>
</span>
</div>
</div>
......@@ -77,11 +77,11 @@
<div class="chat-msg-content">
<span class="chat-msg-heading">
<span class="chat-msg-author">Romeo Montague</span>
<span class="chat-msg-time text-muted">15:31</span>
<span class="chat-msg-time">15:31</span>
</span>
<p class="chat-msg-text">
<span class="chat-msg-text">
It is the east and Juliet is the sun!
</p>
</span>
</div>
</div>
......@@ -90,11 +90,11 @@
<div class="chat-msg-content">
<span class="chat-msg-heading">
<span class="chat-msg-author">Romeo Montague</span>
<span class="chat-msg-time text-muted">15:31</span>
<span class="chat-msg-time">15:31</span>
</span>
<p class="chat-msg-text">
<span class="chat-msg-text">
Arise, fair sun, and kill the envious moon,
</p>
</span>
</div>
</div>
......@@ -105,14 +105,14 @@
<div class="chat-msg-content">
<span class="chat-msg-heading">
<span class="chat-msg-author">Juliet Capulet</span>
<span class="chat-msg-time text-muted">15:31</span>
<span class="chat-msg-time">15:31</span>
</span>
<p class="chat-msg-text">
<span class="chat-msg-text">
O Romeo, Romeo! wherefore art thou Romeo?
Deny thy father and refuse thy name;
Or, if thou wilt not, be but sworn my love,
And I'll no longer be a Capulet.
</p>
</span>
</div>
</div>
</div>
......
This diff is collapsed.
......@@ -32,7 +32,7 @@
color: $chat-head-color;
font-size: $message-font-size;
line-height: $line-height-small;
padding: 0.5rem 1rem;
padding: 0.35rem 1rem;
&.badge {
color: $chat-head-text-color;
......@@ -105,11 +105,20 @@
.chat-msg-text {
padding: 0;
color: $message-text-color;
word-wrap: break-word;
word-break: break-all;
.emojione {
margin-bottom: -6px;
}
}
.chat-msg-media {
audio {
width: 100%;
}
}
.avatar {
margin-top: 0.5em;
background: $gray-color;
......@@ -127,7 +136,8 @@
font-weight: bold;
}
.chat-msg-time {
padding-left: 0.5em;
padding-left: 0.25em;
color: lighten($text-color, 15%);
}
}
&.chat-action {
......
This diff is collapsed.
......@@ -619,11 +619,11 @@
var view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
var chat_content = view.el.querySelector('.chat-content');
var $chat_content = $(chat_content);
var time = chat_content.querySelector('time');
expect(time).not.toBe(null);
expect(time.getAttribute('class')).toEqual('message chat-info chat-date badge badge-info');
expect(time.getAttribute('data-isodate')).toEqual(moment().startOf('day').format());
expect(time.textContent).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
var indicator = chat_content.querySelector('.date-separator');
expect(indicator).not.toBe(null);
expect(indicator.getAttribute('class')).toEqual('message date-separator');
expect(indicator.getAttribute('data-isodate')).toEqual(moment().startOf('day').format());
expect(indicator.querySelector('time').textContent).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
expect(chat_content.querySelectorAll('div.chat-info').length).toBe(1);
expect(chat_content.querySelector('div.chat-info').textContent).toBe(
"dummy has entered the room"
......@@ -654,11 +654,13 @@
});
_converse.connection._dataRecv(test_utils.createRequest(presence));
time = chat_content.querySelector('time[data-isodate="'+moment().startOf('day').format()+'"]');
expect(time).not.toBe(null);
expect(time.getAttribute('class')).toEqual('message chat-info chat-date badge badge-info');
expect(time.getAttribute('data-isodate')).toEqual(moment().startOf('day').format());
expect(time.textContent).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
indicator = chat_content.querySelector('.date-separator[data-isodate="'+moment().startOf('day').format()+'"]');
expect(indicator).not.toBe(null);
expect(indicator.getAttribute('class')).toEqual('message date-separator');
expect(indicator.getAttribute('data-isodate')).toEqual(moment().startOf('day').format());
expect(indicator.querySelector('time').getAttribute('class')).toEqual('separator-text');
expect(indicator.querySelector('time').textContent).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
expect(chat_content.querySelector('div.chat-info:last-child').textContent).toBe(
"some1 has entered the room"
);
......@@ -680,11 +682,13 @@
});
_converse.connection._dataRecv(test_utils.createRequest(presence));
time = chat_content.querySelector('time[data-isodate="'+moment().startOf('day').format()+'"]');
expect(time).not.toBe(null);
expect(time.getAttribute('class')).toEqual('message chat-info chat-date badge badge-info');
expect(time.getAttribute('data-isodate')).toEqual(moment().startOf('day').format());
expect(time.textContent).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
indicator = chat_content.querySelector('.date-separator[data-isodate="'+moment().startOf('day').format()+'"]');
expect(indicator).not.toBe(null);
expect(indicator.getAttribute('class')).toEqual('message date-separator');
expect(indicator.getAttribute('data-isodate')).toEqual(moment().startOf('day').format());
expect(indicator.querySelector('time').textContent).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
expect($(chat_content).find('div.chat-info').length).toBe(4);
expect($(chat_content).find('div.chat-info:last').html()).toBe(
'some1 has left the room. '+
......@@ -716,10 +720,10 @@
var $time = $chat_content.find('time');
expect($time.length).toEqual(4);
$time = $chat_content.find('time:eq(3)');
expect($time.attr('class')).toEqual('message chat-info chat-date badge badge-info');
expect($time.data('isodate')).toEqual(moment().startOf('day').format());
expect($time.text()).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
var $indicator = $chat_content.find('.date-separator:eq(3)');
expect($indicator.attr('class')).toEqual('message date-separator');
expect($indicator.data('isodate')).toEqual(moment().startOf('day').format());
expect($indicator.find('time').text()).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
expect($chat_content.find('div.chat-info').length).toBe(5);
expect($chat_content.find('div.chat-info:last').html()).toBe("newguy has entered the room");
......@@ -755,10 +759,11 @@
$time = $chat_content.find('time');
expect($time.length).toEqual(6);
$time = $chat_content.find('time:eq(5)');
expect($time.attr('class')).toEqual('message chat-info chat-date badge badge-info');
expect($time.data('isodate')).toEqual(moment().startOf('day').format());
expect($time.text()).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
$indicator = $chat_content.find('.date-separator:eq(5)');
expect($indicator.attr('class')).toEqual('message date-separator');
expect($indicator.data('isodate')).toEqual(moment().startOf('day').format());
expect($indicator.find('time').text()).toEqual(moment().startOf('day').format("dddd MMM Do YYYY"));
expect($chat_content.find('div.chat-info').length).toBe(6);
expect($chat_content.find('div.chat-info:last').html()).toBe(
'newguy has left the room. '+
......@@ -2298,7 +2303,7 @@
.c('status', {'code': '307'});
_converse.connection._dataRecv(test_utils.createRequest(presence));
expect(
view.el.querySelectorAll('.chat-info')[3].textContent).toBe(
view.el.querySelectorAll('.chat-info')[2].textContent).toBe(
"annoyingGuy has been kicked out");
done();
}).catch(_.partial(console.error, _));
......
......@@ -5,9 +5,9 @@
<div class="chat-msg-content">
<span class="chat-msg-heading">
<span class="chat-msg-author">{{{o.username}}}</span>
<span class="chat-msg-time tex{{{o.username}}}t-muted">{{{o.pretty_time}}}</span>
<span class="chat-msg-time">{{{o.pretty_time}}}</span>
</span>
<p class="chat-msg-text">
<span class="chat-msg-text"></span>
<div class="chat-msg-media"></div>
</div>
</div>
<div class="message date-separator">
<div class="message date-separator" data-isodate="{{{o.isodate}}}">
<hr class="separator">
<time class="separator-text" datetime="{{{o.isodate}}}"><span>{{{o.datestring}}}</span></time>
</div>
......@@ -3,7 +3,7 @@
<div class="chat-msg-content">
<span class="chat-msg-heading">
<span class="chat-msg-author">{{{o.username}}}</span>
<span class="chat-msg-time text-muted">{{{o.pretty_time}}}</span>
<span class="chat-msg-time">{{{o.pretty_time}}}</span>
</span>
<div>
<span class="spoiler-hint">{{{o.spoiler_hint}}}</span>
......
......@@ -66,18 +66,6 @@
'warn': _.get(console, 'log') ? console.log.bind(console) : _.noop
}, console);
var unescapeHTML = function (htmlEscapedText) {
/* Helper method that replace HTML-escaped symbols with equivalent characters
* (e.g. transform occurrences of '&amp;' to '&')
*
* Parameters:
* (String) htmlEscapedText: a String containing the HTML-escaped symbols.
*/
var div = document.createElement('div');
div.innerHTML = htmlEscapedText;
return div.innerText;
};
var isImage = function (url) {
return new Promise((resolve, reject) => {
var img = new Image();
......@@ -200,6 +188,18 @@
return matches;
}
u.unescapeHTML = function (htmlEscapedText) {
/* Helper method that replace HTML-escaped symbols with equivalent characters
* (e.g. transform occurrences of '&amp;' to '&')
*
* Parameters:
* (String) htmlEscapedText: a String containing the HTML-escaped symbols.
*/
var div = document.createElement('div');
div.innerHTML = htmlEscapedText;
return div.innerText;
};
u.escapeHTML = function (string) {
return string
.replace(/&/g, "&amp;")
......@@ -212,7 +212,11 @@
return URI.withinString(text, function (url) {
var uri = new URI(url);
uri.normalize();
return `<a href="${u.escapeHTML(url)}">${u.escapeHTML(uri.readable())}</a>`;
if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = 'http://' + url;
}
url = encodeURI(decodeURI(url)).replace(/[!'()]/g, escape).replace(/\*/g, "%2A");
return `<a target="_blank" rel="noopener" href="${u.escapeHTML(url)}">${u.escapeHTML(uri.readable())}</a>`;
});
};
......@@ -233,9 +237,9 @@
i.addEventListener('error', resolve);
_.each(sizzle(`a[href="${url}"]`, obj), (a) => {
a.innerHTML = tpl_image({
a.outerHTML= tpl_image({
'url': url,
'label_download': __('Download image file')
'label_download': __('Download')
})
});
}).catch(resolve)
......@@ -268,7 +272,7 @@
return tpl_image({
'url': url,
'label_download': __('Download image file')
'label_download': __('Download')
})
}
return url;
......
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