Bugfix. Can't call tagName
on a Strophe.Builder object
This commit is contained in:
parent
c0c8fbac38
commit
698f3a7b15
@ -42,7 +42,7 @@ describe("The Protocol", function () {
|
||||
mock.initConverse([], { roster_groups: false }, async function (done, _converse) {
|
||||
|
||||
const { u, $iq, $pres, sizzle, Strophe } = converse.env;
|
||||
let contact, sent_stanza, IQ_id, stanza;
|
||||
let contact, stanza;
|
||||
await mock.waitForRoster(_converse, 'current', 0);
|
||||
await mock.waitUntilDiscoConfirmed(_converse, 'montague.lit', [], ['vcard-temp']);
|
||||
await u.waitUntil(() => _converse.xmppstatus.vcard.get('fullname'), 300);
|
||||
@ -57,12 +57,6 @@ describe("The Protocol", function () {
|
||||
spyOn(_converse.roster, "sendContactAddIQ").and.callThrough();
|
||||
spyOn(_converse.api.vcard, "get").and.callThrough();
|
||||
|
||||
const sendIQ = _converse.connection.sendIQ;
|
||||
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
|
||||
sent_stanza = iq;
|
||||
IQ_id = sendIQ.bind(this)(iq, callback, errback);
|
||||
});
|
||||
|
||||
cbview.querySelector('.add-contact').click()
|
||||
const modal = _converse.api.modal.get('add-contact-modal');
|
||||
await u.waitUntil(() => u.isVisible(modal.el), 1000);
|
||||
@ -103,13 +97,18 @@ describe("The Protocol", function () {
|
||||
*/
|
||||
await mock.waitForRoster(_converse, 'all', 0);
|
||||
expect(_converse.roster.sendContactAddIQ).toHaveBeenCalled();
|
||||
expect(Strophe.serialize(sent_stanza)).toBe(
|
||||
`<iq id="${IQ_id}" type="set" xmlns="jabber:client">`+
|
||||
|
||||
const IQ_stanzas = _converse.connection.IQ_stanzas;
|
||||
const roster_fetch_stanza = IQ_stanzas.filter(s => sizzle('query[xmlns="jabber:iq:roster"]', s)).pop();
|
||||
|
||||
expect(Strophe.serialize(roster_fetch_stanza)).toBe(
|
||||
`<iq id="${roster_fetch_stanza.getAttribute('id')}" type="set" xmlns="jabber:client">`+
|
||||
`<query xmlns="jabber:iq:roster">`+
|
||||
`<item jid="contact@example.org"/>`+
|
||||
`</query>`+
|
||||
`</iq>`
|
||||
);
|
||||
|
||||
/* As a result, the user's server (1) MUST initiate a roster push
|
||||
* for the new roster item to all available resources associated
|
||||
* with _converse user that have requested the roster, setting the
|
||||
@ -130,24 +129,25 @@ describe("The Protocol", function () {
|
||||
*/
|
||||
const create = _converse.roster.create;
|
||||
const sent_stanzas = [];
|
||||
let sent_stanza;
|
||||
spyOn(_converse.connection, 'send').and.callFake(function (stanza) {
|
||||
sent_stanza = stanza;
|
||||
sent_stanzas.push(stanza.toLocaleString());
|
||||
sent_stanzas.push(stanza);
|
||||
});
|
||||
spyOn(_converse.roster, 'create').and.callFake(function () {
|
||||
contact = create.apply(_converse.roster, arguments);
|
||||
spyOn(contact, 'subscribe').and.callThrough();
|
||||
return contact;
|
||||
});
|
||||
|
||||
stanza = $iq({'type': 'set'}).c('query', {'xmlns': 'jabber:iq:roster'})
|
||||
.c('item', {
|
||||
'jid': 'contact@example.org',
|
||||
'subscription': 'none',
|
||||
'name': 'contact@example.org'});
|
||||
_converse.connection._dataRecv(mock.createRequest(stanza));
|
||||
/* <iq type='result' id='set1'/>
|
||||
*/
|
||||
stanza = $iq({'type': 'result', 'id':IQ_id});
|
||||
|
||||
stanza = $iq({'type': 'result', 'id': roster_fetch_stanza.getAttribute('id')});
|
||||
_converse.connection._dataRecv(mock.createRequest(stanza));
|
||||
|
||||
await u.waitUntil(() => _converse.roster.create.calls.count());
|
||||
@ -163,9 +163,9 @@ describe("The Protocol", function () {
|
||||
*
|
||||
* <presence to='contact@example.org' type='subscribe'/>
|
||||
*/
|
||||
const sent_presence = await u.waitUntil(() => sent_stanzas.filter(s => s.match('presence')).pop());
|
||||
const sent_presence = await u.waitUntil(() => sent_stanzas.filter(s => s.matches('presence')).pop());
|
||||
expect(contact.subscribe).toHaveBeenCalled();
|
||||
expect(sent_presence).toBe(
|
||||
expect(Strophe.serialize(sent_presence)).toBe(
|
||||
`<presence to="contact@example.org" type="subscribe" xmlns="jabber:client">`+
|
||||
`<nick xmlns="http://jabber.org/protocol/nick">Romeo Montague</nick>`+
|
||||
`</presence>`
|
||||
@ -237,7 +237,7 @@ describe("The Protocol", function () {
|
||||
* stanza of type "subscribe".
|
||||
*/
|
||||
expect(contact.ackSubscribe).toHaveBeenCalled();
|
||||
expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec)
|
||||
expect(Strophe.serialize(sent_stanza)).toBe( // Strophe adds the xmlns attr (although not in spec)
|
||||
`<presence to="contact@example.org" type="subscribe" xmlns="jabber:client"/>`
|
||||
);
|
||||
|
||||
@ -257,7 +257,7 @@ describe("The Protocol", function () {
|
||||
* </query>
|
||||
* </iq>
|
||||
*/
|
||||
IQ_id = _converse.connection.getUniqueId('roster');
|
||||
const IQ_id = _converse.connection.getUniqueId('roster');
|
||||
stanza = $iq({'type': 'set', 'id': IQ_id})
|
||||
.c('query', {'xmlns': 'jabber:iq:roster'})
|
||||
.c('item', {
|
||||
@ -323,7 +323,7 @@ describe("The Protocol", function () {
|
||||
* <presence to='contact@example.org' type='subscribed'/>
|
||||
*/
|
||||
expect(contact.authorize).toHaveBeenCalled();
|
||||
expect(sent_stanza.toLocaleString()).toBe(
|
||||
expect(Strophe.serialize(sent_stanza)).toBe(
|
||||
`<presence to="contact@example.org" type="subscribed" xmlns="jabber:client"/>`
|
||||
);
|
||||
|
||||
@ -424,7 +424,7 @@ describe("The Protocol", function () {
|
||||
* sending a presence stanza of type "unsubscribe
|
||||
*/
|
||||
expect(contact.ackUnsubscribe).toHaveBeenCalled();
|
||||
expect(sent_stanza.toLocaleString()).toBe(
|
||||
expect(Strophe.serialize(sent_stanza)).toBe(
|
||||
`<presence to="contact@example.org" type="unsubscribe" xmlns="jabber:client"/>`
|
||||
);
|
||||
|
||||
|
@ -679,7 +679,10 @@ export const api = _converse.api = {
|
||||
}
|
||||
if (typeof stanza === 'string') {
|
||||
stanza = u.toStanza(stanza);
|
||||
} else if (stanza?.nodeTree) {
|
||||
stanza = stanza.nodeTree;
|
||||
}
|
||||
|
||||
if (stanza.tagName === 'iq') {
|
||||
return api.sendIQ(stanza);
|
||||
} else {
|
||||
|
@ -1,5 +1,7 @@
|
||||
/* global mock, converse */
|
||||
|
||||
const { Strophe } = converse.env;
|
||||
|
||||
describe("Converse", function() {
|
||||
|
||||
describe("Authentication", function () {
|
||||
@ -41,10 +43,10 @@ describe("Converse", function() {
|
||||
i++;
|
||||
}
|
||||
expect(_converse.sendCSI).toHaveBeenCalledWith('inactive');
|
||||
expect(sent_stanza.toLocaleString()).toBe('<inactive xmlns="urn:xmpp:csi:0"/>');
|
||||
expect(Strophe.serialize(sent_stanza)).toBe('<inactive xmlns="urn:xmpp:csi:0"/>');
|
||||
_converse.onUserActivity();
|
||||
expect(_converse.sendCSI).toHaveBeenCalledWith('active');
|
||||
expect(sent_stanza.toLocaleString()).toBe('<active xmlns="urn:xmpp:csi:0"/>');
|
||||
expect(Strophe.serialize(sent_stanza)).toBe('<active xmlns="urn:xmpp:csi:0"/>');
|
||||
done();
|
||||
}));
|
||||
});
|
||||
|
@ -375,7 +375,7 @@ describe("Chatboxes", function () {
|
||||
const model = _converse.chatboxes.get(contact_jid);
|
||||
expect(model.get('chat_state')).toBe('active');
|
||||
expect(_converse.connection.send).toHaveBeenCalled();
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0];
|
||||
expect(stanza.getAttribute('to')).toBe(contact_jid);
|
||||
expect(stanza.childNodes.length).toBe(3);
|
||||
expect(stanza.childNodes[0].tagName).toBe('active');
|
||||
@ -396,21 +396,19 @@ describe("Chatboxes", function () {
|
||||
await mock.openChatBoxFor(_converse, contact_jid);
|
||||
const model = _converse.chatboxes.get(contact_jid);
|
||||
_converse.minimize.minimize(model);
|
||||
const sent_stanzas = _converse.connection.sent_stanzas;
|
||||
sent_stanzas.splice(0, sent_stanzas.length);
|
||||
expect(model.get('chat_state')).toBe('inactive');
|
||||
spyOn(_converse.connection, 'send');
|
||||
_converse.minimize.maximize(model);
|
||||
await u.waitUntil(() => model.get('chat_state') === 'active', 1000);
|
||||
expect(_converse.connection.send).toHaveBeenCalled();
|
||||
const calls = _.filter(_converse.connection.send.calls.all(), function (call) {
|
||||
return call.args[0] instanceof Strophe.Builder;
|
||||
});
|
||||
expect(calls.length).toBe(1);
|
||||
const stanza = calls[0].args[0].tree();
|
||||
expect(stanza.getAttribute('to')).toBe(contact_jid);
|
||||
expect(stanza.childNodes.length).toBe(3);
|
||||
expect(stanza.childNodes[0].tagName).toBe('active');
|
||||
expect(stanza.childNodes[1].tagName).toBe('no-store');
|
||||
expect(stanza.childNodes[2].tagName).toBe('no-permanent-store');
|
||||
const stanza = await u.waitUntil(() => sent_stanzas.filter(s => sizzle(`active`, s).length).pop());
|
||||
expect(Strophe.serialize(stanza)).toBe(
|
||||
`<message id="${stanza.getAttribute('id')}" to="${contact_jid}" type="chat" xmlns="jabber:client">`+
|
||||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<no-store xmlns="urn:xmpp:hints"/>`+
|
||||
`<no-permanent-store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`
|
||||
);
|
||||
done();
|
||||
}));
|
||||
});
|
||||
@ -440,7 +438,7 @@ describe("Chatboxes", function () {
|
||||
expect(view.model.get('chat_state')).toBe('composing');
|
||||
expect(_converse.connection.send).toHaveBeenCalled();
|
||||
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0];
|
||||
expect(stanza.getAttribute('to')).toBe(contact_jid);
|
||||
expect(stanza.childNodes.length).toBe(3);
|
||||
expect(stanza.childNodes[0].tagName).toBe('composing');
|
||||
@ -579,7 +577,6 @@ describe("Chatboxes", function () {
|
||||
_converse.TIMEOUTS.PAUSED = 200; // Make the timeout shorter so that we can test
|
||||
await mock.openChatBoxFor(_converse, contact_jid);
|
||||
const view = _converse.chatboxviews.get(contact_jid);
|
||||
spyOn(_converse.connection, 'send');
|
||||
spyOn(view.model, 'setChatState').and.callThrough();
|
||||
expect(view.model.get('chat_state')).toBe('active');
|
||||
const bottom_panel = view.querySelector('converse-chat-bottom-panel');
|
||||
@ -588,21 +585,29 @@ describe("Chatboxes", function () {
|
||||
keyCode: 1
|
||||
});
|
||||
expect(view.model.get('chat_state')).toBe('composing');
|
||||
expect(_converse.connection.send).toHaveBeenCalled();
|
||||
let stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
|
||||
expect(stanza.childNodes[0].tagName).toBe('composing');
|
||||
|
||||
const xmlns = 'https://jabber.org/protocol/chatstates';
|
||||
const sent_stanzas = _converse.connection.sent_stanzas;
|
||||
let stanza = await u.waitUntil(() => sent_stanzas.filter(s => sizzle(`composing`, s).length).pop(), 1000);
|
||||
|
||||
expect(Strophe.serialize(stanza)).toBe(
|
||||
`<message id="${stanza.getAttribute('id')}" to="${contact_jid}" type="chat" xmlns="jabber:client">`+
|
||||
`<composing xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<no-store xmlns="urn:xmpp:hints"/>`+
|
||||
`<no-permanent-store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`
|
||||
);
|
||||
|
||||
await u.waitUntil(() => view.model.get('chat_state') === 'paused', 500);
|
||||
expect(_converse.connection.send).toHaveBeenCalled();
|
||||
var calls = _.filter(_converse.connection.send.calls.all(), function (call) {
|
||||
return call.args[0] instanceof Strophe.Builder;
|
||||
});
|
||||
expect(calls.length).toBe(2);
|
||||
stanza = calls[1].args[0].tree();
|
||||
expect(stanza.getAttribute('to')).toBe(contact_jid);
|
||||
expect(stanza.childNodes.length).toBe(3);
|
||||
expect(stanza.childNodes[0].tagName).toBe('paused');
|
||||
expect(stanza.childNodes[1].tagName).toBe('no-store');
|
||||
expect(stanza.childNodes[2].tagName).toBe('no-permanent-store');
|
||||
|
||||
stanza = await u.waitUntil(() => sent_stanzas.filter(s => sizzle(`[xmlns="${xmlns}"]`, s)).pop());
|
||||
expect(Strophe.serialize(stanza)).toBe(
|
||||
`<message id="${stanza.getAttribute('id')}" to="${contact_jid}" type="chat" xmlns="jabber:client">`+
|
||||
`<paused xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<no-store xmlns="urn:xmpp:hints"/>`+
|
||||
`<no-permanent-store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`
|
||||
);
|
||||
|
||||
// Test #359. A paused notification should not be sent
|
||||
// out if the user simply types longer than the
|
||||
@ -696,53 +701,55 @@ describe("Chatboxes", function () {
|
||||
await mock.openControlBox(_converse);
|
||||
const rosterview = document.querySelector('converse-roster');
|
||||
await u.waitUntil(() => rosterview.querySelectorAll('.roster-group').length, 1000);
|
||||
|
||||
sent_stanzas.splice(0, sent_stanzas.length);
|
||||
await mock.openChatBoxFor(_converse, contact_jid);
|
||||
const view = _converse.chatboxviews.get(contact_jid);
|
||||
|
||||
await u.waitUntil(() => view.model.get('chat_state') === 'active');
|
||||
let messages = await u.waitUntil(() => sent_stanzas.filter(s => s.matches('message')));
|
||||
expect(messages.length).toBe(1);
|
||||
expect(view.model.get('chat_state')).toBe('active');
|
||||
const bottom_panel = view.querySelector('converse-chat-bottom-panel');
|
||||
bottom_panel.onKeyDown({
|
||||
target: view.querySelector('textarea.chat-textarea'),
|
||||
keyCode: 1
|
||||
});
|
||||
await u.waitUntil(() => view.model.get('chat_state') === 'composing', 600);
|
||||
messages = sent_stanzas.filter(s => s.matches('message'));
|
||||
expect(messages.length).toBe(2);
|
||||
|
||||
await u.waitUntil(() => view.model.get('chat_state') === 'paused', 600);
|
||||
messages = sent_stanzas.filter(s => s.matches('message'));
|
||||
expect(messages.length).toBe(3);
|
||||
|
||||
await u.waitUntil(() => view.model.get('chat_state') === 'inactive', 600);
|
||||
messages = sent_stanzas.filter(s => s.matches('message'));
|
||||
expect(messages.length).toBe(4);
|
||||
|
||||
const messages = sent_stanzas.filter(s => s.matches('message'));
|
||||
expect(Strophe.serialize(messages[0])).toBe(
|
||||
`<message id="${messages[0].getAttribute('id')}" to="mercutio@montague.lit" type="chat" xmlns="jabber:client">`+
|
||||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<no-store xmlns="urn:xmpp:hints"/>`+
|
||||
`<no-permanent-store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`);
|
||||
expect(Strophe.serialize(messages[1])).toBe(
|
||||
`<message id="${messages[1].getAttribute('id')}" to="mercutio@montague.lit" type="chat" xmlns="jabber:client">`+
|
||||
|
||||
|
||||
const bottom_panel = view.querySelector('converse-chat-bottom-panel');
|
||||
bottom_panel.onKeyDown({
|
||||
target: view.querySelector('textarea.chat-textarea'),
|
||||
keyCode: 1
|
||||
});
|
||||
await u.waitUntil(() => view.model.get('chat_state') === 'composing', 600);
|
||||
let stanza = await u.waitUntil(() => sent_stanzas.filter(s => s.querySelector('message composing')).pop());
|
||||
expect(Strophe.serialize(stanza)).toBe(
|
||||
`<message id="${stanza.getAttribute('id')}" to="mercutio@montague.lit" type="chat" xmlns="jabber:client">`+
|
||||
`<composing xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<no-store xmlns="urn:xmpp:hints"/>`+
|
||||
`<no-permanent-store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`);
|
||||
expect(Strophe.serialize(messages[2])).toBe(
|
||||
`<message id="${messages[2].getAttribute('id')}" to="mercutio@montague.lit" type="chat" xmlns="jabber:client">`+
|
||||
|
||||
await u.waitUntil(() => view.model.get('chat_state') === 'paused', 600);
|
||||
stanza = await u.waitUntil(() => sent_stanzas.filter(s => s.querySelector('message paused')).pop());
|
||||
expect(Strophe.serialize(stanza)).toBe(
|
||||
`<message id="${stanza.getAttribute('id')}" to="mercutio@montague.lit" type="chat" xmlns="jabber:client">`+
|
||||
`<paused xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<no-store xmlns="urn:xmpp:hints"/>`+
|
||||
`<no-permanent-store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`);
|
||||
expect(Strophe.serialize(messages[3])).toBe(
|
||||
`<message id="${messages[3].getAttribute('id')}" to="mercutio@montague.lit" type="chat" xmlns="jabber:client">`+
|
||||
|
||||
await u.waitUntil(() => view.model.get('chat_state') === 'inactive', 600);
|
||||
stanza = await u.waitUntil(() => sent_stanzas.filter(s => s.querySelector('message inactive')).pop());
|
||||
expect(Strophe.serialize(stanza)).toBe(
|
||||
`<message id="${stanza.getAttribute('id')}" to="mercutio@montague.lit" type="chat" xmlns="jabber:client">`+
|
||||
`<inactive xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<no-store xmlns="urn:xmpp:hints"/>`+
|
||||
`<no-permanent-store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`);
|
||||
|
||||
done();
|
||||
}));
|
||||
|
||||
@ -759,7 +766,7 @@ describe("Chatboxes", function () {
|
||||
_converse.minimize.minimize(view.model);
|
||||
expect(view.model.get('chat_state')).toBe('inactive');
|
||||
expect(_converse.connection.send).toHaveBeenCalled();
|
||||
var stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
|
||||
var stanza = _converse.connection.send.calls.argsFor(0)[0];
|
||||
expect(stanza.getAttribute('to')).toBe(contact_jid);
|
||||
expect(stanza.childNodes[0].tagName).toBe('inactive');
|
||||
done();
|
||||
@ -779,7 +786,7 @@ describe("Chatboxes", function () {
|
||||
view.close();
|
||||
expect(view.model.get('chat_state')).toBe('inactive');
|
||||
expect(_converse.connection.send).toHaveBeenCalled();
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0];
|
||||
expect(stanza.getAttribute('to')).toBe(contact_jid);
|
||||
expect(stanza.childNodes.length).toBe(3);
|
||||
expect(stanza.childNodes[0].tagName).toBe('inactive');
|
||||
|
@ -1,7 +1,6 @@
|
||||
/*global mock, converse */
|
||||
|
||||
const { Promise, $msg, sizzle } = converse.env;
|
||||
const u = converse.env.utils;
|
||||
const { Promise, $msg, Strophe, sizzle, u } = converse.env;
|
||||
|
||||
describe("A Chat Message", function () {
|
||||
|
||||
@ -56,15 +55,15 @@ describe("A Chat Message", function () {
|
||||
await u.waitUntil(() => view.querySelector('.chat-msg__text').textContent.replace(/<!-.*?->/g, '') === new_text);
|
||||
|
||||
const msg = _converse.connection.send.calls.all()[0].args[0];
|
||||
expect(msg.toLocaleString())
|
||||
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.nodeTree.getAttribute("id")}" `+
|
||||
expect(Strophe.serialize(msg))
|
||||
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.getAttribute("id")}" `+
|
||||
`to="mercutio@montague.lit" type="chat" `+
|
||||
`xmlns="jabber:client">`+
|
||||
`<body>But soft, what light through yonder window breaks?</body>`+
|
||||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<request xmlns="urn:xmpp:receipts"/>`+
|
||||
`<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
|
||||
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`<origin-id id="${msg.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`</message>`);
|
||||
expect(view.model.messages.models.length).toBe(1);
|
||||
const corrected_message = view.model.messages.at(0);
|
||||
@ -213,15 +212,15 @@ describe("A Chat Message", function () {
|
||||
expect(_converse.connection.send).toHaveBeenCalled();
|
||||
|
||||
const msg = _converse.connection.send.calls.all()[0].args[0];
|
||||
expect(msg.toLocaleString())
|
||||
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.nodeTree.getAttribute("id")}" `+
|
||||
expect(Strophe.serialize(msg))
|
||||
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.getAttribute("id")}" `+
|
||||
`to="mercutio@montague.lit" type="chat" `+
|
||||
`xmlns="jabber:client">`+
|
||||
`<body>But soft, what light through yonder window breaks?</body>`+
|
||||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<request xmlns="urn:xmpp:receipts"/>`+
|
||||
`<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
|
||||
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`<origin-id id="${msg.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`</message>`);
|
||||
expect(view.model.messages.models.length).toBe(1);
|
||||
const corrected_message = view.model.messages.at(0);
|
||||
|
@ -258,9 +258,9 @@ describe("XEP-0363: HTTP File Upload", function () {
|
||||
_converse.connection._dataRecv(mock.createRequest(stanza));
|
||||
|
||||
await u.waitUntil(() => sent_stanza, 1000);
|
||||
expect(sent_stanza.toLocaleString()).toBe(
|
||||
expect(Strophe.serialize(sent_stanza)).toBe(
|
||||
`<message from="romeo@montague.lit/orchard" `+
|
||||
`id="${sent_stanza.nodeTree.getAttribute("id")}" `+
|
||||
`id="${sent_stanza.getAttribute("id")}" `+
|
||||
`to="lady.montague@montague.lit" `+
|
||||
`type="chat" `+
|
||||
`xmlns="jabber:client">`+
|
||||
@ -270,7 +270,7 @@ describe("XEP-0363: HTTP File Upload", function () {
|
||||
`<x xmlns="jabber:x:oob">`+
|
||||
`<url>${message}</url>`+
|
||||
`</x>`+
|
||||
`<origin-id id="${sent_stanza.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`<origin-id id="${sent_stanza.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`</message>`);
|
||||
const img_link_el = await u.waitUntil(() => view.querySelector('converse-chat-message-body .chat-image__link'), 1000);
|
||||
// Check that the image renders
|
||||
|
@ -132,7 +132,7 @@ describe("A spoiler message", function () {
|
||||
* <spoiler xmlns="urn:xmpp:spoiler:0"/>
|
||||
* </message>"
|
||||
*/
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0];
|
||||
const spoiler_el = await u.waitUntil(() => stanza.querySelector('spoiler[xmlns="urn:xmpp:spoiler:0"]'));
|
||||
expect(spoiler_el.textContent).toBe('');
|
||||
|
||||
@ -201,7 +201,7 @@ describe("A spoiler message", function () {
|
||||
});
|
||||
await new Promise(resolve => view.model.messages.once('rendered', resolve));
|
||||
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
|
||||
const stanza = _converse.connection.send.calls.argsFor(0)[0];
|
||||
expect(Strophe.serialize(stanza)).toBe(
|
||||
`<message from="romeo@montague.lit/orchard" ` +
|
||||
`id="${stanza.getAttribute('id')}" `+
|
||||
|
@ -210,14 +210,14 @@ describe("A Groupchat Message", function () {
|
||||
.filter(m => m.textContent.replace(/<!-.*?->/g, '') === new_text).length);
|
||||
|
||||
const msg = _converse.connection.send.calls.all()[0].args[0];
|
||||
expect(msg.toLocaleString())
|
||||
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.nodeTree.getAttribute("id")}" `+
|
||||
expect(Strophe.serialize(msg))
|
||||
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.getAttribute("id")}" `+
|
||||
`to="lounge@montague.lit" type="groupchat" `+
|
||||
`xmlns="jabber:client">`+
|
||||
`<body>But soft, what light through yonder window breaks?</body>`+
|
||||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||
`<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
|
||||
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`<origin-id id="${msg.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`</message>`);
|
||||
|
||||
expect(view.model.messages.models.length).toBe(1);
|
||||
|
@ -123,10 +123,10 @@ describe("XEP-0363: HTTP File Upload", function () {
|
||||
_converse.connection._dataRecv(mock.createRequest(stanza));
|
||||
|
||||
await u.waitUntil(() => sent_stanza, 1000);
|
||||
expect(sent_stanza.toLocaleString()).toBe(
|
||||
expect(Strophe.serialize(sent_stanza)).toBe(
|
||||
`<message `+
|
||||
`from="romeo@montague.lit/orchard" `+
|
||||
`id="${sent_stanza.nodeTree.getAttribute("id")}" `+
|
||||
`id="${sent_stanza.getAttribute("id")}" `+
|
||||
`to="lounge@montague.lit" `+
|
||||
`type="groupchat" `+
|
||||
`xmlns="jabber:client">`+
|
||||
@ -135,7 +135,7 @@ describe("XEP-0363: HTTP File Upload", function () {
|
||||
`<x xmlns="jabber:x:oob">`+
|
||||
`<url>${message}</url>`+
|
||||
`</x>`+
|
||||
`<origin-id id="${sent_stanza.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`<origin-id id="${sent_stanza.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`</message>`);
|
||||
const img_link_el = await u.waitUntil(() => view.querySelector('converse-chat-message-body .chat-image__link'), 1000);
|
||||
// Check that the image renders
|
||||
|
@ -463,8 +463,8 @@ describe("A sent groupchat message", function () {
|
||||
await u.waitUntil(() => view.querySelectorAll('.chat-msg__text').length);
|
||||
|
||||
const msg = _converse.connection.send.calls.all()[0].args[0];
|
||||
expect(msg.toLocaleString())
|
||||
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.nodeTree.getAttribute("id")}" `+
|
||||
expect(Strophe.serialize(msg))
|
||||
.toBe(`<message from="romeo@montague.lit/orchard" id="${msg.getAttribute("id")}" `+
|
||||
`to="lounge@montague.lit" type="groupchat" `+
|
||||
`xmlns="jabber:client">`+
|
||||
`<body>hello z3r0 gibson mr.robot, how are you?</body>`+
|
||||
@ -472,7 +472,7 @@ describe("A sent groupchat message", function () {
|
||||
`<reference begin="6" end="10" type="mention" uri="xmpp:${muc_jid}/z3r0" xmlns="urn:xmpp:reference:0"/>`+
|
||||
`<reference begin="11" end="17" type="mention" uri="xmpp:${muc_jid}/gibson" xmlns="urn:xmpp:reference:0"/>`+
|
||||
`<reference begin="18" end="26" type="mention" uri="xmpp:${muc_jid}/mr.robot" xmlns="urn:xmpp:reference:0"/>`+
|
||||
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`<origin-id id="${msg.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
|
||||
`</message>`);
|
||||
done();
|
||||
}));
|
||||
|
@ -1816,9 +1816,9 @@ describe("Groupchats", function () {
|
||||
modal.el.querySelector('button[type="submit"]').click();
|
||||
|
||||
expect(view.model.directInvite).toHaveBeenCalled();
|
||||
expect(sent_stanza.toLocaleString()).toBe(
|
||||
expect(Strophe.serialize(sent_stanza)).toBe(
|
||||
`<message from="romeo@montague.lit/orchard" `+
|
||||
`id="${sent_stanza.nodeTree.getAttribute("id")}" `+
|
||||
`id="${sent_stanza.getAttribute("id")}" `+
|
||||
`to="balthasar@montague.lit" `+
|
||||
`xmlns="jabber:client">`+
|
||||
`<x jid="lounge@montague.lit" reason="Please join!" xmlns="jabber:x:conference"/>`+
|
||||
@ -4177,8 +4177,8 @@ describe("Groupchats", function () {
|
||||
|
||||
let sent_stanza, sent_id;
|
||||
spyOn(_converse.connection, 'send').and.callFake(function (stanza) {
|
||||
if (stanza.nodeTree && stanza.nodeTree.nodeName === 'message') {
|
||||
sent_id = stanza.nodeTree.getAttribute('id');
|
||||
if (stanza.nodeName === 'message') {
|
||||
sent_id = stanza.getAttribute('id');
|
||||
sent_stanza = stanza;
|
||||
}
|
||||
});
|
||||
@ -4267,7 +4267,7 @@ describe("Groupchats", function () {
|
||||
await u.waitUntil(() => view.model.occupants.fetchMembers.calls.count());
|
||||
|
||||
// Finally check that the user gets invited.
|
||||
expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec)
|
||||
expect(Strophe.serialize(sent_stanza)).toBe( // Strophe adds the xmlns attr (although not in spec)
|
||||
`<message from="romeo@montague.lit/orchard" id="${sent_id}" to="${invitee_jid}" xmlns="jabber:client">`+
|
||||
`<x jid="coven@chat.shakespeare.lit" reason="Please join this groupchat" xmlns="jabber:x:conference"/>`+
|
||||
`</message>`
|
||||
|
@ -159,8 +159,8 @@ describe("The OMEMO module", function() {
|
||||
spyOn(_converse.connection, 'send').and.callFake(stanza => { sent_stanza = stanza });
|
||||
_converse.connection._dataRecv(mock.createRequest(stanza));
|
||||
await u.waitUntil(() => sent_stanza);
|
||||
expect(sent_stanza.toLocaleString()).toBe(
|
||||
`<message from="romeo@montague.lit/orchard" id="${sent_stanza.nodeTree.getAttribute("id")}" `+
|
||||
expect(Strophe.serialize(sent_stanza)).toBe(
|
||||
`<message from="romeo@montague.lit/orchard" id="${sent_stanza.getAttribute("id")}" `+
|
||||
`to="mercutio@montague.lit" `+
|
||||
`type="chat" xmlns="jabber:client">`+
|
||||
`<body>This is an OMEMO encrypted message which your client doesn’t seem to support. Find more information on https://conversations.im/omemo</body>`+
|
||||
@ -169,9 +169,9 @@ describe("The OMEMO module", function() {
|
||||
`<header sid="123456789">`+
|
||||
`<key rid="482886413b977930064a5888b92134fe">YzFwaDNSNzNYNw==</key>`+
|
||||
`<key rid="555">YzFwaDNSNzNYNw==</key>`+
|
||||
`<iv>${sent_stanza.nodeTree.querySelector("iv").textContent}</iv>`+
|
||||
`<iv>${sent_stanza.querySelector("iv").textContent}</iv>`+
|
||||
`</header>`+
|
||||
`<payload>${sent_stanza.nodeTree.querySelector("payload").textContent}</payload>`+
|
||||
`<payload>${sent_stanza.querySelector("payload").textContent}</payload>`+
|
||||
`</encrypted>`+
|
||||
`<store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`);
|
||||
@ -348,7 +348,7 @@ describe("The OMEMO module", function() {
|
||||
|
||||
expect(Strophe.serialize(sent_stanza)).toBe(
|
||||
`<message from="romeo@montague.lit/orchard" `+
|
||||
`id="${sent_stanza.nodeTree.getAttribute("id")}" `+
|
||||
`id="${sent_stanza.getAttribute("id")}" `+
|
||||
`to="lounge@montague.lit" `+
|
||||
`type="groupchat" `+
|
||||
`xmlns="jabber:client">`+
|
||||
@ -357,9 +357,9 @@ describe("The OMEMO module", function() {
|
||||
`<header sid="123456789">`+
|
||||
`<key rid="482886413b977930064a5888b92134fe">YzFwaDNSNzNYNw==</key>`+
|
||||
`<key rid="4e30f35051b7b8b42abe083742187228">YzFwaDNSNzNYNw==</key>`+
|
||||
`<iv>${sent_stanza.nodeTree.querySelector("iv").textContent}</iv>`+
|
||||
`<iv>${sent_stanza.querySelector("iv").textContent}</iv>`+
|
||||
`</header>`+
|
||||
`<payload>${sent_stanza.nodeTree.querySelector("payload").textContent}</payload>`+
|
||||
`<payload>${sent_stanza.querySelector("payload").textContent}</payload>`+
|
||||
`</encrypted>`+
|
||||
`<store xmlns="urn:xmpp:hints"/>`+
|
||||
`</message>`);
|
||||
|
Loading…
Reference in New Issue
Block a user