Commit 7dd21880 authored by JC Brand's avatar JC Brand

Fix failing tests

Don't assume order of CSN messages, since `getLastMessageDate` ignores
CSN messages, they sometimes get add above one another.
parent b15ebdde
...@@ -670,7 +670,6 @@ ...@@ -670,7 +670,6 @@
await test_utils.waitUntil(() => _converse.onMAMPreferences.calls.count()); await test_utils.waitUntil(() => _converse.onMAMPreferences.calls.count());
expect(_converse.onMAMPreferences).toHaveBeenCalled(); expect(_converse.onMAMPreferences).toHaveBeenCalled();
expect(_converse.connection.sendIQ.calls.count()).toBe(3);
expect(sent_stanza.toString()).toBe( expect(sent_stanza.toString()).toBe(
`<iq id="${IQ_id}" type="set" xmlns="jabber:client">`+ `<iq id="${IQ_id}" type="set" xmlns="jabber:client">`+
......
...@@ -4363,11 +4363,12 @@ ...@@ -4363,11 +4363,12 @@
expect(events[1].textContent).toEqual('newguy has entered the groupchat'); expect(events[1].textContent).toEqual('newguy has entered the groupchat');
expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat'); expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
await test_utils.waitUntil(() => (view.el.querySelectorAll('.chat-state-notification').length === 2));
notifications = view.el.querySelectorAll('.chat-state-notification'); notifications = view.el.querySelectorAll('.chat-state-notification');
expect(notifications.length).toBe(2); expect(notifications.length).toBe(2);
expect(notifications[0].textContent).toEqual('newguy is typing'); expect(notifications[0].textContent).toEqual('newguy is typing');
expect(notifications[1].textContent).toEqual('nomorenicks is typing'); expect(notifications[1].textContent).toEqual('nomorenicks is typing');
expect(timeout_functions.length).toBe(2); expect(timeout_functions.length).toBe(3);
// Check that new messages appear under the chat state // Check that new messages appear under the chat state
// notifications // notifications
...@@ -4492,7 +4493,8 @@ ...@@ -4492,7 +4493,8 @@
expect(events[1].textContent).toEqual('newguy has entered the groupchat'); expect(events[1].textContent).toEqual('newguy has entered the groupchat');
expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat'); expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
var notifications = view.el.querySelectorAll('.chat-state-notification'); await test_utils.waitUntil(() => view.el.querySelectorAll('.chat-state-notification').length);
let notifications = view.el.querySelectorAll('.chat-state-notification');
expect(notifications.length).toBe(1); expect(notifications.length).toBe(1);
expect(notifications[0].textContent).toEqual('newguy is typing'); expect(notifications[0].textContent).toEqual('newguy is typing');
...@@ -4529,10 +4531,14 @@ ...@@ -4529,10 +4531,14 @@
expect(events[1].textContent).toEqual('newguy has entered the groupchat'); expect(events[1].textContent).toEqual('newguy has entered the groupchat');
expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat'); expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
await test_utils.waitUntil(() => view.el.querySelectorAll('.chat-state-notification').length === 2);
notifications = view.el.querySelectorAll('.chat-state-notification'); notifications = view.el.querySelectorAll('.chat-state-notification');
expect(notifications.length).toBe(2); // We check for the messages' text without assuming order,
expect(notifications[0].textContent).toEqual('newguy is typing'); // because it can be variable since getLastMessageDate
expect(notifications[1].textContent).toEqual('nomorenicks is typing'); // ignore CSN messages.
let text = _.map(notifications, 'textContent').join(' ');
expect(text.includes('newguy is typing')).toBe(true);
expect(text.includes('nomorenicks is typing')).toBe(true);
// <paused> state from occupant who typed first // <paused> state from occupant who typed first
msg = $msg({ msg = $msg({
...@@ -4548,10 +4554,16 @@ ...@@ -4548,10 +4554,16 @@
expect(events[1].textContent).toEqual('newguy has entered the groupchat'); expect(events[1].textContent).toEqual('newguy has entered the groupchat');
expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat'); expect(events[2].textContent).toEqual('nomorenicks has entered the groupchat');
await test_utils.waitUntil(() => {
return _.map(
view.el.querySelectorAll('.chat-state-notification'), 'textContent')
.join(' ').includes('stopped typing')
});
notifications = view.el.querySelectorAll('.chat-state-notification'); notifications = view.el.querySelectorAll('.chat-state-notification');
expect(notifications.length).toBe(2); expect(notifications.length).toBe(2);
expect(notifications[0].textContent).toEqual('nomorenicks is typing'); text = _.map(notifications, 'textContent').join(' ');
expect(notifications[1].textContent).toEqual('newguy has stopped typing'); expect(text.includes('newguy has stopped typing')).toBe(true);
expect(text.includes('nomorenicks is typing')).toBe(true);
done(); done();
})); }));
}); });
......
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