Fix yet more tests

This commit is contained in:
JC Brand 2022-07-14 21:17:32 +02:00
parent 368bcf258f
commit 605c02901a
3 changed files with 11 additions and 9 deletions

View File

@ -41,5 +41,6 @@ async function createCapsNode () {
*/ */
export async function addCapsNode (stanza) { export async function addCapsNode (stanza) {
const caps_el = await createCapsNode(); const caps_el = await createCapsNode();
return stanza.root().cnode(caps_el).up() && stanza; stanza.root().cnode(caps_el).up();
return stanza;
} }

View File

@ -63,7 +63,8 @@ describe("Groupchats", function () {
while (sent_stanzas.length) sent_stanzas.pop(); while (sent_stanzas.length) sent_stanzas.pop();
_converse.xmppstatus.set('status', 'xa'); _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( expect(Strophe.serialize(pres)).toBe(
`<presence to="${muc_jid}/romeo" xmlns="jabber:client">`+ `<presence to="${muc_jid}/romeo" xmlns="jabber:client">`+
`<show>xa</show>`+ `<show>xa</show>`+

View File

@ -186,21 +186,21 @@ describe("XEP-0437 Room Activity Indicators", function () {
expect(_converse.session.get('rai_enabled_domains')).toBe(undefined); expect(_converse.session.get('rai_enabled_domains')).toBe(undefined);
const muc_jid = 'lounge@montague.lit'; const muc_jid = 'lounge@montague.lit';
await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo'); const model = await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo');
const view = _converse.chatboxviews.get(muc_jid); expect(model.get('hidden')).toBe(false);
expect(view.model.get('hidden')).toBe(false);
const sent_stanzas = []; const sent_stanzas = [];
spyOn(_converse.connection, 'send').and.callFake(s => sent_stanzas.push(s?.nodeTree ?? s)); 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); 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(
`<presence to="${muc_jid}/romeo" type="unavailable" xmlns="jabber:client">`+ `<presence to="${muc_jid}/romeo" type="unavailable" xmlns="jabber:client">`+
`<priority>0</priority>`+ `<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="/5ng/Bnz6MXvkSDu6hjAlgQ8C60=" xmlns="http://jabber.org/protocol/caps"/>`+ `<c hash="sha-1" node="https://conversejs.org" ver="/5ng/Bnz6MXvkSDu6hjAlgQ8C60=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>` `</presence>`
); );
expect(Strophe.serialize(sent_stanzas[1])).toBe( expect(Strophe.serialize(sent_presences[1])).toBe(
`<presence to="montague.lit" xmlns="jabber:client">`+ `<presence to="montague.lit" xmlns="jabber:client">`+
`<priority>0</priority>`+ `<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="/5ng/Bnz6MXvkSDu6hjAlgQ8C60=" xmlns="http://jabber.org/protocol/caps"/>`+ `<c hash="sha-1" node="https://conversejs.org" ver="/5ng/Bnz6MXvkSDu6hjAlgQ8C60=" xmlns="http://jabber.org/protocol/caps"/>`+
@ -215,7 +215,7 @@ describe("XEP-0437 Room Activity Indicators", function () {
`); `);
_converse.connection._dataRecv(mock.createRequest(activity_stanza)); _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);
})); }));
}); });