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
a95bb5b2
Commit
a95bb5b2
authored
May 20, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor tests so that IQ_ids always contains only XML stanzas
parent
7e515dd4
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
221 additions
and
238 deletions
+221
-238
spec/controlbox.js
spec/controlbox.js
+13
-13
spec/disco.js
spec/disco.js
+4
-4
spec/http-file-upload.js
spec/http-file-upload.js
+29
-32
spec/muc.js
spec/muc.js
+56
-64
spec/omemo.js
spec/omemo.js
+65
-65
spec/push.js
spec/push.js
+13
-16
spec/room_registration.js
spec/room_registration.js
+16
-20
spec/roomslist.js
spec/roomslist.js
+3
-3
spec/roster.js
spec/roster.js
+10
-12
tests/mock.js
tests/mock.js
+3
-0
tests/utils.js
tests/utils.js
+9
-9
No files found.
spec/controlbox.js
View file @
a95bb5b2
...
...
@@ -6,7 +6,8 @@
$msg
=
converse
.
env
.
$msg
,
$iq
=
converse
.
env
.
$iq
,
u
=
converse
.
env
.
utils
,
Strophe
=
converse
.
env
.
Strophe
;
Strophe
=
converse
.
env
.
Strophe
,
sizzle
=
converse
.
env
.
sizzle
;
describe
(
"
The Controlbox
"
,
function
()
{
...
...
@@ -232,27 +233,26 @@
expect
(
modal
.
name_auto_complete
).
toBe
(
undefined
);
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
let
sent_stanza
;
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
sent_stanza
=
iq
;
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
expect
(
!
_
.
isNull
(
modal
.
el
.
querySelector
(
'
form.add-xmpp-contact
'
))).
toBeTruthy
();
const
input_jid
=
modal
.
el
.
querySelector
(
'
input[name="jid"]
'
);
const
input_name
=
modal
.
el
.
querySelector
(
'
input[name="name"]
'
);
input_jid
.
value
=
'
someone@localhost
'
;
modal
.
el
.
querySelector
(
'
button[type="submit"]
'
).
click
();
await
test_utils
.
waitUntil
(()
=>
sent_stanza
.
nodeTree
.
matches
(
'
iq
'
));
expect
(
sent_stanza
.
toLocaleString
()).
toEqual
(
`<iq id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"><item jid="someone@localhost"/></query>`
+
`</iq>`
);
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
sent_stanza
=
await
test_utils
.
waitUntil
(
()
=>
IQ_stanzas
.
filter
(
s
=>
sizzle
(
`query[xmlns="
${
Strophe
.
NS
.
ROSTER
}
"]`
,
s
).
length
).
pop
()
);
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toEqual
(
`<iq id="
${
sent_stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"><item jid="someone@localhost"/></query>`
+
`</iq>`
);
done
();
}));
it
(
"
integrates with xhr_user_search_url to search for contacts
"
,
it
(
"
integrates with xhr_user_search_url to search for contacts
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
xhr_user_search_url
'
:
'
http://example.org/?
'
},
...
...
spec/disco.js
View file @
a95bb5b2
...
...
@@ -22,7 +22,7 @@
const
IQ_ids
=
_converse
.
connection
.
IQ_ids
;
test_utils
.
waitUntil
(
function
()
{
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
}).
length
>
0
;
},
300
).
then
(
function
()
{
/* <iq type='result'
...
...
@@ -52,7 +52,7 @@
* </iq>
*/
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
});
var
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
...
...
@@ -101,7 +101,7 @@
// Converse.js sees that the entity has a disco#items feature,
// so it will make a query for it.
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
}).
length
>
0
;
},
300
).
then
(
function
()
{
/* <iq type='result'
...
...
@@ -131,7 +131,7 @@
* </iq>
*/
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
});
var
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
...
...
spec/http-file-upload.js
View file @
a95bb5b2
...
...
@@ -21,7 +21,7 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[],
[]);
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)).
length
iq
=>
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)).
length
);
/* <iq type='result'
...
...
@@ -38,7 +38,7 @@
* </iq>
*/
let
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
});
const
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
...
...
@@ -69,7 +69,7 @@
// so it will make a query for it.
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
)
iq
=>
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
)
).
length
);
/* <iq from='montague.tld'
...
...
@@ -83,7 +83,7 @@
* </iq>
*/
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
});
const
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
...
...
@@ -105,7 +105,7 @@
// Converse.js sees that the entity has a disco#info feature,
// so it will make a query for it.
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
}).
length
>
0
;
},
300
);
});
...
...
@@ -113,12 +113,12 @@
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)
iq
=>
iq
.
querySelector
(
'
iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)
).
pop
()
);
const
IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
expect
(
stanza
.
toLocaleString
(
)).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="`
+
IQ_id
+
`" to="upload.localhost" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`</iq>`
);
...
...
@@ -274,11 +274,11 @@
view
.
model
.
sendFiles
([
file
]);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="upload.montague.tld"] request
'
)).
length
);
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="upload.montague.tld"] request
'
)).
length
);
const
iq
=
IQ_stanzas
.
pop
();
expect
(
iq
.
toLocaleString
(
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="dummy@localhost/resource" `
+
`id="
${
iq
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`to="upload.montague.tld" `
+
`type="get" `
+
`xmlns="jabber:client">`
+
...
...
@@ -293,7 +293,7 @@
const
stanza
=
u
.
toStanza
(
`
<iq from="upload.montague.tld"
id="
${
iq
.
nodeTree
.
getAttribute
(
"
id
"
)}
"
id="
${
iq
.
getAttribute
(
"
id
"
)}
"
to="dummy@localhost/resource"
type="result">
<slot xmlns="urn:xmpp:http:upload:0">
...
...
@@ -381,11 +381,11 @@
view
.
model
.
sendFiles
([
file
]);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="upload.montague.tld"] request
'
)).
length
);
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="upload.montague.tld"] request
'
)).
length
);
const
iq
=
IQ_stanzas
.
pop
();
expect
(
iq
.
toLocaleString
(
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="dummy@localhost/resource" `
+
`id="
${
iq
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`to="upload.montague.tld" `
+
`type="get" `
+
`xmlns="jabber:client">`
+
...
...
@@ -399,7 +399,7 @@
const
message
=
base_url
+
"
/logo/conversejs-filled.svg
"
;
const
stanza
=
u
.
toStanza
(
`
<iq from='upload.montague.tld'
id="
${
iq
.
nodeTree
.
getAttribute
(
'
id
'
)}
"
id="
${
iq
.
getAttribute
(
'
id
'
)}
"
to='dummy@localhost/resource'
type='result'>
<slot xmlns='urn:xmpp:http:upload:0'>
...
...
@@ -466,15 +466,14 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[],
[]);
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)).
length
iq
=>
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)).
length
);
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
let
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
});
var
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
const
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
from
'
:
'
localhost
'
,
...
...
@@ -502,12 +501,12 @@
// Converse.js sees that the entity has a disco#items feature,
// so it will make a query for it.
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
}).
length
>
0
;
},
300
);
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="localhost"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
});
var
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
...
...
@@ -530,15 +529,13 @@
// Converse.js sees that the entity has a disco#info feature,
// so it will make a query for it.
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
}).
length
>
0
;
},
300
);
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
});
var
IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
expect
(
stanza
.
toLocaleString
()).
toBe
(
stanza
=
_
.
find
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="upload.localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
));
const
IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
IQ_id
}
" to="upload.localhost" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`</iq>`
);
...
...
@@ -609,11 +606,11 @@
};
view
.
model
.
sendFiles
([
file
]);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
(
iq
)
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="upload.montague.tld"] request
'
)).
length
)
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="upload.montague.tld"] request
'
)).
length
)
const
iq
=
IQ_stanzas
.
pop
();
expect
(
iq
.
toLocaleString
(
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="dummy@localhost/resource" `
+
`id="
${
iq
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`to="upload.montague.tld" `
+
`type="get" `
+
`xmlns="jabber:client">`
+
...
...
@@ -628,7 +625,7 @@
const
message
=
base_url
+
"
/logo/conversejs-filled.svg
"
;
const
stanza
=
u
.
toStanza
(
`
<iq from="upload.montague.tld"
id="
${
iq
.
nodeTree
.
getAttribute
(
"
id
"
)}
"
id="
${
iq
.
getAttribute
(
"
id
"
)}
"
to="dummy@localhost/resource"
type="result">
<slot xmlns="urn:xmpp:http:upload:0">
...
...
spec/muc.js
View file @
a95bb5b2
...
...
@@ -281,11 +281,11 @@
}
});
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
let
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
let
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
()
,
'
nodeTree
'
)
);
)).
pop
());
// We pretend this is a new room, so no disco info is returned.
/* <iq from="jordie.langen@chat.example.org/converse.js-11659299" to="myroom@conference.chat.example.org" type="get">
...
...
@@ -316,13 +316,12 @@
* node="x-roomuser-item"/>
* </iq>
*/
const
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
s
=>
sizzle
(
`iq[to="
${
room_jid
}
"] query[node="x-roomuser-item"]`
,
s
.
nodeTree
).
length
s
=>
sizzle
(
`iq[to="
${
room_jid
}
"] query[node="x-roomuser-item"]`
,
s
).
length
).
pop
()
);
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
"
id
"
)}
" to="lounge@localhost" `
+
`type="get" xmlns="jabber:client">`
+
`<query node="x-roomuser-item" xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
...
...
@@ -1734,13 +1733,12 @@
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
let
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
let
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
()
,
'
nodeTree
'
)
)).
pop
()
);
// We pretend this is a new room, so no disco info is returned.
const
features_stanza
=
$iq
({
from
:
'
lounge@localhost
'
,
...
...
@@ -1762,13 +1760,12 @@
* node='x-roomuser-item'/>
* </iq>
*/
const
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
const
iq
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
s
=>
sizzle
(
`iq[to="
${
room_jid
}
"] query[node="x-roomuser-item"]`
,
s
.
nodeTree
).
length
s
=>
sizzle
(
`iq[to="
${
room_jid
}
"] query[node="x-roomuser-item"]`
,
s
).
length
).
pop
()
);
const
iq
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="lounge@localhost" `
+
`type="get" xmlns="jabber:client">`
+
`<query node="x-roomuser-item" xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
...
...
@@ -1788,7 +1785,7 @@
*/
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
node
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq
.
getAttribute
(
'
id
'
),
'
from
'
:
view
.
model
.
get
(
'
jid
'
),
'
to
'
:
_converse
.
connection
.
jid
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
,
'
node
'
:
'
x-roomuser-item
'
})
...
...
@@ -1863,9 +1860,7 @@
input
.
dispatchEvent
(
evt
);
let
sent_stanza
;
spyOn
(
_converse
.
connection
,
'
send
'
).
and
.
callFake
(
function
(
stanza
)
{
sent_stanza
=
stanza
;
});
spyOn
(
_converse
.
connection
,
'
send
'
).
and
.
callFake
(
stanza
=>
(
sent_stanza
=
stanza
));
const
hint
=
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.suggestion-box__results li
'
));
expect
(
input
.
value
).
toBe
(
'
Felix
'
);
expect
(
hint
.
textContent
).
toBe
(
'
Felix Amsel
'
);
...
...
@@ -2214,15 +2209,14 @@
const
room_jid
=
'
coven@chat.shakespeare.lit
'
;
await
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
some1
'
});
const
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
const
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
());
// Check that the groupchat queried for the feautures.
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
"
id
"
)}
" to="
${
room_jid
}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`</iq>`
);
...
...
@@ -2320,7 +2314,7 @@
const
IQs
=
_converse
.
connection
.
IQ_stanzas
;
let
iq
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
jid
}
"] query[xmlns="
${
Strophe
.
NS
.
MUC_OWNER
}
"]`
)).
pop
());
...
...
@@ -2328,7 +2322,7 @@
`<iq xmlns="jabber:client"
type="result"
to="dummy@localhost/pda"
from="room@conference.example.org" id="
${
iq
.
nodeTree
.
getAttribute
(
'
id
'
)}
">
from="room@conference.example.org" id="
${
iq
.
getAttribute
(
'
id
'
)}
">
<query xmlns="http://jabber.org/protocol/muc#owner">
<x xmlns="jabber:x:data" type="form">
<title>Configuration for room@conference.example.org</title>
...
...
@@ -2396,13 +2390,13 @@
sizzle
(
'
[name="muc#roomconfig_roomname"]
'
,
chatroomview
.
el
).
pop
().
value
=
"
New room name
"
chatroomview
.
el
.
querySelector
(
'
.btn-primary
'
).
click
();
iq
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQs
,
iq
=>
u
.
matchesSelector
(
iq
.
nodeTree
,
`iq[to="
${
jid
}
"][type="set"]`
)).
pop
());
iq
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQs
,
iq
=>
u
.
matchesSelector
(
iq
,
`iq[to="
${
jid
}
"][type="set"]`
)).
pop
());
const
result
=
$iq
({
"
xmlns
"
:
"
jabber:client
"
,
"
type
"
:
"
result
"
,
"
to
"
:
"
dummy@localhost/resource
"
,
"
from
"
:
"
lounge@muc.localhost
"
,
"
id
"
:
iq
.
nodeTree
.
getAttribute
(
'
id
'
)
"
id
"
:
iq
.
getAttribute
(
'
id
'
)
});
IQs
.
length
=
0
;
// Empty the array
...
...
@@ -2410,13 +2404,13 @@
iq
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
());
const
features_stanza
=
$iq
({
'
from
'
:
jid
,
'
id
'
:
iq
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq
.
getAttribute
(
'
id
'
),
'
to
'
:
'
dummy@localhost/desktop
'
,
'
type
'
:
'
result
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
...
...
@@ -2835,13 +2829,12 @@
});
_converse
.
connection
.
IQ_stanzas
=
[];
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
let
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="member"]
'
)).
pop
()
iq
=>
iq
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="member"]
'
)).
pop
()
);
iq_stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq id="
${
iq_stanza
.
getAttribute
(
'
id
'
)}
" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/muc#admin">`
+
`<item affiliation="member"/>`
+
...
...
@@ -2860,13 +2853,12 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
2
);
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="owner"]
'
)).
pop
()
iq
=>
iq
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="owner"]
'
)).
pop
()
);
iq_stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq id="
${
iq_stanza
.
getAttribute
(
'
id
'
)}
" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/muc#admin">`
+
`<item affiliation="owner"/>`
+
...
...
@@ -2885,13 +2877,12 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
2
);
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="admin"]
'
)).
pop
()
iq
=>
iq
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="admin"]
'
)).
pop
()
);
iq_stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq id="
${
iq_stanza
.
getAttribute
(
'
id
'
)}
" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/muc#admin">`
+
`<item affiliation="admin"/>`
+
...
...
@@ -3875,21 +3866,20 @@
});
await
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
dummy
'
});
const
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
let
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
());
// Check that the groupchat queried for the feautures.
let
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
"
id
"
)}
" to="
${
room_jid
}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`</iq>`
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
// State that the chat is members-only via the features IQ
var
features_stanza
=
$iq
({
const
features_stanza
=
$iq
({
from
:
'
coven@chat.shakespeare.lit
'
,
'
id
'
:
IQ_ids
.
pop
(),
'
to
'
:
'
dummy@localhost/desktop
'
,
...
...
@@ -4001,11 +3991,11 @@
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
owner_list_stanza
));
await
test_utils
.
waitUntil
(()
=>
IQ_ids
.
length
,
300
);
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/muc#admin"]`
)).
pop
()
,
'
nodeTree
'
)
);
)).
pop
());
expect
(
stanza
.
outerHTML
,
`<iq id="
${
IQ_ids
.
pop
()}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/muc#admin">`
+
...
...
@@ -4281,13 +4271,6 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
let
sent_stanza
,
IQ_id
;
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
sent_stanza
=
iq
;
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
test_utils
.
openControlBox
();
const
roomspanel
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
).
roomspanel
;
roomspanel
.
el
.
querySelector
(
'
.show-list-muc-modal
'
).
click
();
...
...
@@ -4302,19 +4285,28 @@
const
server_input
=
modal
.
el
.
querySelector
(
'
input[name="server"]
'
);
expect
(
server_input
.
placeholder
).
toBe
(
'
conference.example.org
'
);
const
input
=
server_input
.
value
=
'
chat.shakespear.lit
'
;
const
input
=
server_input
.
value
=
'
chat.shakespear
e
.lit
'
;
modal
.
el
.
querySelector
(
'
input[type="submit"]
'
).
click
();
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
);
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
IQ_id
}
" to="chat.shakespear.lit" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#items"/>`
+
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
sent_stanza
=
await
test_utils
.
waitUntil
(
()
=>
IQ_stanzas
.
filter
(
s
=>
sizzle
(
`query[xmlns="
${
Strophe
.
NS
.
DISCO_ITEMS
}
"]`
,
s
).
length
).
pop
()
);
const
id
=
sent_stanza
.
getAttribute
(
'
id
'
);
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
id
}
" `
+
`to="chat.shakespeare.lit" `
+
`type="get" `
+
`xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#items"/>`
+
`</iq>`
);
const
iq
=
$iq
({
from
:
'
muc.localhost
'
,
to
:
'
dummy@localhost/pda
'
,
id
:
IQ_
id
,
type
:
'
result
'
'
from
'
:
'
muc.localhost
'
,
'
to
'
:
'
dummy@localhost/pda
'
,
'
id
'
:
id
,
'
type
'
:
'
result
'
}).
c
(
'
query
'
)
.
c
(
'
item
'
,
{
jid
:
'
heath@chat.shakespeare.lit
'
,
name
:
'
A Lonely Heath
'
}).
up
()
.
c
(
'
item
'
,
{
jid
:
'
coven@chat.shakespeare.lit
'
,
name
:
'
A Dark Cave
'
}).
up
()
...
...
spec/omemo.js
View file @
a95bb5b2
...
...
@@ -8,7 +8,7 @@
async
function
deviceListFetched
(
_converse
,
jid
)
{
const
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
`iq[to="
${
jid
}
"] items[node="eu.siacs.conversations.axolotl.devicelist"]`
)
iq
=>
iq
.
querySelector
(
`iq[to="
${
jid
}
"] items[node="eu.siacs.conversations.axolotl.devicelist"]`
)
).
pop
());
await
test_utils
.
waitUntil
(()
=>
_converse
.
devicelists
.
get
(
jid
));
return
stanza
;
...
...
@@ -17,21 +17,21 @@
function
ownDeviceHasBeenPublished
(
_converse
)
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[from="
'
+
_converse
.
bare_jid
+
'
"] publish[node="eu.siacs.conversations.axolotl.devicelist"]
'
)
iq
=>
iq
.
querySelector
(
'
iq[from="
'
+
_converse
.
bare_jid
+
'
"] publish[node="eu.siacs.conversations.axolotl.devicelist"]
'
)
).
pop
();
}
function
bundleHasBeenPublished
(
_converse
)
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
publish[node="eu.siacs.conversations.axolotl.bundles:123456789"]
'
)
iq
=>
iq
.
querySelector
(
'
publish[node="eu.siacs.conversations.axolotl.bundles:123456789"]
'
)
).
pop
();
}
function
bundleFetched
(
_converse
,
jid
,
device_id
)
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
`iq[to="
${
jid
}
"] items[node="eu.siacs.conversations.axolotl.bundles:
${
device_id
}
"]`
)
iq
=>
iq
.
querySelector
(
`iq[to="
${
jid
}
"] items[node="eu.siacs.conversations.axolotl.bundles:
${
device_id
}
"]`
)
).
pop
();
}
...
...
@@ -44,7 +44,7 @@
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -57,7 +57,7 @@
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
...
@@ -65,7 +65,7 @@
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
...
@@ -106,7 +106,7 @@
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
let
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -132,7 +132,7 @@
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
contact_jid
,
'
555
'
));
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
...
...
@@ -151,7 +151,7 @@
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
_converse
.
bare_jid
,
'
482886413b977930064a5888b92134fe
'
));
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
...
...
@@ -275,8 +275,8 @@
// Wait for Converse to fetch newguy's device list
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
...
...
@@ -285,7 +285,7 @@
// The server returns his device list
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -318,7 +318,7 @@
console
.
log
(
"
Bundle fetched 4e30f35051b7b8b42abe083742187228
"
);
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
...
...
@@ -339,7 +339,7 @@
console
.
log
(
"
Bundle fetched 482886413b977930064a5888b92134fe
"
);
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
...
...
@@ -397,7 +397,7 @@
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
const
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -464,8 +464,8 @@
keyCode
:
13
// Enter
});
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
_converse
.
bare_jid
,
'
988349631
'
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="
${
_converse
.
bare_jid
}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
_converse
.
bare_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.bundles:988349631"/>`
+
`</pubsub>`
+
...
...
@@ -521,8 +521,8 @@
keyCode
:
13
// Enter
});
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
...
...
@@ -530,7 +530,7 @@
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -551,7 +551,7 @@
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
_converse
.
bare_jid
,
'
482886413b977930064a5888b92134fe
'
));
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
...
...
@@ -580,7 +580,7 @@
*/
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/pubsub
'
})
...
...
@@ -648,7 +648,7 @@
iq_stanza
=
await
deviceListFetched
(
_converse
,
contact_jid
);
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -665,8 +665,8 @@
await
test_utils
.
waitUntil
(()
=>
_converse
.
omemo_store
);
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`
+
`<item>`
+
...
...
@@ -719,8 +719,8 @@
// Wait until own devices are fetched
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="dummy@localhost" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="dummy@localhost" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
...
...
@@ -728,7 +728,7 @@
let
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -747,7 +747,7 @@
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
ownDeviceHasBeenPublished
(
_converse
));
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
...
@@ -755,7 +755,7 @@
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
...
@@ -840,8 +840,8 @@
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
ownDeviceHasBeenPublished
(
_converse
));
// Check that our own device is added again, but that removed
// devices are not added.
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
`id`
)}
" type="set" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
`id`
)}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="eu.siacs.conversations.axolotl.devicelist">`
+
`<item>`
+
...
...
@@ -891,8 +891,8 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="dummy@localhost" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="dummy@localhost" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
...
...
@@ -900,7 +900,7 @@
let
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -918,14 +918,14 @@
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
ownDeviceHasBeenPublished
(
_converse
));
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
...
@@ -1046,7 +1046,7 @@
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -1060,14 +1060,14 @@
iq_stanza
=
await
ownDeviceHasBeenPublished
(
_converse
);
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`
+
`<item>`
+
...
...
@@ -1097,7 +1097,7 @@
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
...
@@ -1122,8 +1122,8 @@
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="dummy@localhost" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="dummy@localhost" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
...
...
@@ -1131,7 +1131,7 @@
let
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -1148,8 +1148,8 @@
expect
(
devicelist
.
devices
.
at
(
1
).
get
(
'
id
'
)).
toBe
(
'
123456789
'
);
// Check that own device was published
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
ownDeviceHasBeenPublished
(
_converse
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
`id`
)}
" type="set" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
`id`
)}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="eu.siacs.conversations.axolotl.devicelist">`
+
`<item>`
+
...
...
@@ -1174,12 +1174,12 @@
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
const
iq_el
=
await
test_utils
.
waitUntil
(()
=>
_
.
get
(
bundleHasBeenPublished
(
_converse
),
'
nodeTree
'
));
const
iq_el
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
expect
(
iq_el
.
getAttributeNames
().
sort
().
join
()).
toBe
([
"
from
"
,
"
type
"
,
"
xmlns
"
,
"
id
"
].
sort
().
join
());
expect
(
iq_el
.
querySelector
(
'
prekeys
'
).
childNodes
.
length
).
toBe
(
100
);
...
...
@@ -1199,8 +1199,8 @@
await
_converse
.
api
.
waitUntil
(
'
OMEMOInitialized
'
,
1000
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
...
...
@@ -1208,7 +1208,7 @@
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -1328,8 +1328,8 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
...
...
@@ -1337,7 +1337,7 @@
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -1414,8 +1414,8 @@
}).
tree
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
...
...
@@ -1423,7 +1423,7 @@
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
error
'
}).
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
...
...
@@ -1477,13 +1477,13 @@
const
modal
=
view
.
user_details_modal
;
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="max.frankfurter@localhost" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="max.frankfurter@localhost" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub>`
+
`</iq>`
);
let
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
...
...
@@ -1494,15 +1494,15 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
contact_jid
,
'
555
'
));
expect
(
iq_stanza
.
toLocaleString
(
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" to="max.frankfurter@localhost" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="max.frankfurter@localhost" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.bundles:555"/>`
+
`</pubsub>`
+
`</iq>`
);
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
pubsub
'
,
{
...
...
spec/push.js
View file @
a95bb5b2
...
...
@@ -29,11 +29,10 @@
_converse
.
bare_jid
,
[{
'
category
'
:
'
account
'
,
'
type
'
:
'
registered
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
);
const
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
const
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
);
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toEqual
(
expect
(
Strophe
.
serialize
(
stanza
)).
toEqual
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
'
<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>
'
+
'
</iq>
'
...
...
@@ -71,17 +70,17 @@
[{
'
category
'
:
'
account
'
,
'
type
'
:
'
registered
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
);
const
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
(
iq
)
=>
iq
.
nodeTree
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
()
=>
_
.
filter
(
IQ_stanzas
,
(
iq
)
=>
iq
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
);
expect
(
stanza
.
toLocaleString
(
)).
toEqual
(
`<iq id="
${
stanza
.
nodeTree
.
getAttribute
(
'
id
'
)}
" to="chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
stanza
)).
toEqual
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
'
<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>
'
+
'
</iq>
'
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$iq
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
id
'
:
stanza
.
nodeTree
.
getAttribute
(
'
id
'
)
'
id
'
:
stanza
.
getAttribute
(
'
id
'
)
})));
await
test_utils
.
waitUntil
(()
=>
_
.
includes
(
_converse
.
session
.
get
(
'
push_enabled
'
),
'
chat.shakespeare.lit
'
));
done
();
...
...
@@ -105,11 +104,10 @@
_converse
.
bare_jid
,
[{
'
category
'
:
'
account
'
,
'
type
'
:
'
registered
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
);
const
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[type="set"] disable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
const
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[type="set"] disable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
);
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toEqual
(
expect
(
Strophe
.
serialize
(
stanza
)).
toEqual
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
'
<disable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>
'
+
'
</iq>
'
...
...
@@ -147,11 +145,10 @@
[{
'
category
'
:
'
account
'
,
'
type
'
:
'
registered
'
}],
[
'
urn:xmpp:push:0
'
],
[],
'
info
'
);
const
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
const
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[type="set"] enable[xmlns="urn:xmpp:push:0"]
'
)).
pop
()
);
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toEqual
(
expect
(
Strophe
.
serialize
(
stanza
)).
toEqual
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
'
<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0">
'
+
'
<x type="submit" xmlns="jabber:x:data">
'
+
...
...
spec/room_registration.js
View file @
a95bb5b2
...
...
@@ -32,11 +32,10 @@
});
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`
,
iq
).
length
).
pop
());
}).
then
(
node
=>
{
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
())
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
))
.
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" `
+
`type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register"/></iq>`
);
...
...
@@ -56,11 +55,10 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`
,
iq
).
length
).
pop
());
}).
then
(
node
=>
{
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
...
...
@@ -83,15 +81,15 @@
function
(
done
,
_converse
)
{
let
view
;
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
room_jid
=
'
coven@chat.shakespeare.lit
'
;
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
romeo
'
})
.
then
(()
=>
{
return
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
()
,
'
nodeTree
'
)
);
)).
pop
());
}).
then
(
stanza
=>
{
const
features_stanza
=
$iq
({
'
from
'
:
room_jid
,
...
...
@@ -127,11 +125,10 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="get"] query[xmlns="jabber:iq:register"]`
,
iq
).
length
).
pop
());
}).
then
(
node
=>
{
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
())
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
))
.
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" `
+
`type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register"/></iq>`
);
...
...
@@ -151,11 +148,10 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[to="coven@chat.shakespeare.lit"][type="set"] query[xmlns="jabber:iq:register"]`
,
iq
).
length
).
pop
());
}).
then
(
node
=>
{
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
...
...
spec/roomslist.js
View file @
a95bb5b2
...
...
@@ -153,11 +153,11 @@
const
room_jid
=
'
coven@chat.shakespeare.lit
'
;
test_utils
.
openControlBox
();
await
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
some1
'
});
const
last_stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
const
last_stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
()
,
'
nodeTree
'
)
);
)).
pop
());
const
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
const
IQ_id
=
last_stanza
.
getAttribute
(
'
id
'
);
const
features_stanza
=
$iq
({
...
...
spec/roster.js
View file @
a95bb5b2
...
...
@@ -37,18 +37,18 @@
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
const
IQs
=
_converse
.
connection
.
IQ_stanzas
;
const
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
());
const
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
());
expect
(
_converse
.
api
.
trigger
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterContactsFetched
'
)).
toBeFalsy
();
expect
(
node
.
toLocaleString
(
)).
toBe
(
`<iq id="
${
node
.
nodeTree
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"/>`
+
`</iq>`
);
const
result
=
$iq
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
id
'
:
node
.
nodeTree
.
getAttribute
(
'
id
'
)
'
id
'
:
stanza
.
getAttribute
(
'
id
'
)
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
}).
c
(
'
item
'
,
{
'
jid
'
:
'
nurse@example.com
'
}).
up
()
...
...
@@ -64,12 +64,11 @@
async
function
(
done
,
_converse
)
{
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
let
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
()
let
stanza
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
()
);
let
stanza
=
node
.
nodeTree
;
expect
(
_converse
.
roster
.
data
.
get
(
'
version
'
)).
toBeUndefined
();
expect
(
node
.
toLocaleString
(
)).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"/>`
+
`</iq>`
);
...
...
@@ -89,9 +88,8 @@
expect
(
_converse
.
roster
.
models
.
length
).
toBe
(
2
);
_converse
.
roster
.
fetchFromServer
();
node
=
_converse
.
connection
.
IQ_stanzas
.
pop
();
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
stanza
=
_converse
.
connection
.
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq id="
${
stanza
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<query ver="ver7" xmlns="jabber:iq:roster"/>`
+
`</iq>`
);
...
...
tests/mock.js
View file @
a95bb5b2
...
...
@@ -117,6 +117,9 @@
c
.
IQ_stanzas
=
[];
c
.
IQ_ids
=
[];
c
.
sendIQ
=
function
(
iq
,
callback
,
errback
)
{
if
(
!
_
.
isElement
(
iq
))
{
iq
=
iq
.
nodeTree
;
}
this
.
IQ_stanzas
.
push
(
iq
);
const
id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
this
.
IQ_ids
.
push
(
id
);
...
...
tests/utils.js
View file @
a95bb5b2
...
...
@@ -19,14 +19,14 @@
const
iq
=
await
utils
.
waitUntil
(()
=>
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
sizzle
(
`iq[to="
${
entity_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#
${
type
}
"]`
,
iq
.
nodeTree
).
length
(
iq
)
=>
sizzle
(
`iq[to="
${
entity_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#
${
type
}
"]`
,
iq
).
length
).
pop
();
},
300
);
const
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
from
'
:
entity_jid
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
id
'
:
iq
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq
.
getAttribute
(
'
id
'
),
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#
'
+
type
});
_
.
forEach
(
identities
,
function
(
identity
)
{
...
...
@@ -123,11 +123,11 @@
const
stanzas
=
_converse
.
connection
.
IQ_stanzas
;
await
_converse
.
api
.
rooms
.
open
(
room_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
let
stanza
=
await
utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
let
stanza
=
await
utils
.
waitUntil
(()
=>
_
.
filter
(
stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
iq
=>
iq
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
()
,
'
nodeTree
'
)
);
)).
pop
());
const
features_stanza
=
$iq
({
'
from
'
:
room_jid
,
...
...
@@ -164,14 +164,14 @@
const
iq
=
await
utils
.
waitUntil
(()
=>
_
.
filter
(
stanzas
,
s
=>
sizzle
(
`iq[to="
${
room_jid
}
"] query[node="x-roomuser-item"]`
,
s
.
nodeTree
).
length
s
=>
sizzle
(
`iq[to="
${
room_jid
}
"] query[node="x-roomuser-item"]`
,
s
).
length
).
pop
());
// We remove the stanza, otherwise we might get stale stanzas returned in our filter above.
stanzas
.
splice
(
stanzas
.
indexOf
(
iq
),
1
)
// The XMPP server returns the reserved nick for this user.
const
IQ_id
=
iq
.
nodeTree
.
getAttribute
(
'
id
'
);
const
IQ_id
=
iq
.
getAttribute
(
'
id
'
);
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
id
'
:
IQ_id
,
...
...
@@ -266,13 +266,13 @@
const
iq
=
await
utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
sizzle
(
`iq[type="get"] query[xmlns="
${
Strophe
.
NS
.
ROSTER
}
"]`
,
iq
.
nodeTree
).
length
iq
=>
sizzle
(
`iq[type="get"] query[xmlns="
${
Strophe
.
NS
.
ROSTER
}
"]`
,
iq
).
length
).
pop
());
const
result
=
$iq
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
id
'
:
iq
.
nodeTree
.
getAttribute
(
'
id
'
)
'
id
'
:
iq
.
getAttribute
(
'
id
'
)
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
});
...
...
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