Commit f3f58a8d authored by JC Brand's avatar JC Brand

Test multiple corrections of the same message

parent 9e965fa2
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
If the device is trusted, localStorage is used and user data is cached indefinitely. If the device is trusted, localStorage is used and user data is cached indefinitely.
- Initial support for XEP-0357 Push Notifications, specifically registering an "App Server". - Initial support for XEP-0357 Push Notifications, specifically registering an "App Server".
- Add support for logging in via OAuth (see the [oauth_providers](https://conversejs.org/docs/html/configurations.html#oauth-providers) setting) - Add support for logging in via OAuth (see the [oauth_providers](https://conversejs.org/docs/html/configurations.html#oauth-providers) setting)
- XEP-0308: Render message corrections
### Bugfixes ### Bugfixes
......
...@@ -74531,6 +74531,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -74531,6 +74531,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.model.on('change:progress', this.renderFileUploadProgresBar, this); this.model.on('change:progress', this.renderFileUploadProgresBar, this);
this.model.on('change:type', this.render, this); this.model.on('change:type', this.render, this);
this.model.on('change:upload', this.render, this); this.model.on('change:upload', this.render, this);
this.model.on('change:message', this.render, this);
this.model.on('destroy', this.remove, this); this.model.on('destroy', this.remove, this);
this.render(); this.render();
}, },
...@@ -74665,13 +74666,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -74665,13 +74666,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
showMessageVersionsModal(ev) { showMessageVersionsModal(ev) {
ev.preventDefault(); ev.preventDefault();
if (_.isUndefined(this.message_versions_modal)) { if (_.isUndefined(this.model.message_versions_modal)) {
this.message_versions_modal = new _converse.MessageVersionsModal({ this.model.message_versions_modal = new _converse.MessageVersionsModal({
'model': this.model 'model': this.model
}); });
} }
this.message_versions_modal.show(ev); this.model.message_versions_modal.show(ev);
}, },
isMeCommand() { isMeCommand() {
...@@ -85616,7 +85617,7 @@ __e(o.__('Message versions')) + ...@@ -85616,7 +85617,7 @@ __e(o.__('Message versions')) +
__e(o.label_close) + __e(o.label_close) +
'"><span aria-hidden="true">&times;</span></button>\n </div>\n <div class="modal-body">\n <h4>Older versions</h4>\n '; '"><span aria-hidden="true">&times;</span></button>\n </div>\n <div class="modal-body">\n <h4>Older versions</h4>\n ';
o.older_versions.forEach(function (text) { ; o.older_versions.forEach(function (text) { ;
__p += ' <p>' + __p += ' <p class="older-msg">' +
__e(text) + __e(text) +
'</p> '; '</p> ';
}); ; }); ;
...@@ -3182,9 +3182,8 @@ ...@@ -3182,9 +3182,8 @@
roomspanel.el.querySelector('.show-add-muc-modal').click(); roomspanel.el.querySelector('.show-add-muc-modal').click();
test_utils.closeControlBox(_converse); test_utils.closeControlBox(_converse);
const modal = roomspanel.add_room_modal; const modal = roomspanel.add_room_modal;
test_utils.waitUntil(function () { test_utils.waitUntil(() => u.isVisible(modal.el), 1000)
return u.isVisible(modal.el); .then(function () {
}, 1000).then(function () {
spyOn(_converse.ChatRoom.prototype, 'getRoomFeatures').and.callFake(function () { spyOn(_converse.ChatRoom.prototype, 'getRoomFeatures').and.callFake(function () {
var deferred = new $.Deferred(); var deferred = new $.Deferred();
deferred.resolve(); deferred.resolve();
......
...@@ -100,14 +100,37 @@ ...@@ -100,14 +100,37 @@
'to': _converse.connection.jid, 'to': _converse.connection.jid,
'type': 'chat', 'type': 'chat',
'id': u.getUniqueId(), 'id': u.getUniqueId(),
}).c('body').t('But soft, what light through yonder window breaks?').up() }).c('body').t('But soft, what light through yonder chimney breaks?').up()
.c('replace', {'id': msg_id, 'xmlns': 'urn:xmpp:message-correct:0'}).tree()); .c('replace', {'id': msg_id, 'xmlns': 'urn:xmpp:message-correct:0'}).tree());
expect(chatboxview.el.querySelectorAll('.chat-msg').length).toBe(1);
test_utils.waitUntil(() => chatboxview.el.querySelector('.chat-msg-text').textContent === test_utils.waitUntil(() => chatboxview.el.querySelector('.chat-msg-text').textContent ===
'But soft, what light through yonder window breaks?').then(() => { 'But soft, what light through yonder chimney breaks?').then(() => {
expect(chatboxview.el.querySelectorAll('.chat-msg').length).toBe(1);
expect(chatboxview.el.querySelectorAll('.chat-msg-content .fa-edit').length).toBe(1);
_converse.chatboxes.onMessage($msg({
'from': sender_jid,
'to': _converse.connection.jid,
'type': 'chat',
'id': u.getUniqueId(),
}).c('body').t('But soft, what light through yonder window breaks?').up()
.c('replace', {'id': msg_id, 'xmlns': 'urn:xmpp:message-correct:0'}).tree());
return test_utils.waitUntil(() => chatboxview.el.querySelector('.chat-msg-text').textContent ===
'But soft, what light through yonder window breaks?');
}).then(() => {
expect(chatboxview.el.querySelectorAll('.chat-msg').length).toBe(1);
expect(chatboxview.el.querySelectorAll('.chat-msg-content .fa-edit').length).toBe(1); expect(chatboxview.el.querySelectorAll('.chat-msg-content .fa-edit').length).toBe(1);
chatboxview.el.querySelector('.chat-msg-content .fa-edit').click();
const modal = chatboxview.model.messages.at(0).message_versions_modal;
return test_utils.waitUntil(() => u.isVisible(modal.el), 1000);
}).then(() => {
const modal = chatboxview.model.messages.at(0).message_versions_modal;
const older_msgs = modal.el.querySelectorAll('.older-msg');
expect(older_msgs.length).toBe(2);
expect(older_msgs[0].textContent).toBe('But soft, what light through yonder airlock breaks?');
expect(older_msgs[1].textContent).toBe('But soft, what light through yonder chimney breaks?');
done(); done();
}); });
})); }));
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
this.model.on('change:progress', this.renderFileUploadProgresBar, this); this.model.on('change:progress', this.renderFileUploadProgresBar, this);
this.model.on('change:type', this.render, this); this.model.on('change:type', this.render, this);
this.model.on('change:upload', this.render, this); this.model.on('change:upload', this.render, this);
this.model.on('change:message', this.render, this);
this.model.on('destroy', this.remove, this); this.model.on('destroy', this.remove, this);
this.render(); this.render();
}, },
...@@ -232,10 +233,10 @@ ...@@ -232,10 +233,10 @@
showMessageVersionsModal (ev) { showMessageVersionsModal (ev) {
ev.preventDefault(); ev.preventDefault();
if (_.isUndefined(this.message_versions_modal)) { if (_.isUndefined(this.model.message_versions_modal)) {
this.message_versions_modal = new _converse.MessageVersionsModal({'model': this.model}); this.model.message_versions_modal = new _converse.MessageVersionsModal({'model': this.model});
} }
this.message_versions_modal.show(ev); this.model.message_versions_modal.show(ev);
}, },
isMeCommand () { isMeCommand () {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<h4>Older versions</h4> <h4>Older versions</h4>
{[o.older_versions.forEach(function (text) { ]} <p>{{{text}}}</p> {[ }); ]} {[o.older_versions.forEach(function (text) { ]} <p class="older-msg">{{{text}}}</p> {[ }); ]}
<hr> <hr>
<h4>Current version</h4> <h4>Current version</h4>
<p>{{{o.message}}}</p> <p>{{{o.message}}}</p>
......
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