Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
eed9ee80
Commit
eed9ee80
authored
Dec 14, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RAI: Add tests
parent
e80afbfe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
3 deletions
+101
-3
karma.conf.js
karma.conf.js
+1
-0
spec/rai.js
spec/rai.js
+96
-0
src/headless/plugins/chat/model.js
src/headless/plugins/chat/model.js
+3
-2
src/headless/plugins/muc/muc.js
src/headless/plugins/muc/muc.js
+1
-1
No files found.
karma.conf.js
View file @
eed9ee80
...
...
@@ -50,6 +50,7 @@ module.exports = function(config) {
{
pattern
:
"
spec/styling.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/receipts.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/markers.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/rai.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/muc_messages.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/me-messages.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/mentions.js
"
,
type
:
'
module
'
},
...
...
spec/rai.js
0 → 100644
View file @
eed9ee80
/*global mock, converse */
const
{
Strophe
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
// See: https://xmpp.org/rfcs/rfc3921.html
fdescribe
(
"
XEP-0437 Room Activity Indicators
"
,
function
()
{
it
(
"
will be activated for a MUC that becomes hidden
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
],
{
'
muc_subscribe_to_rai
'
:
true
},
async
function
(
done
,
_converse
)
{
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
.
api
.
chatviews
.
get
(
muc_jid
);
expect
(
view
.
model
.
get
(
'
hidden
'
)).
toBe
(
false
);
const
sent_IQs
=
_converse
.
connection
.
IQ_stanzas
;
const
iq_get
=
await
u
.
waitUntil
(()
=>
sent_IQs
.
filter
(
iq
=>
iq
.
querySelector
(
`iq query[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
)).
pop
());
const
first_msg_id
=
_converse
.
connection
.
getUniqueId
();
const
last_msg_id
=
_converse
.
connection
.
getUniqueId
();
let
message
=
u
.
toStanza
(
`<message xmlns="jabber:client"
to="romeo@montague.lit/orchard"
from="
${
muc_jid
}
">
<result xmlns="urn:xmpp:mam:2" queryid="
${
iq_get
.
querySelector
(
'
query
'
).
getAttribute
(
'
queryid
'
)}
" id="
${
first_msg_id
}
">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2018-01-09T06:15:23Z"/>
<message from="
${
muc_jid
}
/some1" type="groupchat">
<body>1st MAM Message</body>
</message>
</forwarded>
</result>
</message>`
);
_converse
.
connection
.
_dataRecv
(
mock
.
createRequest
(
message
));
message
=
u
.
toStanza
(
`<message xmlns="jabber:client"
to="romeo@montague.lit/orchard"
from="
${
muc_jid
}
">
<result xmlns="urn:xmpp:mam:2" queryid="
${
iq_get
.
querySelector
(
'
query
'
).
getAttribute
(
'
queryid
'
)}
" id="
${
last_msg_id
}
">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2018-01-09T06:16:23Z"/>
<message from="
${
muc_jid
}
/some1" type="groupchat">
<body>2nd MAM Message</body>
</message>
</forwarded>
</result>
</message>`
);
_converse
.
connection
.
_dataRecv
(
mock
.
createRequest
(
message
));
const
result
=
u
.
toStanza
(
`<iq type='result' id='
${
iq_get
.
getAttribute
(
'
id
'
)}
'>
<fin xmlns='urn:xmpp:mam:2'>
<set xmlns='http://jabber.org/protocol/rsm'>
<first index='0'>
${
first_msg_id
}
</first>
<last>
${
last_msg_id
}
</last>
<count>2</count>
</set>
</fin>
</iq>`
);
_converse
.
connection
.
_dataRecv
(
mock
.
createRequest
(
result
));
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
===
2
);
const
sent_stanzas
=
[];
spyOn
(
_converse
.
connection
,
'
send
'
).
and
.
callFake
(
s
=>
sent_stanzas
.
push
(
s
?.
nodeTree
??
s
));
view
.
model
.
save
({
'
hidden
'
:
true
});
await
u
.
waitUntil
(()
=>
sent_stanzas
.
length
===
3
);
expect
(
Strophe
.
serialize
(
sent_stanzas
[
0
])).
toBe
(
`<message from="
${
_converse
.
jid
}
" id="
${
sent_stanzas
[
0
].
getAttribute
(
'
id
'
)}
" to="lounge@montague.lit" type="groupchat" xmlns="jabber:client">`
+
`<received id="
${
last_msg_id
}
" xmlns="urn:xmpp:chat-markers:0"/>`
+
`</message>`
);
expect
(
Strophe
.
serialize
(
sent_stanzas
[
1
])).
toBe
(
`<presence to="
${
muc_jid
}
/romeo" type="unavailable" xmlns="jabber:client">`
+
`<priority>0</priority>`
+
`<c hash="sha-1" node="https://conversejs.org" ver="PxXfr6uz8ClMWIga0OB/MhKNH/M=" xmlns="http://jabber.org/protocol/caps"/>`
+
`</presence>`
);
expect
(
Strophe
.
serialize
(
sent_stanzas
[
2
])).
toBe
(
`<presence to="montague.lit" xmlns="jabber:client">`
+
`<priority>0</priority>`
+
`<c hash="sha-1" node="https://conversejs.org" ver="PxXfr6uz8ClMWIga0OB/MhKNH/M=" xmlns="http://jabber.org/protocol/caps"/>`
+
`<rai xmlns="urn:xmpp:rai:0"/>`
+
`</presence>`
);
done
();
}));
});
src/headless/plugins/chat/model.js
View file @
eed9ee80
...
...
@@ -584,14 +584,15 @@ const ChatBox = ModelWithContact.extend({
/**
* Finds the last eligible message and then sends a XEP-0333 chat marker for it.
* @param { ('received'|'displayed'|'acknowledged') } [type='displayed']
* @param { Boolean } force - Whether a marker should be sent for the
* message, even if it didn't include a `markable` element.
*/
sendMarkerForLastMessage
(
force
=
false
)
{
sendMarkerForLastMessage
(
type
=
'
displayed
'
,
force
=
false
)
{
const
msgs
=
Array
.
from
(
this
.
messages
.
models
);
msgs
.
reverse
();
const
msg
=
msgs
.
find
(
m
=>
m
.
get
(
'
sender
'
)
===
'
them
'
&&
(
force
||
m
.
get
(
'
is_markable
'
)));
msg
&&
this
.
sendMarkerForMessage
(
msg
);
msg
&&
this
.
sendMarkerForMessage
(
msg
,
type
,
force
);
},
/**
...
...
src/headless/plugins/muc/muc.js
View file @
eed9ee80
...
...
@@ -207,7 +207,7 @@ const ChatRoomMixin = {
*/
async
onHiddenChange
()
{
if
(
this
.
get
(
'
hidden
'
)
&&
api
.
settings
.
get
(
'
muc_subscribe_to_rai
'
))
{
this
.
sendMarkerForLastMessage
(
true
);
this
.
sendMarkerForLastMessage
(
'
received
'
,
true
);
if
(
this
.
session
.
get
(
'
connection_status
'
)
!==
converse
.
ROOMSTATUS
.
DISCONNECTED
)
{
await
this
.
leave
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment