Commit 88e74975 authored by JC Brand's avatar JC Brand

Fix failing tests due to avatar changes

parent 35057505
......@@ -2642,56 +2642,55 @@
it("takes /topic to set the groupchat topic",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
async function (done, _converse) {
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy').then(function () {
var sent_stanza;
var view = _converse.chatboxviews.get('lounge@localhost');
spyOn(view, 'onMessageSubmitted').and.callThrough();
spyOn(view, 'clearMessages');
spyOn(_converse.connection, 'send').and.callFake(function (stanza) {
sent_stanza = stanza;
});
// Check the alias /topic
var textarea = view.el.querySelector('.chat-textarea');
textarea.value = '/topic This is the groupchat subject';
view.keyPressed({
target: textarea,
preventDefault: _.noop,
keyCode: 13
});
expect(view.onMessageSubmitted).toHaveBeenCalled();
expect(_converse.connection.send).toHaveBeenCalled();
expect(sent_stanza.textContent).toBe('This is the groupchat subject');
await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
const view = _converse.chatboxviews.get('lounge@localhost');
spyOn(view, 'onMessageSubmitted').and.callThrough();
spyOn(view, 'clearMessages');
let sent_stanza;
spyOn(_converse.connection, 'send').and.callFake(function (stanza) {
sent_stanza = stanza;
});
// Check the alias /topic
const textarea = view.el.querySelector('.chat-textarea');
textarea.value = '/topic This is the groupchat subject';
view.keyPressed({
target: textarea,
preventDefault: _.noop,
keyCode: 13
});
expect(view.onMessageSubmitted).toHaveBeenCalled();
expect(_converse.connection.send).toHaveBeenCalled();
expect(sent_stanza.textContent).toBe('This is the groupchat subject');
// Check /subject
textarea.value = '/subject This is a new subject';
view.keyPressed({
target: textarea,
preventDefault: _.noop,
keyCode: 13
});
// Check /subject
textarea.value = '/subject This is a new subject';
view.keyPressed({
target: textarea,
preventDefault: _.noop,
keyCode: 13
});
expect(sent_stanza.textContent).toBe('This is a new subject');
expect(Strophe.serialize(sent_stanza).toLocaleString()).toBe(
'<message from="dummy@localhost/resource" to="lounge@localhost" type="groupchat" xmlns="jabber:client">'+
'<subject xmlns="jabber:client">This is a new subject</subject>'+
'</message>');
expect(sent_stanza.textContent).toBe('This is a new subject');
expect(Strophe.serialize(sent_stanza).toLocaleString()).toBe(
'<message from="dummy@localhost/resource" to="lounge@localhost" type="groupchat" xmlns="jabber:client">'+
'<subject xmlns="jabber:client">This is a new subject</subject>'+
'</message>');
// Check case insensitivity
textarea.value = '/Subject This is yet another subject';
view.keyPressed({
target: textarea,
preventDefault: _.noop,
keyCode: 13
});
expect(sent_stanza.textContent).toBe('This is yet another subject');
expect(Strophe.serialize(sent_stanza).toLocaleString()).toBe(
'<message from="dummy@localhost/resource" to="lounge@localhost" type="groupchat" xmlns="jabber:client">'+
'<subject xmlns="jabber:client">This is yet another subject</subject>'+
'</message>');
done();
}).catch(_.partial(console.error, _));
// Check case insensitivity
textarea.value = '/Subject This is yet another subject';
view.keyPressed({
target: textarea,
preventDefault: _.noop,
keyCode: 13
});
expect(sent_stanza.textContent).toBe('This is yet another subject');
expect(Strophe.serialize(sent_stanza).toLocaleString()).toBe(
'<message from="dummy@localhost/resource" to="lounge@localhost" type="groupchat" xmlns="jabber:client">'+
'<subject xmlns="jabber:client">This is yet another subject</subject>'+
'</message>');
done();
}));
it("takes /clear to clear messages",
......
......@@ -505,9 +505,10 @@
it("can be a carbon message, as defined in XEP-0280",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
async function (done, _converse) {
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
async function (done, _converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
......@@ -549,7 +550,6 @@
expect(chat_content.querySelector('.chat-msg .chat-msg__text').textContent).toEqual(msgtext);
expect(chat_content.querySelector('.chat-msg__time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
await test_utils.waitUntil(() => chatbox.vcard.get('fullname') === 'Candice van der Knijff')
await new Promise((resolve, reject) => view.model.messages.once('rendered', resolve));
expect(chat_content.querySelector('span.chat-msg__author').textContent.trim()).toBe('Candice van der Knijff');
done();
}));
......@@ -2154,7 +2154,6 @@
target: textarea,
keyCode: 38 // Up arrow
});
await new Promise((resolve, reject) => view.model.messages.once('rendered', resolve));
expect(textarea.value).toBe('But soft, what light through yonder window breaks?');
expect(view.model.messages.at(0).get('correcting')).toBe(true);
expect(view.el.querySelectorAll('.chat-msg').length).toBe(2);
......
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