From 605c02901aa424b79cbce79d0fda498d47c7f0bf Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 14 Jul 2022 21:17:32 +0200 Subject: [PATCH] Fix yet more tests --- src/headless/plugins/caps/utils.js | 3 ++- src/headless/plugins/muc/tests/muc.js | 3 ++- src/plugins/muc-views/tests/rai.js | 14 +++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/headless/plugins/caps/utils.js b/src/headless/plugins/caps/utils.js index 8190fa52b..928c0738e 100644 --- a/src/headless/plugins/caps/utils.js +++ b/src/headless/plugins/caps/utils.js @@ -41,5 +41,6 @@ async function createCapsNode () { */ export async function addCapsNode (stanza) { const caps_el = await createCapsNode(); - return stanza.root().cnode(caps_el).up() && stanza; + stanza.root().cnode(caps_el).up(); + return stanza; } diff --git a/src/headless/plugins/muc/tests/muc.js b/src/headless/plugins/muc/tests/muc.js index 7a16f3f37..ace30988c 100644 --- a/src/headless/plugins/muc/tests/muc.js +++ b/src/headless/plugins/muc/tests/muc.js @@ -63,7 +63,8 @@ describe("Groupchats", function () { while (sent_stanzas.length) sent_stanzas.pop(); _converse.xmppstatus.set('status', 'xa'); - pres = await u.waitUntil(() => sent_stanzas.filter(s => s.nodeName === 'presence').pop()); + pres = await u.waitUntil(() => sent_stanzas.filter(s => s.nodeName === 'presence' && s.getAttribute('to') === `${muc_jid}/romeo`).pop()); + expect(Strophe.serialize(pres)).toBe( ``+ `xa`+ diff --git a/src/plugins/muc-views/tests/rai.js b/src/plugins/muc-views/tests/rai.js index 17b3c3d59..147c94ee8 100644 --- a/src/plugins/muc-views/tests/rai.js +++ b/src/plugins/muc-views/tests/rai.js @@ -186,21 +186,21 @@ describe("XEP-0437 Room Activity Indicators", function () { expect(_converse.session.get('rai_enabled_domains')).toBe(undefined); const muc_jid = 'lounge@montague.lit'; - await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo'); - const view = _converse.chatboxviews.get(muc_jid); - expect(view.model.get('hidden')).toBe(false); + const model = await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo'); + expect(model.get('hidden')).toBe(false); const sent_stanzas = []; spyOn(_converse.connection, 'send').and.callFake(s => sent_stanzas.push(s?.nodeTree ?? s)); - view.model.save({'hidden': true}); + model.save({'hidden': true}); await u.waitUntil(() => sent_stanzas.filter(s => s.nodeName === 'presence').length === 2); - expect(Strophe.serialize(sent_stanzas[0])).toBe( + const sent_presences = sent_stanzas.filter(s => s.nodeName === 'presence'); + expect(Strophe.serialize(sent_presences[0])).toBe( ``+ `0`+ ``+ `` ); - expect(Strophe.serialize(sent_stanzas[1])).toBe( + expect(Strophe.serialize(sent_presences[1])).toBe( ``+ `0`+ ``+ @@ -215,7 +215,7 @@ describe("XEP-0437 Room Activity Indicators", function () { `); _converse.connection._dataRecv(mock.createRequest(activity_stanza)); - await u.waitUntil(() => view.model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING); + await u.waitUntil(() => model.session.get('connection_status') === converse.ROOMSTATUS.CONNECTING); })); });