-
-
Notifications
You must be signed in to change notification settings - Fork 777
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
159 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ const { Strophe, u, stx } = converse.env; | |
|
||
describe("A Groupchat Message", function () { | ||
|
||
beforeAll(() => jasmine.addMatchers({ toEqualStanza: jasmine.toEqualStanza })); | ||
|
||
it("can be replaced with a correction", | ||
mock.initConverse([], {}, async function (_converse) { | ||
|
||
|
@@ -173,6 +175,8 @@ describe("A Groupchat Message", function () { | |
it("can be sent as a correction by using the up arrow", | ||
mock.initConverse([], {}, async function (_converse) { | ||
|
||
const { api } = _converse; | ||
const { jid: own_jid } = api.connection.get(); | ||
const nick = 'romeo' | ||
const muc_jid = '[email protected]'; | ||
await mock.openAndEnterChatRoom(_converse, muc_jid, nick); | ||
|
@@ -220,15 +224,15 @@ describe("A Groupchat Message", function () { | |
|
||
expect(_converse.api.connection.get().send).toHaveBeenCalled(); | ||
const msg = _converse.api.connection.get().send.calls.all()[0].args[0]; | ||
expect(Strophe.serialize(msg)).toBe( | ||
`<message from="${muc_jid}/${nick}" id="${msg.getAttribute("id")}" `+ | ||
`to="[email protected]" 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.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+ | ||
`</message>`); | ||
expect(msg).toEqualStanza(stx` | ||
<message from="${own_jid}" id="${msg.getAttribute("id")}" | ||
to="[email protected]" 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.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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ const { Strophe, sizzle, u, stx } = converse.env; | |
|
||
describe("XEP-0363: HTTP File Upload", function () { | ||
|
||
beforeAll(() => jasmine.addMatchers({ toEqualStanza: jasmine.toEqualStanza })); | ||
|
||
describe("When not supported", function () { | ||
describe("A file upload toolbar button", function () { | ||
|
||
|
@@ -124,20 +126,20 @@ describe("XEP-0363: HTTP File Upload", function () { | |
_converse.api.connection.get()._dataRecv(mock.createRequest(stanza)); | ||
|
||
await u.waitUntil(() => sent_stanza, 1000); | ||
expect(Strophe.serialize(sent_stanza)).toBe( | ||
`<message `+ | ||
`from="${muc_jid}/${nick}" `+ | ||
`id="${sent_stanza.getAttribute("id")}" `+ | ||
`to="[email protected]" `+ | ||
`type="groupchat" `+ | ||
`xmlns="jabber:client">`+ | ||
`<body>${message}</body>`+ | ||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ | ||
`<x xmlns="jabber:x:oob">`+ | ||
`<url>${message}</url>`+ | ||
`</x>`+ | ||
`<origin-id id="${sent_stanza.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+ | ||
`</message>`); | ||
expect(sent_stanza).toEqualStanza(stx` | ||
<message | ||
from="[email protected]/orchard" | ||
id="${sent_stanza.getAttribute("id")}" | ||
to="[email protected]" | ||
type="groupchat" | ||
xmlns="jabber:client"> | ||
<body>${message}</body> | ||
<active xmlns="http://jabber.org/protocol/chatstates"/> | ||
<x xmlns="jabber:x:oob"> | ||
<url>${message}</url> | ||
</x> | ||
<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 | ||
expect(img_link_el.outerHTML.replace(/<!-.*?->/g, '').trim()).toEqual( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,11 +84,13 @@ describe("An incoming groupchat message", function () { | |
it("properly renders mentions that contain the pipe character", | ||
mock.initConverse([], {}, async function (_converse) { | ||
|
||
const { api } = _converse; | ||
const { jid: own_jid } = api.connection.get(); | ||
const muc_jid = '[email protected]'; | ||
const nick = 'romeo'; | ||
const muc = await mock.openAndEnterChatRoom(_converse, muc_jid, nick); | ||
const view = _converse.chatboxviews.get(muc_jid); | ||
_converse.api.connection.get()._dataRecv(mock.createRequest( | ||
api.connection.get()._dataRecv(mock.createRequest( | ||
stx`<presence | ||
to="[email protected]/resource" | ||
from="[email protected]/ThUnD3r|Gr33n" | ||
|
@@ -116,7 +118,7 @@ describe("An incoming groupchat message", function () { | |
const sent_stanzas = _converse.api.connection.get().sent_stanzas; | ||
const msg = await u.waitUntil(() => sent_stanzas.filter(s => s.nodeName.toLowerCase() === 'message').pop()); | ||
expect(msg).toEqualStanza( | ||
stx`<message from="${muc_jid}/${nick}" | ||
stx`<message from="${own_jid}" | ||
id="${msg.getAttribute("id")}" | ||
to="[email protected]" type="groupchat" | ||
xmlns="jabber:client"> | ||
|
@@ -336,6 +338,8 @@ describe("A sent groupchat message", function () { | |
it("properly encodes the URIs in sent out references", | ||
mock.initConverse([], {}, async function (_converse) { | ||
|
||
const { api } = _converse; | ||
const { jid: own_jid } = api.connection.get(); | ||
const nick = 'tom'; | ||
const muc_jid = '[email protected]'; | ||
await mock.openAndEnterChatRoom(_converse, muc_jid, nick); | ||
|
@@ -364,22 +368,24 @@ describe("A sent groupchat message", function () { | |
await u.waitUntil(() => view.querySelectorAll('.chat-msg__text').length); | ||
const sent_stanzas = _converse.api.connection.get().sent_stanzas; | ||
const msg = await u.waitUntil(() => sent_stanzas.filter(s => s.nodeName.toLowerCase() === 'message').pop()); | ||
expect(Strophe.serialize(msg)) | ||
.toBe(`<message from="${muc_jid}/${nick}" id="${msg.getAttribute("id")}" `+ | ||
`to="[email protected]" type="groupchat" `+ | ||
`xmlns="jabber:client">`+ | ||
`<body>hello Link Mauve</body>`+ | ||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ | ||
`<reference begin="6" end="16" type="mention" uri="xmpp:[email protected]/Link%20Mauve" xmlns="urn:xmpp:reference:0"/>`+ | ||
`<origin-id id="${msg.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+ | ||
`</message>`); | ||
expect(msg).toEqualStanza(stx` | ||
<message from="${own_jid}" id="${msg.getAttribute("id")}" | ||
to="[email protected]" type="groupchat" | ||
xmlns="jabber:client"> | ||
<body>hello Link Mauve</body> | ||
<active xmlns="http://jabber.org/protocol/chatstates"/> | ||
<reference begin="6" end="16" type="mention" uri="xmpp:[email protected]/Link%20Mauve" xmlns="urn:xmpp:reference:0"/> | ||
<origin-id id="${msg.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/> | ||
</message>`); | ||
})); | ||
|
||
it("can get corrected and given new references", | ||
mock.initConverse([], {}, async function (_converse) { | ||
|
||
const nick = 'tom'; | ||
const muc_jid = '[email protected]'; | ||
const { api } = _converse; | ||
const { jid: own_jid } = api.connection.get(); | ||
|
||
// Making the MUC non-anonymous so that real JIDs are included | ||
const features = [ | ||
|
@@ -432,17 +438,17 @@ describe("A sent groupchat message", function () { | |
|
||
const sent_stanzas = _converse.api.connection.get().sent_stanzas; | ||
const msg = await u.waitUntil(() => sent_stanzas.filter(s => s.nodeName.toLowerCase() === 'message').pop()); | ||
expect(Strophe.serialize(msg)) | ||
.toBe(`<message from="${muc_jid}/${nick}" id="${msg.getAttribute("id")}" `+ | ||
`to="[email protected]" type="groupchat" `+ | ||
`xmlns="jabber:client">`+ | ||
`<body>hello z3r0 gibson mr.robot, how are you?</body>`+ | ||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ | ||
`<reference begin="6" end="10" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/>`+ | ||
`<reference begin="11" end="17" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/>`+ | ||
`<reference begin="18" end="26" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/>`+ | ||
`<origin-id id="${msg.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+ | ||
`</message>`); | ||
expect(msg).toEqualStanza(stx` | ||
<message from="${own_jid}" id="${msg.getAttribute("id")}" | ||
to="[email protected]" type="groupchat" | ||
xmlns="jabber:client"> | ||
<body>hello z3r0 gibson mr.robot, how are you?</body> | ||
<active xmlns="http://jabber.org/protocol/chatstates"/> | ||
<reference begin="6" end="10" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/> | ||
<reference begin="11" end="17" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/> | ||
<reference begin="18" end="26" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/> | ||
<origin-id id="${msg.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/> | ||
</message>`); | ||
|
||
const action = await u.waitUntil(() => view.querySelector('.chat-msg .chat-msg__action')); | ||
action.style.opacity = 1; | ||
|
@@ -459,23 +465,25 @@ describe("A sent groupchat message", function () { | |
'hello z3r0 gibson sw0rdf1sh, how are you?', 500); | ||
|
||
const correction = sent_stanzas.filter(s => s.nodeName.toLowerCase() === 'message').pop(); | ||
expect(Strophe.serialize(correction)) | ||
.toBe(`<message from="${muc_jid}/${nick}" id="${correction.getAttribute("id")}" `+ | ||
`to="[email protected]" type="groupchat" `+ | ||
`xmlns="jabber:client">`+ | ||
`<body>hello z3r0 gibson sw0rdf1sh, how are you?</body>`+ | ||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ | ||
`<reference begin="6" end="10" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/>`+ | ||
`<reference begin="11" end="17" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/>`+ | ||
`<reference begin="18" end="27" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/>`+ | ||
`<replace id="${msg.getAttribute("id")}" xmlns="urn:xmpp:message-correct:0"/>`+ | ||
`<origin-id id="${correction.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+ | ||
`</message>`); | ||
expect(correction).toEqualStanza(stx` | ||
<message from="${own_jid}" id="${correction.getAttribute("id")}" | ||
to="[email protected]" type="groupchat" | ||
xmlns="jabber:client"> | ||
<body>hello z3r0 gibson sw0rdf1sh, how are you?</body> | ||
<active xmlns="http://jabber.org/protocol/chatstates"/> | ||
<reference begin="6" end="10" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/> | ||
<reference begin="11" end="17" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/> | ||
<reference begin="18" end="27" type="mention" uri="xmpp:[email protected]" xmlns="urn:xmpp:reference:0"/> | ||
<replace id="${msg.getAttribute("id")}" xmlns="urn:xmpp:message-correct:0"/> | ||
<origin-id id="${correction.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/> | ||
</message>`); | ||
})); | ||
|
||
it("includes a XEP-0372 references to that person", | ||
mock.initConverse([], { auto_register_muc_nickname: false }, async function (_converse) { | ||
|
||
const { api } = _converse; | ||
const { jid: own_jid } = api.connection.get(); | ||
const nick = 'romeo'; | ||
const muc_jid = '[email protected]'; | ||
const muc = await mock.openAndEnterChatRoom(_converse, muc_jid, nick); | ||
|
@@ -509,7 +517,7 @@ describe("A sent groupchat message", function () { | |
|
||
const msg = _converse.api.connection.get().send.calls.all()[0].args[0]; | ||
expect(msg).toEqualStanza( | ||
stx`<message from="${muc_jid}/${nick}" | ||
stx`<message from="${own_jid}" | ||
id="${msg.getAttribute("id")}" | ||
to="[email protected]" | ||
type="groupchat" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ const { Strophe, u, stx } = converse.env; | |
|
||
describe("A Groupchat Message", function () { | ||
|
||
beforeAll(() => jasmine.addMatchers({ toEqualStanza: jasmine.toEqualStanza })); | ||
|
||
it("will render an unfurl based on OGP data", mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) { | ||
const nick = 'romeo'; | ||
const muc_jid = '[email protected]'; | ||
|
@@ -404,6 +406,9 @@ describe("A Groupchat Message", function () { | |
|
||
it("will not render an unfurl that has been removed in a subsequent correction", | ||
mock.initConverse(['chatBoxesFetched'], { auto_register_muc_nickname: false }, async function (_converse) { | ||
|
||
const { api } = _converse; | ||
const { jid: own_jid } = api.connection.get(); | ||
const nick = 'romeo'; | ||
const muc_jid = '[email protected]'; | ||
await mock.openAndEnterChatRoom(_converse, muc_jid, nick); | ||
|
@@ -426,17 +431,15 @@ describe("A Groupchat Message", function () { | |
message_form.onKeyDown(enter_event); | ||
|
||
await u.waitUntil(() => view.querySelectorAll('.chat-msg').length === 1); | ||
expect(view.querySelector('.chat-msg__text').textContent) | ||
.toBe(unfurl_url); | ||
expect(view.querySelector('.chat-msg__text').textContent).toBe(unfurl_url); | ||
|
||
let msg = _converse.api.connection.get().send.calls.all()[1].args[0]; | ||
expect(Strophe.serialize(msg)) | ||
.toBe( | ||
`<message from="${muc_jid}/${nick}" id="${msg.getAttribute('id')}" to="${muc_jid}" type="groupchat" xmlns="jabber:client">`+ | ||
`<body>${unfurl_url}</body>`+ | ||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ | ||
`<origin-id id="${msg.querySelector('origin-id')?.getAttribute('id')}" xmlns="urn:xmpp:sid:0"/>`+ | ||
`</message>`); | ||
expect(msg).toEqualStanza(stx` | ||
<message from="${own_jid}" id="${msg.getAttribute('id')}" to="${muc_jid}" type="groupchat" xmlns="jabber:client"> | ||
<body>${unfurl_url}</body> | ||
<active xmlns="http://jabber.org/protocol/chatstates"/> | ||
<origin-id id="${msg.querySelector('origin-id')?.getAttribute('id')}" xmlns="urn:xmpp:sid:0"/> | ||
</message>`); | ||
|
||
const el = await u.waitUntil(() => view.querySelector('.chat-msg__text')); | ||
expect(el.textContent).toBe(unfurl_url); | ||
|
@@ -478,13 +481,12 @@ describe("A Groupchat Message", function () { | |
const getSentMessages = () => _converse.api.connection.get().send.calls.all().map(c => c.args[0]).filter(s => s.nodeName === 'message'); | ||
await u.waitUntil(() => getSentMessages().length == 2); | ||
msg = getSentMessages().pop(); | ||
expect(Strophe.serialize(msg)) | ||
.toBe( | ||
`<message from="${muc_jid}/${nick}" id="${msg.getAttribute('id')}" to="${muc_jid}" type="groupchat" xmlns="jabber:client">`+ | ||
`<body>never mind</body>`+ | ||
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ | ||
`<replace id="${msg.querySelector('replace')?.getAttribute('id')}" xmlns="urn:xmpp:message-correct:0"/>`+ | ||
`<origin-id id="${msg.querySelector('origin-id')?.getAttribute('id')}" xmlns="urn:xmpp:sid:0"/>`+ | ||
`</message>`); | ||
expect(msg).toEqualStanza(stx` | ||
<message from="${own_jid}" id="${msg.getAttribute('id')}" to="${muc_jid}" type="groupchat" xmlns="jabber:client"> | ||
<body>never mind</body> | ||
<active xmlns="http://jabber.org/protocol/chatstates"/> | ||
<replace id="${msg.querySelector('replace')?.getAttribute('id')}" xmlns="urn:xmpp:message-correct:0"/> | ||
<origin-id id="${msg.querySelector('origin-id')?.getAttribute('id')}" xmlns="urn:xmpp:sid:0"/> | ||
</message>`); | ||
})); | ||
}); |
Oops, something went wrong.