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
737e27c7
Commit
737e27c7
authored
Jun 03, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use shakespearean character names in tests
parent
5738b374
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
1098 additions
and
1102 deletions
+1098
-1102
mockup/mockup.js
mockup/mockup.js
+8
-8
spec/autocomplete.js
spec/autocomplete.js
+21
-21
spec/bookmarks.js
spec/bookmarks.js
+10
-10
spec/chatbox.js
spec/chatbox.js
+57
-57
spec/controlbox.js
spec/controlbox.js
+12
-12
spec/converse.js
spec/converse.js
+9
-9
spec/disco.js
spec/disco.js
+15
-15
spec/headline.js
spec/headline.js
+4
-4
spec/http-file-upload.js
spec/http-file-upload.js
+63
-63
spec/login.js
spec/login.js
+2
-2
spec/mam.js
spec/mam.js
+10
-10
spec/messages.js
spec/messages.js
+199
-199
spec/minchats.js
spec/minchats.js
+6
-6
spec/muc.js
spec/muc.js
+455
-455
spec/notification.js
spec/notification.js
+19
-19
spec/omemo.js
spec/omemo.js
+54
-54
spec/ping.js
spec/ping.js
+1
-1
spec/presence.js
spec/presence.js
+11
-11
spec/protocol.js
spec/protocol.js
+7
-7
spec/push.js
spec/push.js
+2
-2
spec/room_registration.js
spec/room_registration.js
+5
-5
spec/roomslist.js
spec/roomslist.js
+18
-18
spec/roster.js
spec/roster.js
+58
-62
spec/smacks.js
spec/smacks.js
+7
-7
spec/spoilers.js
spec/spoilers.js
+16
-16
spec/transcripts.js
spec/transcripts.js
+1
-1
spec/user-details-modal.js
spec/user-details-modal.js
+3
-3
src/headless/converse-core.js
src/headless/converse-core.js
+1
-1
tests/mock.js
tests/mock.js
+11
-11
tests/runner.js
tests/runner.js
+1
-1
tests/utils.js
tests/utils.js
+12
-12
No files found.
mockup/mockup.js
View file @
737e27c7
...
@@ -13,15 +13,15 @@
...
@@ -13,15 +13,15 @@
});
});
it
(
"
Show a chat room
"
,
function
()
{
it
(
"
Show a chat room
"
,
function
()
{
test_utils
.
openChatRoom
(
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
test_utils
.
openChatRoom
(
'
lounge
'
,
'
mongague.lit
'
,
'
romeo
'
);
var
view
=
converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
var
view
=
converse
.
chatboxviews
.
get
(
'
lounge@
mongague.li
t
'
);
if
(
!
view
.
$el
.
find
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
if
(
!
view
.
$el
.
find
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
var
text
=
'
This is a sent message
'
;
var
text
=
'
This is a sent message
'
;
view
.
$el
.
find
(
'
.chat-textarea
'
).
text
(
text
);
view
.
$el
.
find
(
'
.chat-textarea
'
).
text
(
text
);
view
.
$el
.
find
(
'
textarea.chat-textarea
'
).
trigger
(
$
.
Event
(
'
keypress
'
,
{
keyCode
:
13
}));
view
.
$el
.
find
(
'
textarea.chat-textarea
'
).
trigger
(
$
.
Event
(
'
keypress
'
,
{
keyCode
:
13
}));
var
message
=
$msg
({
var
message
=
$msg
({
from
:
'
lounge@
localhost/dummy
'
,
from
:
'
lounge@
mongague.lit/romeo
'
,
to
:
'
dummy@localhos
t.com
'
,
to
:
'
romeo@mongague.li
t.com
'
,
type
:
'
groupchat
'
,
type
:
'
groupchat
'
,
id
:
view
.
model
.
messages
.
at
(
0
).
get
(
'
msgid
'
)
id
:
view
.
model
.
messages
.
at
(
0
).
get
(
'
msgid
'
)
}).
c
(
'
body
'
).
t
(
text
);
}).
c
(
'
body
'
).
t
(
text
);
...
@@ -30,9 +30,9 @@
...
@@ -30,9 +30,9 @@
var
nick
=
mock
.
chatroom_names
[
0
];
var
nick
=
mock
.
chatroom_names
[
0
];
text
=
'
This is a received message
'
;
text
=
'
This is a received message
'
;
message
=
$msg
({
message
=
$msg
({
from
:
'
lounge@
localhos
t/
'
+
nick
,
from
:
'
lounge@
mongague.li
t/
'
+
nick
,
id
:
'
1
'
,
id
:
'
1
'
,
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@mongague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
}).
c
(
'
body
'
).
t
(
text
);
view
.
onChatRoomMessage
(
message
.
nodeTree
);
view
.
onChatRoomMessage
(
message
.
nodeTree
);
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
$msg
({
$msg
({
'
type
'
:
'
headline
'
,
'
type
'
:
'
headline
'
,
'
from
'
:
'
notify.example.com
'
,
'
from
'
:
'
notify.example.com
'
,
'
to
'
:
'
dummy@localhos
t
'
,
'
to
'
:
'
romeo@mongague.li
t
'
,
'
xml:lang
'
:
'
en
'
'
xml:lang
'
:
'
en
'
})
})
.
c
(
'
subject
'
).
t
(
'
MAIL
'
).
up
()
.
c
(
'
subject
'
).
t
(
'
MAIL
'
).
up
()
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
});
});
xit
(
"
Show a private chat box
"
,
function
()
{
xit
(
"
Show a private chat box
"
,
function
()
{
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
mongague.li
t
'
;
var
chatbox
=
test_utils
.
openChatBoxFor
(
contact_jid
);
var
chatbox
=
test_utils
.
openChatBoxFor
(
contact_jid
);
var
view
=
converse
.
chatboxviews
.
get
(
contact_jid
);
var
view
=
converse
.
chatboxviews
.
get
(
contact_jid
);
var
message
=
'
This message is sent from this chatbox
'
;
var
message
=
'
This message is sent from this chatbox
'
;
...
...
spec/autocomplete.js
View file @
737e27c7
...
@@ -20,19 +20,19 @@
...
@@ -20,19 +20,19 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhos
t
'
,
'
tom
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.li
t
'
,
'
tom
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
[
'
dick
'
,
'
harry
'
].
forEach
((
nick
)
=>
{
[
'
dick
'
,
'
harry
'
].
forEach
((
nick
)
=>
{
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$pres
({
$pres
({
'
to
'
:
'
tom@
localhos
t/resource
'
,
'
to
'
:
'
tom@
montague.li
t/resource
'
,
'
from
'
:
`lounge@
localhos
t/
${
nick
}
`
'
from
'
:
`lounge@
montague.li
t/
${
nick
}
`
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
`
${
nick
}
@
localhos
t/resource`
,
'
jid
'
:
`
${
nick
}
@
montague.li
t/resource`
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
})));
})));
});
});
...
@@ -62,17 +62,17 @@
...
@@ -62,17 +62,17 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
1
);
let
presence
=
$pres
({
let
presence
=
$pres
({
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
from
'
:
'
lounge@
localhos
t/some1
'
'
from
'
:
'
lounge@
montague.li
t/some1
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
some1@
localhos
t/resource
'
,
'
jid
'
:
'
some1@
montague.li
t/resource
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
});
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
...
@@ -109,13 +109,13 @@
...
@@ -109,13 +109,13 @@
expect
(
view
.
el
.
querySelector
(
'
.suggestion-box__results
'
).
hidden
).
toBeTruthy
();
expect
(
view
.
el
.
querySelector
(
'
.suggestion-box__results
'
).
hidden
).
toBeTruthy
();
presence
=
$pres
({
presence
=
$pres
({
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
from
'
:
'
lounge@
localhos
t/some2
'
'
from
'
:
'
lounge@
montague.li
t/some2
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
some2@
localhos
t/resource
'
,
'
jid
'
:
'
some2@
montague.li
t/resource
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
});
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
...
@@ -148,13 +148,13 @@
...
@@ -148,13 +148,13 @@
// Test that pressing tab twice selects
// Test that pressing tab twice selects
presence
=
$pres
({
presence
=
$pres
({
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
from
'
:
'
lounge@
localhos
t/z3r0
'
'
from
'
:
'
lounge@
montague.li
t/z3r0
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
z3r0@
localhos
t/resource
'
,
'
jid
'
:
'
z3r0@
montague.li
t/resource
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
});
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
...
@@ -173,17 +173,17 @@
...
@@ -173,17 +173,17 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
1
);
const
presence
=
$pres
({
const
presence
=
$pres
({
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
from
'
:
'
lounge@
localhos
t/some1
'
'
from
'
:
'
lounge@
montague.li
t/some1
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
some1@
localhos
t/resource
'
,
'
jid
'
:
'
some1@
montague.li
t/resource
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
});
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
...
...
spec/bookmarks.js
View file @
737e27c7
...
@@ -96,7 +96,7 @@
...
@@ -96,7 +96,7 @@
await
test_utils
.
waitUntil
(()
=>
sent_stanza
);
await
test_utils
.
waitUntil
(()
=>
sent_stanza
);
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard
" id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="storage:bookmarks">`
+
`<publish node="storage:bookmarks">`
+
`<item id="current">`
+
`<item id="current">`
+
...
@@ -154,7 +154,7 @@
...
@@ -154,7 +154,7 @@
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
bookmarks
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
bookmarks
);
let
jid
=
'
lounge@
localhos
t
'
;
let
jid
=
'
lounge@
montague.li
t
'
;
_converse
.
bookmarks
.
create
({
_converse
.
bookmarks
.
create
({
'
jid
'
:
jid
,
'
jid
'
:
jid
,
'
autojoin
'
:
false
,
'
autojoin
'
:
false
,
...
@@ -222,8 +222,8 @@
...
@@ -222,8 +222,8 @@
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
);
await
_converse
.
api
.
rooms
.
open
(
`lounge@
localhos
t`
);
await
_converse
.
api
.
rooms
.
open
(
`lounge@
montague.li
t`
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
let
bookmark_icon
=
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.toggle-bookmark
'
));
let
bookmark_icon
=
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.toggle-bookmark
'
));
expect
(
_
.
includes
(
bookmark_icon
.
classList
,
'
button-on
'
)).
toBeFalsy
();
expect
(
_
.
includes
(
bookmark_icon
.
classList
,
'
button-on
'
)).
toBeFalsy
();
_converse
.
bookmarks
.
create
({
_converse
.
bookmarks
.
create
({
...
@@ -289,7 +289,7 @@
...
@@ -289,7 +289,7 @@
// conferences to bookmark (since we removed the one and
// conferences to bookmark (since we removed the one and
// only bookmark).
// only bookmark).
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard
" id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="storage:bookmarks">`
+
`<publish node="storage:bookmarks">`
+
`<item id="current">`
+
`<item id="current">`
+
...
@@ -389,8 +389,8 @@
...
@@ -389,8 +389,8 @@
* </message>
* </message>
*/
*/
var
stanza
=
$msg
({
var
stanza
=
$msg
({
'
from
'
:
'
dummy@localhos
t
'
,
'
from
'
:
'
romeo@montague.li
t
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
type
'
:
'
headline
'
,
'
type
'
:
'
headline
'
,
'
id
'
:
'
rnfoo1
'
'
id
'
:
'
rnfoo1
'
}).
c
(
'
event
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/pubsub#event
'
})
}).
c
(
'
event
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/pubsub#event
'
})
...
@@ -445,7 +445,7 @@
...
@@ -445,7 +445,7 @@
);
);
expect
(
Strophe
.
serialize
(
call
.
args
[
0
])).
toBe
(
expect
(
Strophe
.
serialize
(
call
.
args
[
0
])).
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
IQ_id
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard
" id="
${
IQ_id
}
" type="get" xmlns="jabber:client">`
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<items node="storage:bookmarks"/>
'
+
'
<items node="storage:bookmarks"/>
'
+
'
</pubsub>
'
+
'
</pubsub>
'
+
...
@@ -528,7 +528,7 @@
...
@@ -528,7 +528,7 @@
).
pop
()
).
pop
()
);
);
expect
(
Strophe
.
serialize
(
call
.
args
[
0
])).
toBe
(
expect
(
Strophe
.
serialize
(
call
.
args
[
0
])).
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
IQ_id
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard
" id="
${
IQ_id
}
" type="get" xmlns="jabber:client">`
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<items node="storage:bookmarks"/>
'
+
'
<items node="storage:bookmarks"/>
'
+
'
</pubsub>
'
+
'
</pubsub>
'
+
...
@@ -616,7 +616,7 @@
...
@@ -616,7 +616,7 @@
).
pop
()
).
pop
()
);
);
expect
(
Strophe
.
serialize
(
call
.
args
[
0
])).
toBe
(
expect
(
Strophe
.
serialize
(
call
.
args
[
0
])).
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
IQ_id
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard
" id="
${
IQ_id
}
" type="get" xmlns="jabber:client">`
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<items node="storage:bookmarks"/>
'
+
'
<items node="storage:bookmarks"/>
'
+
'
</pubsub>
'
+
'
</pubsub>
'
+
...
...
spec/chatbox.js
View file @
737e27c7
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
test_utils
.
sendMessage
(
view
,
'
/help
'
);
test_utils
.
sendMessage
(
view
,
'
/help
'
);
...
@@ -55,11 +55,11 @@
...
@@ -55,11 +55,11 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhos
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.li
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
test_utils
.
openControlBox
();
await
test_utils
.
openControlBox
();
expect
(
_converse
.
chatboxes
.
length
).
toEqual
(
1
);
expect
(
_converse
.
chatboxes
.
length
).
toEqual
(
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
let
message
=
'
/me is tired
'
;
let
message
=
'
/me is tired
'
;
const
msg
=
$msg
({
const
msg
=
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
...
@@ -73,12 +73,12 @@
...
@@ -73,12 +73,12 @@
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
1
);
expect
(
_
.
includes
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
,
'
**M
ax Frankfurter
'
)).
toBeTruthy
();
expect
(
_
.
includes
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
,
'
**M
ercutio
'
)).
toBeTruthy
();
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__text
'
).
textContent
).
toBe
(
'
is tired
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__text
'
).
textContent
).
toBe
(
'
is tired
'
);
message
=
'
/me is as well
'
;
message
=
'
/me is as well
'
;
await
test_utils
.
sendMessage
(
view
,
message
);
await
test_utils
.
sendMessage
(
view
,
message
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
2
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
2
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg__author:last
'
,
view
.
el
).
pop
().
textContent
.
trim
()
===
'
**
Max Mustermann
'
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg__author:last
'
,
view
.
el
).
pop
().
textContent
.
trim
()
===
'
**
Romeo Montague
'
);
const
last_el
=
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
();
const
last_el
=
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
();
expect
(
last_el
.
textContent
).
toBe
(
'
is as well
'
);
expect
(
last_el
.
textContent
).
toBe
(
'
is as well
'
);
expect
(
u
.
hasClass
(
'
chat-msg--followup
'
,
last_el
)).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
chat-msg--followup
'
,
last_el
)).
toBe
(
false
);
...
@@ -115,7 +115,7 @@
...
@@ -115,7 +115,7 @@
const
online_contacts
=
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact a.open-chat
'
);
const
online_contacts
=
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group .current-xmpp-contact a.open-chat
'
);
expect
(
online_contacts
.
length
).
toBe
(
15
);
expect
(
online_contacts
.
length
).
toBe
(
15
);
let
el
=
online_contacts
[
0
];
let
el
=
online_contacts
[
0
];
const
jid
=
el
.
textContent
.
trim
().
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
el
.
textContent
.
trim
().
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
el
.
click
();
el
.
click
();
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
2
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
2
);
const
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
const
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
...
@@ -126,7 +126,7 @@
...
@@ -126,7 +126,7 @@
online_contacts
[
1
].
click
();
online_contacts
[
1
].
click
();
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
3
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
3
);
el
=
online_contacts
[
1
];
el
=
online_contacts
[
1
];
const
new_jid
=
el
.
textContent
.
trim
().
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
new_jid
=
el
.
textContent
.
trim
().
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
new_chatboxview
=
_converse
.
chatboxviews
.
get
(
new_jid
);
const
new_chatboxview
=
_converse
.
chatboxviews
.
get
(
new_jid
);
expect
(
_converse
.
chatboxviews
.
trimChats
).
toHaveBeenCalled
();
expect
(
_converse
.
chatboxviews
.
trimChats
).
toHaveBeenCalled
();
// Check that new chat boxes are created to the left of the
// Check that new chat boxes are created to the left of the
...
@@ -140,11 +140,11 @@
...
@@ -140,11 +140,11 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<message from="
${
sender_jid
}
"
<message from="
${
sender_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>Hey\nHave you heard the news?</body>
<body>Hey\nHave you heard the news?</body>
</message>`
);
</message>`
);
...
@@ -161,11 +161,11 @@
...
@@ -161,11 +161,11 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<message from="
${
sender_jid
}
"
<message from="
${
sender_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<composing xmlns="http://jabber.org/protocol/chatstates"/>
<composing xmlns="http://jabber.org/protocol/chatstates"/>
</message>`
);
</message>`
);
const
message_promise
=
new
Promise
(
resolve
=>
_converse
.
api
.
listen
.
on
(
'
message
'
,
resolve
))
const
message_promise
=
new
Promise
(
resolve
=>
_converse
.
api
.
listen
.
on
(
'
message
'
,
resolve
))
...
@@ -209,7 +209,7 @@
...
@@ -209,7 +209,7 @@
for
(
i
=
0
;
i
<
online_contacts
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
online_contacts
.
length
;
i
++
)
{
const
el
=
online_contacts
[
i
];
const
el
=
online_contacts
[
i
];
jid
=
_
.
trim
(
el
.
textContent
.
trim
()).
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
_
.
trim
(
el
.
textContent
.
trim
()).
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
chatboxview
=
_converse
.
chatboxviews
.
get
(
jid
);
spyOn
(
chatboxview
,
'
minimize
'
).
and
.
callThrough
();
spyOn
(
chatboxview
,
'
minimize
'
).
and
.
callThrough
();
chatboxview
.
model
.
set
({
'
minimized
'
:
true
});
chatboxview
.
model
.
set
({
'
minimized
'
:
true
});
...
@@ -237,7 +237,7 @@
...
@@ -237,7 +237,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
chat
=
await
_converse
.
api
.
chats
.
create
(
sender_jid
,
{
'
minimized
'
:
true
});
const
chat
=
await
_converse
.
api
.
chats
.
create
(
sender_jid
,
{
'
minimized
'
:
true
});
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
>
1
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
>
1
);
const
chatBoxView
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
const
chatBoxView
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
...
@@ -257,14 +257,14 @@
...
@@ -257,14 +257,14 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// openControlBox was called earlier, so the controlbox is
// openControlBox was called earlier, so the controlbox is
// visible, but no other chat boxes have been created.
// visible, but no other chat boxes have been created.
expect
(
_converse
.
chatboxes
.
length
).
toEqual
(
1
);
expect
(
_converse
.
chatboxes
.
length
).
toEqual
(
1
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
el
=
sizzle
(
'
a.open-chat:contains("
'
+
view
.
model
.
getDisplayName
()
+
'
")
'
,
_converse
.
rosterview
.
el
).
pop
();
const
el
=
sizzle
(
'
a.open-chat:contains("
'
+
view
.
model
.
getDisplayName
()
+
'
")
'
,
_converse
.
rosterview
.
el
).
pop
();
const
jid
=
el
.
textContent
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
el
.
textContent
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
el
.
click
();
el
.
click
();
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
trigger
.
calls
.
count
(),
500
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
trigger
.
calls
.
count
(),
500
);
...
@@ -317,7 +317,7 @@
...
@@ -317,7 +317,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
7
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
7
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
controlview
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
),
// The controlbox is currently open
const
controlview
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
),
// The controlbox is currently open
...
@@ -352,7 +352,7 @@
...
@@ -352,7 +352,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
7
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
7
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
trimmed_chatboxes
=
_converse
.
minimized_chats
;
const
trimmed_chatboxes
=
_converse
.
minimized_chats
;
...
@@ -433,7 +433,7 @@
...
@@ -433,7 +433,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
3
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
3
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
contact_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
@@ -453,7 +453,7 @@
...
@@ -453,7 +453,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
toolbar
=
view
.
el
.
querySelector
(
'
ul.chat-toolbar
'
);
const
toolbar
=
view
.
el
.
querySelector
(
'
ul.chat-toolbar
'
);
...
@@ -484,7 +484,7 @@
...
@@ -484,7 +484,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
let
toolbar
,
call_button
;
let
toolbar
,
call_button
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
// First check that the button doesn't show if it's not enabled
// First check that the button doesn't show if it's not enabled
// via "visible_toolbar_buttons"
// via "visible_toolbar_buttons"
...
@@ -518,12 +518,12 @@
...
@@ -518,12 +518,12 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
let
stanza
=
u
.
toStanza
(
let
stanza
=
u
.
toStanza
(
`<message from="
${
sender_jid
}
"
`<message from="
${
sender_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<composing xmlns="http://jabber.org/protocol/chatstates"/>
<composing xmlns="http://jabber.org/protocol/chatstates"/>
<no-store xmlns="urn:xmpp:hints"/>
<no-store xmlns="urn:xmpp:hints"/>
<no-permanent-store xmlns="urn:xmpp:hints"/>
<no-permanent-store xmlns="urn:xmpp:hints"/>
...
@@ -533,7 +533,7 @@
...
@@ -533,7 +533,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
`<message from="
${
sender_jid
}
"
`<message from="
${
sender_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<paused xmlns="http://jabber.org/protocol/chatstates"/>
<paused xmlns="http://jabber.org/protocol/chatstates"/>
<no-store xmlns="urn:xmpp:hints"/>
<no-store xmlns="urn:xmpp:hints"/>
<no-permanent-store xmlns="urn:xmpp:hints"/>
<no-permanent-store xmlns="urn:xmpp:hints"/>
...
@@ -551,7 +551,7 @@
...
@@ -551,7 +551,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// <composing> state
// <composing> state
const
msg
=
$msg
({
const
msg
=
$msg
({
'
from
'
:
sender_jid
,
'
from
'
:
sender_jid
,
...
@@ -573,7 +573,7 @@
...
@@ -573,7 +573,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
spyOn
(
_converse
.
connection
,
'
send
'
);
spyOn
(
_converse
.
connection
,
'
send
'
);
...
@@ -596,7 +596,7 @@
...
@@ -596,7 +596,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -630,7 +630,7 @@
...
@@ -630,7 +630,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -672,7 +672,7 @@
...
@@ -672,7 +672,7 @@
// See XEP-0085 https://xmpp.org/extensions/xep-0085.html#definitions
// See XEP-0085 https://xmpp.org/extensions/xep-0085.html#definitions
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
...
@@ -713,12 +713,12 @@
...
@@ -713,12 +713,12 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
let
contact
,
sent_stanza
,
IQ_id
,
stanza
;
let
contact
,
sent_stanza
,
IQ_id
,
stanza
;
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhos
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.li
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
// Send a message from a different resource
// Send a message from a different resource
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
,
'
log
'
);
const
recipient_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
recipient_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
recipient_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
recipient_jid
);
const
msg
=
$msg
({
const
msg
=
$msg
({
'
from
'
:
_converse
.
bare_jid
,
'
from
'
:
_converse
.
bare_jid
,
...
@@ -759,7 +759,7 @@
...
@@ -759,7 +759,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group li
'
).
length
,
700
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group li
'
).
length
,
700
);
_converse
.
TIMEOUTS
.
PAUSED
=
200
;
// Make the timeout shorter so that we can test
_converse
.
TIMEOUTS
.
PAUSED
=
200
;
// Make the timeout shorter so that we can test
...
@@ -818,7 +818,7 @@
...
@@ -818,7 +818,7 @@
// TODO: only show paused state if the previous state was composing
// TODO: only show paused state if the previous state was composing
// See XEP-0085 https://xmpp.org/extensions/xep-0085.html#definitions
// See XEP-0085 https://xmpp.org/extensions/xep-0085.html#definitions
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
// <paused> state
// <paused> state
const
msg
=
$msg
({
const
msg
=
$msg
({
...
@@ -841,12 +841,12 @@
...
@@ -841,12 +841,12 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
let
contact
,
sent_stanza
,
IQ_id
,
stanza
;
let
contact
,
sent_stanza
,
IQ_id
,
stanza
;
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhos
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.li
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
// Send a message from a different resource
// Send a message from a different resource
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
,
'
log
'
);
const
recipient_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
recipient_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
recipient_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
recipient_jid
);
const
msg
=
$msg
({
const
msg
=
$msg
({
'
from
'
:
_converse
.
bare_jid
,
'
from
'
:
_converse
.
bare_jid
,
...
@@ -891,7 +891,7 @@
...
@@ -891,7 +891,7 @@
_converse
.
TIMEOUTS
.
INACTIVE
=
200
;
_converse
.
TIMEOUTS
.
INACTIVE
=
200
;
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
1000
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
1000
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -939,7 +939,7 @@
...
@@ -939,7 +939,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
spyOn
(
_converse
.
connection
,
'
send
'
);
spyOn
(
_converse
.
connection
,
'
send
'
);
...
@@ -958,7 +958,7 @@
...
@@ -958,7 +958,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -984,7 +984,7 @@
...
@@ -984,7 +984,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// See XEP-0085 https://xmpp.org/extensions/xep-0085.html#definitions
// See XEP-0085 https://xmpp.org/extensions/xep-0085.html#definitions
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
...
@@ -1028,7 +1028,7 @@
...
@@ -1028,7 +1028,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// <paused> state
// <paused> state
const
msg
=
$msg
({
const
msg
=
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
...
@@ -1057,7 +1057,7 @@
...
@@ -1057,7 +1057,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -1103,7 +1103,7 @@
...
@@ -1103,7 +1103,7 @@
expect
(
_converse
.
msg_counter
).
toBe
(
0
);
expect
(
_converse
.
msg_counter
).
toBe
(
0
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
const
previous_state
=
_converse
.
windowState
;
const
previous_state
=
_converse
.
windowState
;
...
@@ -1158,7 +1158,7 @@
...
@@ -1158,7 +1158,7 @@
spyOn
(
_converse
,
'
incrementMsgCounter
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
incrementMsgCounter
'
).
and
.
callThrough
();
_converse
.
saveWindowState
(
null
,
'
focus
'
);
_converse
.
saveWindowState
(
null
,
'
focus
'
);
const
message
=
'
This message will not increment the message counter
'
;
const
message
=
'
This message will not increment the message counter
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
msg
=
$msg
({
msg
=
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
to
:
_converse
.
connection
.
jid
,
...
@@ -1181,7 +1181,7 @@
...
@@ -1181,7 +1181,7 @@
// initial state
// initial state
expect
(
_converse
.
msg_counter
).
toBe
(
0
);
expect
(
_converse
.
msg_counter
).
toBe
(
0
);
const
message
=
'
This message will always increment the message counter from zero
'
,
const
message
=
'
This message will always increment the message counter from zero
'
,
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
msgFactory
=
function
()
{
msgFactory
=
function
()
{
return
$msg
({
return
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
...
@@ -1228,7 +1228,7 @@
...
@@ -1228,7 +1228,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
...
@@ -1246,7 +1246,7 @@
...
@@ -1246,7 +1246,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be read
'
);
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be read
'
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
...
@@ -1262,7 +1262,7 @@
...
@@ -1262,7 +1262,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msgFactory
=
function
()
{
const
msgFactory
=
function
()
{
return
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
return
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
};
};
...
@@ -1281,7 +1281,7 @@
...
@@ -1281,7 +1281,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msgFactory
=
()
=>
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
const
msgFactory
=
()
=>
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
...
@@ -1299,7 +1299,7 @@
...
@@ -1299,7 +1299,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msgFactory
=
()
=>
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
const
msgFactory
=
()
=>
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
...
@@ -1318,7 +1318,7 @@
...
@@ -1318,7 +1318,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msgFactory
=
()
=>
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
const
msgFactory
=
()
=>
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
...
@@ -1342,7 +1342,7 @@
...
@@ -1342,7 +1342,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
let
msg
,
indicator_el
;
let
msg
,
indicator_el
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
...
@@ -1367,7 +1367,7 @@
...
@@ -1367,7 +1367,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
let
indicator_el
,
msg
;
let
indicator_el
,
msg
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
...
@@ -1397,7 +1397,7 @@
...
@@ -1397,7 +1397,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msgFactory
=
()
=>
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be received as unread, but eventually will be read
'
);
const
msgFactory
=
()
=>
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be received as unread, but eventually will be read
'
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
...
@@ -1423,7 +1423,7 @@
...
@@ -1423,7 +1423,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
...
@@ -1447,7 +1447,7 @@
...
@@ -1447,7 +1447,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
const
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
...
@@ -1474,7 +1474,7 @@
...
@@ -1474,7 +1474,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
msgFactory
=
function
()
{
const
msgFactory
=
function
()
{
return
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be received as unread, but eventually will be read
'
);
return
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be received as unread, but eventually will be read
'
);
...
@@ -1502,7 +1502,7 @@
...
@@ -1502,7 +1502,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
const
msgFactory
=
function
()
{
const
msgFactory
=
function
()
{
return
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
return
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
...
@@ -1530,7 +1530,7 @@
...
@@ -1530,7 +1530,7 @@
const
base_url
=
document
.
URL
.
split
(
window
.
location
.
pathname
)[
0
],
const
base_url
=
document
.
URL
.
split
(
window
.
location
.
pathname
)[
0
],
message
=
"
geo:37.786971,-122.399677
"
,
message
=
"
geo:37.786971,-122.399677
"
,
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
...
spec/controlbox.js
View file @
737e27c7
...
@@ -48,13 +48,13 @@
...
@@ -48,13 +48,13 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
// Adding two contacts one with Capital initials and one with small initials of same JID (Case sensitive check)
// Adding two contacts one with Capital initials and one with small initials of same JID (Case sensitive check)
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
pend_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
mock
.
pend_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
none
'
,
subscription
:
'
none
'
,
ask
:
'
subscribe
'
,
ask
:
'
subscribe
'
,
fullname
:
mock
.
pend_names
[
0
]
fullname
:
mock
.
pend_names
[
0
]
});
});
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
pend_names
[
0
].
replace
(
/ /g
,
'
.
'
)
+
'
@
localhos
t
'
,
jid
:
mock
.
pend_names
[
0
].
replace
(
/ /g
,
'
.
'
)
+
'
@
montague.li
t
'
,
subscription
:
'
none
'
,
subscription
:
'
none
'
,
ask
:
'
subscribe
'
,
ask
:
'
subscribe
'
,
fullname
:
mock
.
pend_names
[
0
]
fullname
:
mock
.
pend_names
[
0
]
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
test_utils
.
createContacts
(
_converse
,
'
all
'
).
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
all
'
).
openControlBox
();
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
);
const
chatview
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
const
chatview
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
...
@@ -208,13 +208,13 @@
...
@@ -208,13 +208,13 @@
input_jid
.
value
=
'
someone@
'
;
input_jid
.
value
=
'
someone@
'
;
const
evt
=
new
Event
(
'
input
'
);
const
evt
=
new
Event
(
'
input
'
);
input_jid
.
dispatchEvent
(
evt
);
input_jid
.
dispatchEvent
(
evt
);
expect
(
modal
.
el
.
querySelector
(
'
.suggestion-box li
'
).
textContent
).
toBe
(
'
someone@
localhos
t
'
);
expect
(
modal
.
el
.
querySelector
(
'
.suggestion-box li
'
).
textContent
).
toBe
(
'
someone@
montague.li
t
'
);
input_jid
.
value
=
'
someone@
localhos
t
'
;
input_jid
.
value
=
'
someone@
montague.li
t
'
;
input_name
.
value
=
'
Someone
'
;
input_name
.
value
=
'
Someone
'
;
modal
.
el
.
querySelector
(
'
button[type="submit"]
'
).
click
();
modal
.
el
.
querySelector
(
'
button[type="submit"]
'
).
click
();
expect
(
sent_stanza
.
toLocaleString
()).
toEqual
(
expect
(
sent_stanza
.
toLocaleString
()).
toEqual
(
`<iq id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
`<iq id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"><item jid="someone@
localhos
t" name="Someone"/></query>`
+
`<query xmlns="jabber:iq:roster"><item jid="someone@
montague.li
t" name="Someone"/></query>`
+
`</iq>`
);
`</iq>`
);
done
();
done
();
}));
}));
...
@@ -236,7 +236,7 @@
...
@@ -236,7 +236,7 @@
expect
(
!
_
.
isNull
(
modal
.
el
.
querySelector
(
'
form.add-xmpp-contact
'
))).
toBeTruthy
();
expect
(
!
_
.
isNull
(
modal
.
el
.
querySelector
(
'
form.add-xmpp-contact
'
))).
toBeTruthy
();
const
input_jid
=
modal
.
el
.
querySelector
(
'
input[name="jid"]
'
);
const
input_jid
=
modal
.
el
.
querySelector
(
'
input[name="jid"]
'
);
const
input_name
=
modal
.
el
.
querySelector
(
'
input[name="name"]
'
);
const
input_name
=
modal
.
el
.
querySelector
(
'
input[name="name"]
'
);
input_jid
.
value
=
'
someone@
localhos
t
'
;
input_jid
.
value
=
'
someone@
montague.li
t
'
;
modal
.
el
.
querySelector
(
'
button[type="submit"]
'
).
click
();
modal
.
el
.
querySelector
(
'
button[type="submit"]
'
).
click
();
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
...
@@ -245,7 +245,7 @@
...
@@ -245,7 +245,7 @@
);
);
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toEqual
(
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toEqual
(
`<iq id="
${
sent_stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<iq id="
${
sent_stanza
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"><item jid="someone@
localhos
t"/></query>`
+
`<query xmlns="jabber:iq:roster"><item jid="someone@
montague.li
t"/></query>`
+
`</iq>`
`</iq>`
);
);
done
();
done
();
...
@@ -324,10 +324,10 @@
...
@@ -324,10 +324,10 @@
'
send
'
:
function
()
{
'
send
'
:
function
()
{
const
value
=
modal
.
el
.
querySelector
(
'
input[name="name"]
'
).
value
;
const
value
=
modal
.
el
.
querySelector
(
'
input[name="name"]
'
).
value
;
if
(
value
===
'
existing
'
)
{
if
(
value
===
'
existing
'
)
{
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
xhr
.
responseText
=
JSON
.
stringify
([{
"
jid
"
:
contact_jid
,
"
fullname
"
:
mock
.
cur_names
[
0
]}]);
xhr
.
responseText
=
JSON
.
stringify
([{
"
jid
"
:
contact_jid
,
"
fullname
"
:
mock
.
cur_names
[
0
]}]);
}
else
if
(
value
===
'
dummy
'
)
{
}
else
if
(
value
===
'
romeo
'
)
{
xhr
.
responseText
=
JSON
.
stringify
([{
"
jid
"
:
"
dummy@localhost
"
,
"
fullname
"
:
"
Max Mustermann
"
}]);
xhr
.
responseText
=
JSON
.
stringify
([{
"
jid
"
:
"
romeo@montague.lit
"
,
"
fullname
"
:
"
Romeo Montague
"
}]);
}
else
if
(
value
===
'
ambiguous
'
)
{
}
else
if
(
value
===
'
ambiguous
'
)
{
xhr
.
responseText
=
JSON
.
stringify
([
xhr
.
responseText
=
JSON
.
stringify
([
{
"
jid
"
:
"
marty@mcfly.net
"
,
"
fullname
"
:
"
Marty McFly
"
},
{
"
jid
"
:
"
marty@mcfly.net
"
,
"
fullname
"
:
"
Marty McFly
"
},
...
@@ -374,7 +374,7 @@
...
@@ -374,7 +374,7 @@
expect
(
feedback_el
.
textContent
).
toBe
(
'
Sorry, could not find a contact with that name
'
);
expect
(
feedback_el
.
textContent
).
toBe
(
'
Sorry, could not find a contact with that name
'
);
feedback_el
.
textContent
=
''
;
feedback_el
.
textContent
=
''
;
input_el
.
value
=
'
dummy
'
;
input_el
.
value
=
'
romeo
'
;
modal
.
el
.
querySelector
(
'
button[type="submit"]
'
).
click
();
modal
.
el
.
querySelector
(
'
button[type="submit"]
'
).
click
();
feedback_el
=
modal
.
el
.
querySelector
(
'
.invalid-feedback
'
);
feedback_el
=
modal
.
el
.
querySelector
(
'
.invalid-feedback
'
);
expect
(
feedback_el
.
textContent
).
toBe
(
'
You cannot add yourself as a contact
'
);
expect
(
feedback_el
.
textContent
).
toBe
(
'
You cannot add yourself as a contact
'
);
...
...
spec/converse.js
View file @
737e27c7
...
@@ -254,16 +254,16 @@
...
@@ -254,16 +254,16 @@
let
contact
=
await
_converse
.
api
.
contacts
.
get
(
'
non-existing@jabber.org
'
);
let
contact
=
await
_converse
.
api
.
contacts
.
get
(
'
non-existing@jabber.org
'
);
expect
(
contact
).
toBeFalsy
();
expect
(
contact
).
toBeFalsy
();
// Check when a single jid is given
// Check when a single jid is given
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
contact
=
await
_converse
.
api
.
contacts
.
get
(
jid
);
contact
=
await
_converse
.
api
.
contacts
.
get
(
jid
);
expect
(
contact
.
get
(
'
fullname
'
)).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
contact
.
get
DisplayName
(
)).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
contact
.
get
(
'
jid
'
)).
toBe
(
jid
);
expect
(
contact
.
get
(
'
jid
'
)).
toBe
(
jid
);
// You can retrieve multiple contacts by passing in an array
// You can retrieve multiple contacts by passing in an array
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
let
list
=
await
_converse
.
api
.
contacts
.
get
([
jid
,
jid2
]);
let
list
=
await
_converse
.
api
.
contacts
.
get
([
jid
,
jid2
]);
expect
(
Array
.
isArray
(
list
)).
toBeTruthy
();
expect
(
Array
.
isArray
(
list
)).
toBeTruthy
();
expect
(
list
[
0
].
get
(
'
fullname
'
)).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
list
[
0
].
get
DisplayName
(
)).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
list
[
1
].
get
(
'
fullname
'
)).
toBe
(
mock
.
cur_names
[
1
]);
expect
(
list
[
1
].
get
DisplayName
(
)).
toBe
(
mock
.
cur_names
[
1
]);
// Check that all JIDs are returned if you call without any parameters
// Check that all JIDs are returned if you call without any parameters
list
=
await
_converse
.
api
.
contacts
.
get
();
list
=
await
_converse
.
api
.
contacts
.
get
();
expect
(
list
.
length
).
toBe
(
mock
.
cur_names
.
length
);
expect
(
list
.
length
).
toBe
(
mock
.
cur_names
.
length
);
...
@@ -294,8 +294,8 @@
...
@@ -294,8 +294,8 @@
// Test on chat that doesn't exist.
// Test on chat that doesn't exist.
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// Test on chat that's not open
// Test on chat that's not open
let
box
=
_converse
.
api
.
chats
.
get
(
jid
);
let
box
=
_converse
.
api
.
chats
.
get
(
jid
);
...
@@ -327,8 +327,8 @@
...
@@ -327,8 +327,8 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
,
2
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
2
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// Test on chat that doesn't exist.
// Test on chat that doesn't exist.
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
expect
(
_converse
.
api
.
chats
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
...
...
spec/disco.js
View file @
737e27c7
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
const
IQ_ids
=
_converse
.
connection
.
IQ_ids
;
const
IQ_ids
=
_converse
.
connection
.
IQ_ids
;
test_utils
.
waitUntil
(
function
()
{
test_utils
.
waitUntil
(
function
()
{
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
}).
length
>
0
;
}).
length
>
0
;
},
300
).
then
(
function
()
{
},
300
).
then
(
function
()
{
/* <iq type='result'
/* <iq type='result'
...
@@ -52,13 +52,13 @@
...
@@ -52,13 +52,13 @@
* </iq>
* </iq>
*/
*/
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
});
});
var
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
var
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
from
'
:
'
localhos
t
'
,
'
from
'
:
'
montague.li
t
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
info_IQ_id
'
id
'
:
info_IQ_id
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
.
c
(
'
identity
'
,
{
...
@@ -88,12 +88,12 @@
...
@@ -88,12 +88,12 @@
expect
(
entities
.
length
).
toBe
(
2
);
// We have an extra entity, which is the user's JID
expect
(
entities
.
length
).
toBe
(
2
);
// We have an extra entity, which is the user's JID
expect
(
entities
.
get
(
_converse
.
domain
).
features
.
length
).
toBe
(
5
);
expect
(
entities
.
get
(
_converse
.
domain
).
features
.
length
).
toBe
(
5
);
expect
(
entities
.
get
(
_converse
.
domain
).
identities
.
length
).
toBe
(
3
);
expect
(
entities
.
get
(
_converse
.
domain
).
identities
.
length
).
toBe
(
3
);
expect
(
entities
.
get
(
'
localhos
t
'
).
features
.
where
({
'
var
'
:
'
jabber:iq:version
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
montague.li
t
'
).
features
.
where
({
'
var
'
:
'
jabber:iq:version
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
localhos
t
'
).
features
.
where
({
'
var
'
:
'
jabber:iq:time
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
montague.li
t
'
).
features
.
where
({
'
var
'
:
'
jabber:iq:time
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
localhos
t
'
).
features
.
where
({
'
var
'
:
'
jabber:iq:register
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
montague.li
t
'
).
features
.
where
({
'
var
'
:
'
jabber:iq:register
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
localhos
t
'
).
features
.
where
(
expect
(
entities
.
get
(
'
montague.li
t
'
).
features
.
where
(
{
'
var
'
:
'
http://jabber.org/protocol/disco#items
'
}).
length
).
toBe
(
1
);
{
'
var
'
:
'
http://jabber.org/protocol/disco#items
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
localhos
t
'
).
features
.
where
(
expect
(
entities
.
get
(
'
montague.li
t
'
).
features
.
where
(
{
'
var
'
:
'
http://jabber.org/protocol/disco#info
'
}).
length
).
toBe
(
1
);
{
'
var
'
:
'
http://jabber.org/protocol/disco#info
'
}).
length
).
toBe
(
1
);
...
@@ -131,13 +131,13 @@
...
@@ -131,13 +131,13 @@
* </iq>
* </iq>
*/
*/
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
var
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
});
});
var
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
var
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
from
'
:
'
localhos
t
'
,
'
from
'
:
'
montague.li
t
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
items_IQ_id
'
id
'
:
items_IQ_id
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
...
@@ -151,14 +151,14 @@
...
@@ -151,14 +151,14 @@
'
name
'
:
'
Gateway to Marlowe IM
'
}).
up
()
'
name
'
:
'
Gateway to Marlowe IM
'
}).
up
()
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
jid
'
:
'
localhos
t
'
,
'
jid
'
:
'
montague.li
t
'
,
'
node
'
:
'
books
'
,
'
node
'
:
'
books
'
,
'
name
'
:
'
Books by and about Shakespeare
'
}).
up
()
'
name
'
:
'
Books by and about Shakespeare
'
}).
up
()
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
node
'
:
'
localhos
t
'
,
'
node
'
:
'
montague.li
t
'
,
'
name
'
:
'
Wear your literary taste with pride
'
}).
up
()
'
name
'
:
'
Wear your literary taste with pride
'
}).
up
()
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
jid
'
:
'
localhos
t
'
,
'
jid
'
:
'
montague.li
t
'
,
'
node
'
:
'
music
'
,
'
node
'
:
'
music
'
,
'
name
'
:
'
Music from the time of Shakespeare
'
'
name
'
:
'
Music from the time of Shakespeare
'
});
});
...
...
spec/headline.js
View file @
737e27c7
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
/* XMPP spam message:
/* XMPP spam message:
*
*
* <message xmlns="jabber:client"
* <message xmlns="jabber:client"
* to="
dummy@localhos
t"
* to="
romeo@montague.li
t"
* type="chat"
* type="chat"
* from="gapowa20102106@rds-rostov.ru/Adium">
* from="gapowa20102106@rds-rostov.ru/Adium">
* <nick xmlns="http://jabber.org/protocol/nick">-wwdmz</nick>
* <nick xmlns="http://jabber.org/protocol/nick">-wwdmz</nick>
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
sinon
.
spy
(
utils
,
'
isHeadlineMessage
'
);
sinon
.
spy
(
utils
,
'
isHeadlineMessage
'
);
const
stanza
=
$msg
({
const
stanza
=
$msg
({
'
xmlns
'
:
'
jabber:client
'
,
'
xmlns
'
:
'
jabber:client
'
,
'
to
'
:
'
dummy@localhos
t
'
,
'
to
'
:
'
romeo@montague.li
t
'
,
'
type
'
:
'
chat
'
,
'
type
'
:
'
chat
'
,
'
from
'
:
'
gapowa20102106@rds-rostov.ru/Adium
'
,
'
from
'
:
'
gapowa20102106@rds-rostov.ru/Adium
'
,
})
})
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
const
stanza
=
$msg
({
const
stanza
=
$msg
({
'
type
'
:
'
headline
'
,
'
type
'
:
'
headline
'
,
'
from
'
:
'
notify.example.com
'
,
'
from
'
:
'
notify.example.com
'
,
'
to
'
:
'
dummy@localhos
t
'
,
'
to
'
:
'
romeo@montague.li
t
'
,
'
xml:lang
'
:
'
en
'
'
xml:lang
'
:
'
en
'
})
})
.
c
(
'
subject
'
).
t
(
'
SIEVE
'
).
up
()
.
c
(
'
subject
'
).
t
(
'
SIEVE
'
).
up
()
...
@@ -91,7 +91,7 @@
...
@@ -91,7 +91,7 @@
var
stanza
=
$msg
({
var
stanza
=
$msg
({
'
type
'
:
'
headline
'
,
'
type
'
:
'
headline
'
,
'
from
'
:
'
andre5114@jabber.snc.ru/Spark
'
,
'
from
'
:
'
andre5114@jabber.snc.ru/Spark
'
,
'
to
'
:
'
dummy@localhos
t
'
,
'
to
'
:
'
romeo@montague.li
t
'
,
'
xml:lang
'
:
'
en
'
'
xml:lang
'
:
'
en
'
})
})
.
c
(
'
nick
'
).
t
(
'
gpocy
'
).
up
()
.
c
(
'
nick
'
).
t
(
'
gpocy
'
).
up
()
...
...
spec/http-file-upload.js
View file @
737e27c7
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[],
[]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[],
[]);
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)).
length
iq
=>
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)).
length
);
);
/* <iq type='result'
/* <iq type='result'
...
@@ -39,13 +39,13 @@
...
@@ -39,13 +39,13 @@
*/
*/
let
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
let
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
return
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
});
});
const
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
const
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
from
'
:
'
localhos
t
'
,
'
from
'
:
'
montague.li
t
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
info_IQ_id
'
id
'
:
info_IQ_id
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
.
c
(
'
identity
'
,
{
...
@@ -59,8 +59,8 @@
...
@@ -59,8 +59,8 @@
let
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
();
let
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
();
expect
(
entities
.
length
).
toBe
(
2
);
expect
(
entities
.
length
).
toBe
(
2
);
expect
(
_
.
includes
(
entities
.
pluck
(
'
jid
'
),
'
localhos
t
'
)).
toBe
(
true
);
expect
(
_
.
includes
(
entities
.
pluck
(
'
jid
'
),
'
montague.li
t
'
)).
toBe
(
true
);
expect
(
_
.
includes
(
entities
.
pluck
(
'
jid
'
),
'
dummy@localhos
t
'
)).
toBe
(
true
);
expect
(
_
.
includes
(
entities
.
pluck
(
'
jid
'
),
'
romeo@montague.li
t
'
)).
toBe
(
true
);
expect
(
entities
.
get
(
_converse
.
domain
).
features
.
length
).
toBe
(
2
);
expect
(
entities
.
get
(
_converse
.
domain
).
features
.
length
).
toBe
(
2
);
expect
(
entities
.
get
(
_converse
.
domain
).
identities
.
length
).
toBe
(
1
);
expect
(
entities
.
get
(
_converse
.
domain
).
identities
.
length
).
toBe
(
1
);
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
// so it will make a query for it.
// so it will make a query for it.
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
)
iq
=>
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
)
).
length
).
length
);
);
/* <iq from='montague.tld'
/* <iq from='montague.tld'
...
@@ -83,29 +83,29 @@
...
@@ -83,29 +83,29 @@
* </iq>
* </iq>
*/
*/
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
});
});
const
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
const
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
from
'
:
'
localhos
t
'
,
'
from
'
:
'
montague.li
t
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
items_IQ_id
'
id
'
:
items_IQ_id
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
jid
'
:
'
upload.
localhos
t
'
,
'
jid
'
:
'
upload.
montague.li
t
'
,
'
name
'
:
'
HTTP File Upload
'
});
'
name
'
:
'
HTTP File Upload
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
api
.
disco
.
entities
.
get
().
then
(
function
(
entities
)
{
_converse
.
api
.
disco
.
entities
.
get
().
then
(
function
(
entities
)
{
expect
(
entities
.
length
).
toBe
(
2
);
expect
(
entities
.
length
).
toBe
(
2
);
expect
(
entities
.
get
(
'
localhos
t
'
).
items
.
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
montague.li
t
'
).
items
.
length
).
toBe
(
1
);
return
test_utils
.
waitUntil
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
// Converse.js sees that the entity has a disco#info feature,
// Converse.js sees that the entity has a disco#info feature,
// so it will make a query for it.
// so it will make a query for it.
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="upload.
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="upload.
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
}).
length
>
0
;
}).
length
>
0
;
},
300
);
},
300
);
});
});
...
@@ -113,13 +113,13 @@
...
@@ -113,13 +113,13 @@
stanza
=
await
test_utils
.
waitUntil
(()
=>
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_
.
filter
(
IQ_stanzas
,
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="upload.
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)
iq
=>
iq
.
querySelector
(
'
iq[to="upload.
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)
).
pop
()
).
pop
()
);
);
const
IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
const
IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="
dummy@localhost/resource" id="`
+
IQ_id
+
`" to="upload.localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard" id="`
+
IQ_id
+
`" to="upload.montague.li
t" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`</iq>`
);
`</iq>`
);
...
@@ -144,7 +144,7 @@
...
@@ -144,7 +144,7 @@
* </query>
* </query>
* </iq>
* </iq>
*/
*/
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
id
'
:
IQ_id
,
'
from
'
:
'
upload.localhos
t
'
})
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
IQ_id
,
'
from
'
:
'
upload.montague.li
t
'
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
'
category
'
:
'
store
'
,
'
type
'
:
'
file
'
,
'
name
'
:
'
HTTP File Upload
'
}).
up
()
.
c
(
'
identity
'
,
{
'
category
'
:
'
store
'
,
'
type
'
:
'
file
'
,
'
name
'
:
'
HTTP File Upload
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
urn:xmpp:http:upload:0
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
urn:xmpp:http:upload:0
'
}).
up
()
...
@@ -156,12 +156,12 @@
...
@@ -156,12 +156,12 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
();
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
();
expect
(
entities
.
get
(
'
localhost
'
).
items
.
get
(
'
upload.localhos
t
'
).
identities
.
where
({
'
category
'
:
'
store
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
montague.lit
'
).
items
.
get
(
'
upload.montague.li
t
'
).
identities
.
where
({
'
category
'
:
'
store
'
}).
length
).
toBe
(
1
);
const
supported
=
await
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
HTTPUPLOAD
,
_converse
.
domain
);
const
supported
=
await
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
HTTPUPLOAD
,
_converse
.
domain
);
expect
(
supported
).
toBe
(
true
);
expect
(
supported
).
toBe
(
true
);
const
features
=
await
_converse
.
api
.
disco
.
features
.
get
(
Strophe
.
NS
.
HTTPUPLOAD
,
_converse
.
domain
);
const
features
=
await
_converse
.
api
.
disco
.
features
.
get
(
Strophe
.
NS
.
HTTPUPLOAD
,
_converse
.
domain
);
expect
(
features
.
length
).
toBe
(
1
);
expect
(
features
.
length
).
toBe
(
1
);
expect
(
features
[
0
].
get
(
'
jid
'
)).
toBe
(
'
upload.
localhos
t
'
);
expect
(
features
[
0
].
get
(
'
jid
'
)).
toBe
(
'
upload.
montague.li
t
'
);
expect
(
features
[
0
].
dataforms
.
where
({
'
FORM_TYPE
'
:
{
value
:
"
urn:xmpp:http:upload:0
"
,
type
:
"
hidden
"
}}).
length
).
toBe
(
1
);
expect
(
features
[
0
].
dataforms
.
where
({
'
FORM_TYPE
'
:
{
value
:
"
urn:xmpp:http:upload:0
"
,
type
:
"
hidden
"
}}).
length
).
toBe
(
1
);
done
();
done
();
}));
}));
...
@@ -171,7 +171,7 @@
...
@@ -171,7 +171,7 @@
describe
(
"
A file upload toolbar button
"
,
function
()
{
describe
(
"
A file upload toolbar button
"
,
function
()
{
it
(
"
does not appear in private chats
"
,
mock
.
initConverse
(
async
(
done
,
_converse
)
=>
{
it
(
"
does not appear in private chats
"
,
mock
.
initConverse
(
async
(
done
,
_converse
)
=>
{
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
var
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -190,15 +190,15 @@
...
@@ -190,15 +190,15 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
(
done
,
_converse
)
=>
{
async
(
done
,
_converse
)
=>
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
test_utils
.
waitUntilDiscoConfirmed
(
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
_converse
,
_converse
.
domain
,
[{
'
category
'
:
'
server
'
,
'
type
'
:
'
IM
'
}],
[{
'
category
'
:
'
server
'
,
'
type
'
:
'
IM
'
}],
[
'
http://jabber.org/protocol/disco#items
'
],
[],
'
info
'
);
[
'
http://jabber.org/protocol/disco#items
'
],
[],
'
info
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.
localhos
t
'
],
'
items
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.
montague.li
t
'
],
'
items
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.
localhos
t
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.
montague.li
t
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-toolbar .upload-file
'
)).
toBe
(
null
);
expect
(
view
.
el
.
querySelector
(
'
.chat-toolbar .upload-file
'
)).
toBe
(
null
);
done
();
done
();
}));
}));
...
@@ -216,11 +216,11 @@
...
@@ -216,11 +216,11 @@
[{
'
category
'
:
'
server
'
,
'
type
'
:
'
IM
'
}],
[{
'
category
'
:
'
server
'
,
'
type
'
:
'
IM
'
}],
[
'
http://jabber.org/protocol/disco#items
'
],
[],
'
info
'
);
[
'
http://jabber.org/protocol/disco#items
'
],
[],
'
info
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.
localhos
t
'
],
'
items
'
)
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.
montague.li
t
'
],
'
items
'
)
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.
localhos
t
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.
montague.li
t
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
3
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
3
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.upload-file
'
));
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.upload-file
'
));
...
@@ -237,11 +237,11 @@
...
@@ -237,11 +237,11 @@
[{
'
category
'
:
'
server
'
,
'
type
'
:
'
IM
'
}],
[{
'
category
'
:
'
server
'
,
'
type
'
:
'
IM
'
}],
[
'
http://jabber.org/protocol/disco#items
'
],
[],
'
info
'
);
[
'
http://jabber.org/protocol/disco#items
'
],
[],
'
info
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.
localhos
t
'
],
'
items
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.
montague.li
t
'
],
'
items
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.
localhos
t
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.
montague.li
t
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
).
el
.
querySelector
(
'
.upload-file
'
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
).
el
.
querySelector
(
'
.upload-file
'
));
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-toolbar .upload-file
'
)).
not
.
toBe
(
null
);
expect
(
view
.
el
.
querySelector
(
'
.chat-toolbar .upload-file
'
)).
not
.
toBe
(
null
);
done
();
done
();
}));
}));
...
@@ -262,7 +262,7 @@
...
@@ -262,7 +262,7 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.montague.tld
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.montague.tld
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
file
=
{
const
file
=
{
...
@@ -277,7 +277,7 @@
...
@@ -277,7 +277,7 @@
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
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
();
const
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="
dummy@localhost/resource
" `
+
`<iq from="
romeo@montague.lit/orchard
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`to="upload.montague.tld" `
+
`to="upload.montague.tld" `
+
`type="get" `
+
`type="get" `
+
...
@@ -294,7 +294,7 @@
...
@@ -294,7 +294,7 @@
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<iq from="upload.montague.tld"
<iq from="upload.montague.tld"
id="
${
iq
.
getAttribute
(
"
id
"
)}
"
id="
${
iq
.
getAttribute
(
"
id
"
)}
"
to="
dummy@localhost/resource
"
to="
romeo@montague.lit/orchard
"
type="result">
type="result">
<slot xmlns="urn:xmpp:http:upload:0">
<slot xmlns="urn:xmpp:http:upload:0">
<put url="https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my-juliet.jpg">
<put url="https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my-juliet.jpg">
...
@@ -328,9 +328,9 @@
...
@@ -328,9 +328,9 @@
await
test_utils
.
waitUntil
(()
=>
sent_stanza
,
1000
);
await
test_utils
.
waitUntil
(()
=>
sent_stanza
,
1000
);
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
`<message from="
dummy@localhost/resource
" `
+
`<message from="
romeo@montague.lit/orchard
" `
+
`id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="
irini.vlastuin@localhos
t" `
+
`to="
lady.montague@montague.li
t" `
+
`type="chat" `
+
`type="chat" `
+
`xmlns="jabber:client">`
+
`xmlns="jabber:client">`
+
`<body>
${
message
}
</body>`
+
`<body>
${
message
}
</body>`
+
...
@@ -365,13 +365,13 @@
...
@@ -365,13 +365,13 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.montague.tld
'
],
'
items
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
domain
,
[],
[],
[
'
upload.montague.tld
'
],
'
items
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.montague.tld
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.montague.tld
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
// Wait until MAM query has been sent out
// Wait until MAM query has been sent out
const
sent_stanzas
=
_converse
.
connection
.
sent_stanzas
;
const
sent_stanzas
=
_converse
.
connection
.
sent_stanzas
;
await
test_utils
.
waitUntil
(()
=>
sent_stanzas
.
filter
(
s
=>
sizzle
(
`[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
,
s
).
length
).
pop
());
await
test_utils
.
waitUntil
(()
=>
sent_stanzas
.
filter
(
s
=>
sizzle
(
`[xmlns="
${
Strophe
.
NS
.
MAM
}
"]`
,
s
).
length
).
pop
());
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
const
file
=
{
const
file
=
{
'
type
'
:
'
image/jpeg
'
,
'
type
'
:
'
image/jpeg
'
,
'
size
'
:
'
23456
'
,
'
size
'
:
'
23456
'
,
...
@@ -384,7 +384,7 @@
...
@@ -384,7 +384,7 @@
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
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
();
const
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="
dummy@localhost/resource
" `
+
`<iq from="
romeo@montague.lit/orchard
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`to="upload.montague.tld" `
+
`to="upload.montague.tld" `
+
`type="get" `
+
`type="get" `
+
...
@@ -400,7 +400,7 @@
...
@@ -400,7 +400,7 @@
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<iq from='upload.montague.tld'
<iq from='upload.montague.tld'
id="
${
iq
.
getAttribute
(
'
id
'
)}
"
id="
${
iq
.
getAttribute
(
'
id
'
)}
"
to='
dummy@localhost/resource
'
to='
romeo@montague.lit/orchard
'
type='result'>
type='result'>
<slot xmlns='urn:xmpp:http:upload:0'>
<slot xmlns='urn:xmpp:http:upload:0'>
<put url='https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my-juliet.jpg'>
<put url='https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my-juliet.jpg'>
...
@@ -435,9 +435,9 @@
...
@@ -435,9 +435,9 @@
await
test_utils
.
waitUntil
(()
=>
sent_stanza
,
1000
);
await
test_utils
.
waitUntil
(()
=>
sent_stanza
,
1000
);
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
`<message `
+
`<message `
+
`from="
dummy@localhost/resource
" `
+
`from="
romeo@montague.lit/orchard
" `
+
`id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="lounge@
localhos
t" `
+
`to="lounge@
montague.li
t" `
+
`type="groupchat" `
+
`type="groupchat" `
+
`xmlns="jabber:client">`
+
`xmlns="jabber:client">`
+
`<body>
${
message
}
</body>`
+
`<body>
${
message
}
</body>`
+
...
@@ -466,18 +466,18 @@
...
@@ -466,18 +466,18 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[],
[]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[],
[]);
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)).
length
iq
=>
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
)).
length
);
);
let
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
let
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
return
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
});
});
const
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
const
info_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
from
'
:
'
localhos
t
'
,
'
from
'
:
'
montague.li
t
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
info_IQ_id
'
id
'
:
info_IQ_id
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
.
c
(
'
identity
'
,
{
...
@@ -491,8 +491,8 @@
...
@@ -491,8 +491,8 @@
let
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
();
let
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
();
expect
(
entities
.
length
).
toBe
(
2
);
expect
(
entities
.
length
).
toBe
(
2
);
expect
(
_
.
includes
(
entities
.
pluck
(
'
jid
'
),
'
localhos
t
'
)).
toBe
(
true
);
expect
(
_
.
includes
(
entities
.
pluck
(
'
jid
'
),
'
montague.li
t
'
)).
toBe
(
true
);
expect
(
_
.
includes
(
entities
.
pluck
(
'
jid
'
),
'
dummy@localhos
t
'
)).
toBe
(
true
);
expect
(
_
.
includes
(
entities
.
pluck
(
'
jid
'
),
'
romeo@montague.li
t
'
)).
toBe
(
true
);
expect
(
entities
.
get
(
_converse
.
domain
).
features
.
length
).
toBe
(
2
);
expect
(
entities
.
get
(
_converse
.
domain
).
features
.
length
).
toBe
(
2
);
expect
(
entities
.
get
(
_converse
.
domain
).
identities
.
length
).
toBe
(
1
);
expect
(
entities
.
get
(
_converse
.
domain
).
identities
.
length
).
toBe
(
1
);
...
@@ -501,22 +501,22 @@
...
@@ -501,22 +501,22 @@
// Converse.js sees that the entity has a disco#items feature,
// Converse.js sees that the entity has a disco#items feature,
// so it will make a query for it.
// so it will make a query for it.
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
}).
length
>
0
;
}).
length
>
0
;
},
300
);
},
300
);
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
stanza
=
_
.
find
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
return
iq
.
querySelector
(
'
iq[to="
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#items"]
'
);
});
});
var
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
var
items_IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
stanza
=
$iq
({
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
from
'
:
'
localhos
t
'
,
'
from
'
:
'
montague.li
t
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
items_IQ_id
'
id
'
:
items_IQ_id
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
jid
'
:
'
upload.
localhos
t
'
,
'
jid
'
:
'
upload.
montague.li
t
'
,
'
name
'
:
'
HTTP File Upload
'
});
'
name
'
:
'
HTTP File Upload
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -524,24 +524,24 @@
...
@@ -524,24 +524,24 @@
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
()
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
()
expect
(
entities
.
length
).
toBe
(
2
);
expect
(
entities
.
length
).
toBe
(
2
);
expect
(
entities
.
get
(
'
localhos
t
'
).
items
.
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
montague.li
t
'
).
items
.
length
).
toBe
(
1
);
await
test_utils
.
waitUntil
(
function
()
{
await
test_utils
.
waitUntil
(
function
()
{
// Converse.js sees that the entity has a disco#info feature,
// Converse.js sees that the entity has a disco#info feature,
// so it will make a query for it.
// so it will make a query for it.
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
_
.
filter
(
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
querySelector
(
'
iq[to="upload.
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
return
iq
.
querySelector
(
'
iq[to="upload.
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
}).
length
>
0
;
}).
length
>
0
;
},
300
);
},
300
);
stanza
=
_
.
find
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="upload.
localhos
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
));
stanza
=
_
.
find
(
IQ_stanzas
,
iq
=>
iq
.
querySelector
(
'
iq[to="upload.
montague.li
t"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
));
const
IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
const
IQ_id
=
IQ_ids
[
IQ_stanzas
.
indexOf
(
stanza
)];
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="
dummy@localhost/resource" id="
${
IQ_id
}
" to="upload.localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard" id="
${
IQ_id
}
" to="upload.montague.li
t" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`</iq>`
);
`</iq>`
);
// Upload service responds and reports a maximum file size of 5MiB
// Upload service responds and reports a maximum file size of 5MiB
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
id
'
:
IQ_id
,
'
from
'
:
'
upload.localhos
t
'
})
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
IQ_id
,
'
from
'
:
'
upload.montague.li
t
'
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
'
category
'
:
'
store
'
,
'
type
'
:
'
file
'
,
'
name
'
:
'
HTTP File Upload
'
}).
up
()
.
c
(
'
identity
'
,
{
'
category
'
:
'
store
'
,
'
type
'
:
'
file
'
,
'
name
'
:
'
HTTP File Upload
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
urn:xmpp:http:upload:0
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
urn:xmpp:http:upload:0
'
}).
up
()
...
@@ -552,12 +552,12 @@
...
@@ -552,12 +552,12 @@
.
c
(
'
value
'
).
t
(
'
5242880
'
);
.
c
(
'
value
'
).
t
(
'
5242880
'
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
();
entities
=
await
_converse
.
api
.
disco
.
entities
.
get
();
expect
(
entities
.
get
(
'
localhost
'
).
items
.
get
(
'
upload.localhos
t
'
).
identities
.
where
({
'
category
'
:
'
store
'
}).
length
).
toBe
(
1
);
expect
(
entities
.
get
(
'
montague.lit
'
).
items
.
get
(
'
upload.montague.li
t
'
).
identities
.
where
({
'
category
'
:
'
store
'
}).
length
).
toBe
(
1
);
await
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
HTTPUPLOAD
,
_converse
.
domain
);
await
_converse
.
api
.
disco
.
supports
(
Strophe
.
NS
.
HTTPUPLOAD
,
_converse
.
domain
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
var
file
=
{
var
file
=
{
...
@@ -595,7 +595,7 @@
...
@@ -595,7 +595,7 @@
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.montague.tld
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
upload.montague.tld
'
,
[],
[
Strophe
.
NS
.
HTTPUPLOAD
],
[]);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
file
=
{
const
file
=
{
...
@@ -609,7 +609,7 @@
...
@@ -609,7 +609,7 @@
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
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
();
const
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="
dummy@localhost/resource
" `
+
`<iq from="
romeo@montague.lit/orchard
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
iq
.
getAttribute
(
"
id
"
)}
" `
+
`to="upload.montague.tld" `
+
`to="upload.montague.tld" `
+
`type="get" `
+
`type="get" `
+
...
@@ -626,7 +626,7 @@
...
@@ -626,7 +626,7 @@
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<iq from="upload.montague.tld"
<iq from="upload.montague.tld"
id="
${
iq
.
getAttribute
(
"
id
"
)}
"
id="
${
iq
.
getAttribute
(
"
id
"
)}
"
to="
dummy@localhost/resource
"
to="
romeo@montague.lit/orchard
"
type="result">
type="result">
<slot xmlns="urn:xmpp:http:upload:0">
<slot xmlns="urn:xmpp:http:upload:0">
<put url="https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my-juliet.jpg">
<put url="https://upload.montague.tld/4a771ac1-f0b2-4a4a-9700-f2a26fa2bb67/my-juliet.jpg">
...
...
spec/login.js
View file @
737e27c7
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
expect
(
label
.
textContent
).
toBe
(
'
This is a trusted device
'
);
expect
(
label
.
textContent
).
toBe
(
'
This is a trusted device
'
);
expect
(
checkbox
.
checked
).
toBe
(
true
);
expect
(
checkbox
.
checked
).
toBe
(
true
);
cbview
.
el
.
querySelector
(
'
input[name="jid"]
'
).
value
=
'
dummy@localhos
t
'
;
cbview
.
el
.
querySelector
(
'
input[name="jid"]
'
).
value
=
'
romeo@montague.li
t
'
;
cbview
.
el
.
querySelector
(
'
input[name="password"]
'
).
value
=
'
secret
'
;
cbview
.
el
.
querySelector
(
'
input[name="password"]
'
).
value
=
'
secret
'
;
spyOn
(
cbview
.
loginpanel
,
'
connect
'
);
spyOn
(
cbview
.
loginpanel
,
'
connect
'
);
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
expect
(
label
.
textContent
).
toBe
(
'
This is a trusted device
'
);
expect
(
label
.
textContent
).
toBe
(
'
This is a trusted device
'
);
expect
(
checkbox
.
checked
).
toBe
(
false
);
expect
(
checkbox
.
checked
).
toBe
(
false
);
cbview
.
el
.
querySelector
(
'
input[name="jid"]
'
).
value
=
'
dummy@localhos
t
'
;
cbview
.
el
.
querySelector
(
'
input[name="jid"]
'
).
value
=
'
romeo@montague.li
t
'
;
cbview
.
el
.
querySelector
(
'
input[name="password"]
'
).
value
=
'
secret
'
;
cbview
.
el
.
querySelector
(
'
input[name="password"]
'
).
value
=
'
secret
'
;
spyOn
(
cbview
.
loginpanel
,
'
connect
'
);
spyOn
(
cbview
.
loginpanel
,
'
connect
'
);
...
...
spec/mam.js
View file @
737e27c7
...
@@ -24,11 +24,11 @@
...
@@ -24,11 +24,11 @@
null
,
[
'
discoInitialized
'
],
{},
null
,
[
'
discoInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
trek-radio
'
,
'
conference.lightwitch.org
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
trek-radio
'
,
'
conference.lightwitch.org
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
trek-radio@conference.lightwitch.org
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
trek-radio@conference.lightwitch.org
'
);
let
stanza
=
u
.
toStanza
(
let
stanza
=
u
.
toStanza
(
`<message xmlns="jabber:client" to="
dummy@localhost/resource
" type="groupchat" from="trek-radio@conference.lightwitch.org/some1">
`<message xmlns="jabber:client" to="
romeo@montague.lit/orchard
" type="groupchat" from="trek-radio@conference.lightwitch.org/some1">
<body>Hello</body>
<body>Hello</body>
<stanza-id xmlns="urn:xmpp:sid:0" id="45fbbf2a-1059-479d-9283-c8effaf05621" by="trek-radio@conference.lightwitch.org"/>
<stanza-id xmlns="urn:xmpp:sid:0" id="45fbbf2a-1059-479d-9283-c8effaf05621" by="trek-radio@conference.lightwitch.org"/>
</message>`
);
</message>`
);
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
`<message xmlns="jabber:client"
`<message xmlns="jabber:client"
to="
dummy@localhost/resource
"
to="
romeo@montague.lit/orchard
"
from="trek-radio@conference.lightwitch.org">
from="trek-radio@conference.lightwitch.org">
<result xmlns="urn:xmpp:mam:2" queryid="82d9db27-6cf8-4787-8c2c-5a560263d823" id="45fbbf2a-1059-479d-9283-c8effaf05621">
<result xmlns="urn:xmpp:mam:2" queryid="82d9db27-6cf8-4787-8c2c-5a560263d823" id="45fbbf2a-1059-479d-9283-c8effaf05621">
<forwarded xmlns="urn:xmpp:forward:0">
<forwarded xmlns="urn:xmpp:forward:0">
...
@@ -111,10 +111,10 @@
...
@@ -111,10 +111,10 @@
null
,
[
'
discoInitialized
'
],
{},
null
,
[
'
discoInitialized
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
discuss
'
,
'
conference.conversejs.org
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
discuss
'
,
'
conference.conversejs.org
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
discuss@conference.conversejs.org
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
discuss@conference.conversejs.org
'
);
let
stanza
=
u
.
toStanza
(
let
stanza
=
u
.
toStanza
(
`<message xmlns="jabber:client" to="
dummy@localhost/resource
" from="discuss@conference.conversejs.org">
`<message xmlns="jabber:client" to="
romeo@montague.lit/orchard
" from="discuss@conference.conversejs.org">
<result xmlns="urn:xmpp:mam:2" queryid="06fea9ca-97c9-48c4-8583-009ff54ea2e8" id="7a9fde91-4387-4bf8-b5d3-978dab8f6bf3">
<result xmlns="urn:xmpp:mam:2" queryid="06fea9ca-97c9-48c4-8583-009ff54ea2e8" id="7a9fde91-4387-4bf8-b5d3-978dab8f6bf3">
<forwarded xmlns="urn:xmpp:forward:0">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2018-12-05T04:53:12Z"/>
<delay xmlns="urn:xmpp:delay" stamp="2018-12-05T04:53:12Z"/>
...
@@ -132,7 +132,7 @@
...
@@ -132,7 +132,7 @@
expect
(
view
.
content
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
view
.
content
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
`<message xmlns="jabber:client" to="
dummy@localhost/resource
" from="discuss@conference.conversejs.org">
`<message xmlns="jabber:client" to="
romeo@montague.lit/orchard
" from="discuss@conference.conversejs.org">
<result xmlns="urn:xmpp:mam:2" queryid="06fea9ca-97c9-48c4-8583-009ff54ea2e8" id="7a9fde91-4387-4bf8-b5d3-978dab8f6bf3">
<result xmlns="urn:xmpp:mam:2" queryid="06fea9ca-97c9-48c4-8583-009ff54ea2e8" id="7a9fde91-4387-4bf8-b5d3-978dab8f6bf3">
<forwarded xmlns="urn:xmpp:forward:0">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2018-12-05T04:53:12Z"/>
<delay xmlns="urn:xmpp:delay" stamp="2018-12-05T04:53:12Z"/>
...
@@ -272,13 +272,13 @@
...
@@ -272,13 +272,13 @@
* </result>
* </result>
* </message>
* </message>
*/
*/
const
msg1
=
$msg
({
'
id
'
:
'
iasd207
'
,
'
from
'
:
'
other@chat.shakespear.lit
'
,
'
to
'
:
'
dummy@localhos
t
'
})
const
msg1
=
$msg
({
'
id
'
:
'
iasd207
'
,
'
from
'
:
'
other@chat.shakespear.lit
'
,
'
to
'
:
'
romeo@montague.li
t
'
})
.
c
(
'
result
'
,
{
'
xmlns
'
:
'
urn:xmpp:mam:2
'
,
'
queryid
'
:
queryid
,
'
id
'
:
'
34482-21985-73620
'
})
.
c
(
'
result
'
,
{
'
xmlns
'
:
'
urn:xmpp:mam:2
'
,
'
queryid
'
:
queryid
,
'
id
'
:
'
34482-21985-73620
'
})
.
c
(
'
forwarded
'
,
{
'
xmlns
'
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
forwarded
'
,
{
'
xmlns
'
:
'
urn:xmpp:forward:0
'
})
.
c
(
'
delay
'
,
{
'
xmlns
'
:
'
urn:xmpp:delay
'
,
'
stamp
'
:
'
2010-07-10T23:08:25Z
'
}).
up
()
.
c
(
'
delay
'
,
{
'
xmlns
'
:
'
urn:xmpp:delay
'
,
'
stamp
'
:
'
2010-07-10T23:08:25Z
'
}).
up
()
.
c
(
'
message
'
,
{
.
c
(
'
message
'
,
{
'
xmlns
'
:
'
jabber:client
'
,
'
xmlns
'
:
'
jabber:client
'
,
'
to
'
:
'
dummy@localhos
t
'
,
'
to
'
:
'
romeo@montague.li
t
'
,
'
id
'
:
'
162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2
'
,
'
id
'
:
'
162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2
'
,
'
from
'
:
'
coven@chat.shakespeare.lit/firstwitch
'
,
'
from
'
:
'
coven@chat.shakespeare.lit/firstwitch
'
,
'
type
'
:
'
groupchat
'
})
'
type
'
:
'
groupchat
'
})
...
@@ -728,7 +728,7 @@
...
@@ -728,7 +728,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
null
,
[
Strophe
.
NS
.
MAM
]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
null
,
[
Strophe
.
NS
.
MAM
]);
...
@@ -747,7 +747,7 @@
...
@@ -747,7 +747,7 @@
`<query queryid="
${
queryid
}
" xmlns="urn:xmpp:mam:2">`
+
`<query queryid="
${
queryid
}
" xmlns="urn:xmpp:mam:2">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<field type="hidden" var="FORM_TYPE"><value>urn:xmpp:mam:2</value></field>`
+
`<field type="hidden" var="FORM_TYPE"><value>urn:xmpp:mam:2</value></field>`
+
`<field var="with"><value>m
ax.frankfurter@localhos
t</value></field>`
+
`<field var="with"><value>m
ercutio@montague.li
t</value></field>`
+
`</x>`
+
`</x>`
+
`<set xmlns="http://jabber.org/protocol/rsm"><max>50</max><before></before></set>`
+
`<set xmlns="http://jabber.org/protocol/rsm"><max>50</max><before></before></set>`
+
`</query>`
+
`</query>`
+
...
...
spec/messages.js
View file @
737e27c7
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
...
@@ -63,8 +63,8 @@
...
@@ -63,8 +63,8 @@
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
expect
(
msg
.
toLocaleString
())
expect
(
msg
.
toLocaleString
())
.
toBe
(
`<message from="
dummy@localhost/resource
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
.
toBe
(
`<message from="
romeo@montague.lit/orchard
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="m
ax.frankfurter@localhos
t" type="chat" `
+
`to="m
ercutio@montague.li
t" type="chat" `
+
`xmlns="jabber:client">`
+
`xmlns="jabber:client">`
+
`<body>But soft, what light through yonder window breaks?</body>`
+
`<body>But soft, what light through yonder window breaks?</body>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
...
@@ -126,7 +126,7 @@
...
@@ -126,7 +126,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
...
@@ -171,8 +171,8 @@
...
@@ -171,8 +171,8 @@
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
expect
(
msg
.
toLocaleString
())
expect
(
msg
.
toLocaleString
())
.
toBe
(
`<message from="
dummy@localhost/resource
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
.
toBe
(
`<message from="
romeo@montague.lit/orchard
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="m
ax.frankfurter@localhos
t" type="chat" `
+
`to="m
ercutio@montague.li
t" type="chat" `
+
`xmlns="jabber:client">`
+
`xmlns="jabber:client">`
+
`<body>But soft, what light through yonder window breaks?</body>`
+
`<body>But soft, what light through yonder window breaks?</body>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
...
@@ -287,7 +287,7 @@
...
@@ -287,7 +287,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
let
message
,
msg
;
let
message
,
msg
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
)
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
)
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
.
chatboxes
,
'
getChatBox
'
).
and
.
callThrough
();
spyOn
(
_converse
.
chatboxes
,
'
getChatBox
'
).
and
.
callThrough
();
...
@@ -479,14 +479,14 @@
...
@@ -479,14 +479,14 @@
sinon
.
spy
(
_converse
.
chatboxes
,
'
getChatBox
'
);
sinon
.
spy
(
_converse
.
chatboxes
,
'
getChatBox
'
);
sinon
.
spy
(
u
,
'
isHeadlineMessage
'
);
sinon
.
spy
(
u
,
'
isHeadlineMessage
'
);
const
msg
=
$msg
({
const
msg
=
$msg
({
from
:
'
localhos
t
'
,
from
:
'
montague.li
t
'
,
to
:
_converse
.
bare_jid
,
to
:
_converse
.
bare_jid
,
type
:
'
chat
'
,
type
:
'
chat
'
,
id
:
(
new
Date
()).
getTime
()
id
:
(
new
Date
()).
getTime
()
}).
c
(
'
body
'
).
t
(
"
This headline message will not be shown
"
).
tree
();
}).
c
(
'
body
'
).
t
(
"
This headline message will not be shown
"
).
tree
();
await
_converse
.
chatboxes
.
onMessage
(
msg
);
await
_converse
.
chatboxes
.
onMessage
(
msg
);
expect
(
_converse
.
log
.
calledWith
(
expect
(
_converse
.
log
.
calledWith
(
"
onMessage: Ignoring incoming headline message from JID:
localhos
t
"
,
"
onMessage: Ignoring incoming headline message from JID:
montague.li
t
"
,
Strophe
.
LogLevel
.
INFO
Strophe
.
LogLevel
.
INFO
)).
toBeTruthy
();
)).
toBeTruthy
();
expect
(
u
.
isHeadlineMessage
.
called
).
toBeTruthy
();
expect
(
u
.
isHeadlineMessage
.
called
).
toBeTruthy
();
...
@@ -512,7 +512,7 @@
...
@@ -512,7 +512,7 @@
// Send a message from a different resource
// Send a message from a different resource
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
,
'
log
'
);
const
msgtext
=
'
This is a carbon message
'
;
const
msgtext
=
'
This is a carbon message
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msg
=
$msg
({
const
msg
=
$msg
({
'
from
'
:
_converse
.
bare_jid
,
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
(
new
Date
()).
getTime
(),
'
id
'
:
(
new
Date
()).
getTime
(),
...
@@ -548,8 +548,8 @@
...
@@ -548,8 +548,8 @@
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
msgtext
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
msgtext
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
.chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
await
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
'
Candice van der Knijff
'
)
await
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
'
Juliet Capulet
'
)
expect
(
chat_content
.
querySelector
(
'
span.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Candice van der Knijff
'
);
expect
(
chat_content
.
querySelector
(
'
span.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Juliet Capulet
'
);
done
();
done
();
}));
}));
...
@@ -558,14 +558,14 @@
...
@@ -558,14 +558,14 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhos
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.li
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
// Send a message from a different resource
// Send a message from a different resource
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
,
'
log
'
);
const
msgtext
=
'
This is a sent carbon message
'
;
const
msgtext
=
'
This is a sent carbon message
'
;
const
recipient_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
recipient_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msg
=
$msg
({
const
msg
=
$msg
({
'
from
'
:
_converse
.
bare_jid
,
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
(
new
Date
()).
getTime
(),
'
id
'
:
(
new
Date
()).
getTime
(),
...
@@ -620,8 +620,8 @@
...
@@ -620,8 +620,8 @@
*/
*/
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
,
'
log
'
);
const
msgtext
=
'
Please come to Creepy Valley tonight, alone!
'
;
const
msgtext
=
'
Please come to Creepy Valley tonight, alone!
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
impersonated_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
impersonated_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msg
=
$msg
({
const
msg
=
$msg
({
'
from
'
:
sender_jid
,
'
from
'
:
sender_jid
,
'
id
'
:
(
new
Date
()).
getTime
(),
'
id
'
:
(
new
Date
()).
getTime
(),
...
@@ -658,7 +658,7 @@
...
@@ -658,7 +658,7 @@
}
}
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
contact_name
=
mock
.
cur_names
[
0
];
const
contact_name
=
mock
.
cur_names
[
0
];
const
contact_jid
=
contact_name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
contact_name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
...
@@ -670,7 +670,7 @@
...
@@ -670,7 +670,7 @@
chatview
.
el
.
querySelector
(
'
.toggle-chatbox-button
'
).
click
();
chatview
.
el
.
querySelector
(
'
.toggle-chatbox-button
'
).
click
();
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
var
message
=
'
This message is sent to a minimized chatbox
'
;
var
message
=
'
This message is sent to a minimized chatbox
'
;
var
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
var
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
var
msg
=
$msg
({
var
msg
=
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
to
:
_converse
.
connection
.
jid
,
...
@@ -691,7 +691,7 @@
...
@@ -691,7 +691,7 @@
expect
(
count
.
textContent
).
toBe
(
'
1
'
);
expect
(
count
.
textContent
).
toBe
(
'
1
'
);
_converse
.
chatboxes
.
onMessage
(
_converse
.
chatboxes
.
onMessage
(
$msg
({
$msg
({
from
:
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
from
:
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
to
:
_converse
.
connection
.
jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
type
:
'
chat
'
,
id
:
(
new
Date
()).
getTime
()
id
:
(
new
Date
()).
getTime
()
...
@@ -720,7 +720,7 @@
...
@@ -720,7 +720,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
contact_name
=
mock
.
cur_names
[
1
];
const
contact_name
=
mock
.
cur_names
[
1
];
const
contact_jid
=
contact_name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
contact_name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -736,7 +736,7 @@
...
@@ -736,7 +736,7 @@
type
:
'
chat
'
,
type
:
'
chat
'
,
id
:
one_day_ago
.
toDate
().
getTime
()
id
:
one_day_ago
.
toDate
().
getTime
()
}).
c
(
'
body
'
).
t
(
message
).
up
()
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
delay
'
,
{
xmlns
:
'
urn:xmpp:delay
'
,
from
:
'
localhos
t
'
,
stamp
:
one_day_ago
.
toISOString
()
})
.
c
(
'
delay
'
,
{
xmlns
:
'
urn:xmpp:delay
'
,
from
:
'
montague.li
t
'
,
stamp
:
one_day_ago
.
toISOString
()
})
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
await
_converse
.
chatboxes
.
onMessage
(
msg
);
await
_converse
.
chatboxes
.
onMessage
(
msg
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
...
@@ -749,11 +749,11 @@
...
@@ -749,11 +749,11 @@
expect
(
msg_obj
.
get
(
'
nickname
'
)).
toBe
(
null
);
expect
(
msg_obj
.
get
(
'
nickname
'
)).
toBe
(
null
);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
is_delayed
'
)).
toEqual
(
true
);
expect
(
msg_obj
.
get
(
'
is_delayed
'
)).
toEqual
(
true
);
await
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
'
Candice van der Knijff
'
)
await
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
'
Juliet Capulet
'
)
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
.chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
span.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Candice van der Knijff
'
);
expect
(
chat_content
.
querySelector
(
'
span.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Juliet Capulet
'
);
expect
(
chat_content
.
querySelectorAll
(
'
.date-separator
'
).
length
).
toEqual
(
1
);
expect
(
chat_content
.
querySelectorAll
(
'
.date-separator
'
).
length
).
toEqual
(
1
);
let
day
=
chat_content
.
querySelector
(
'
.date-separator
'
);
let
day
=
chat_content
.
querySelector
(
'
.date-separator
'
);
...
@@ -799,7 +799,7 @@
...
@@ -799,7 +799,7 @@
expect
(
chat_content
.
querySelector
(
'
.chat-msg:last-child .chat-msg__text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg:last-child .chat-msg__text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg:last-child .chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
.chat-msg:last-child .chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
.chat-msg:last-child .chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Candice van der Knijff
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg:last-child .chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Juliet Capulet
'
);
done
();
done
();
}));
}));
...
@@ -811,7 +811,7 @@
...
@@ -811,7 +811,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
chatBoxFocused
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
chatBoxFocused
'
,
jasmine
.
any
(
Object
));
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
@@ -832,7 +832,7 @@
...
@@ -832,7 +832,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
message
=
'
<p>This message contains <em>some</em> <b>markup</b></p>
'
;
const
message
=
'
<p>This message contains <em>some</em> <b>markup</b></p>
'
;
...
@@ -852,7 +852,7 @@
...
@@ -852,7 +852,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
message
=
'
This message contains a hyperlink: www.opkode.com
'
;
const
message
=
'
This message contains a hyperlink: www.opkode.com
'
;
...
@@ -875,7 +875,7 @@
...
@@ -875,7 +875,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
@@ -933,7 +933,7 @@
...
@@ -933,7 +933,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
chatboxes
.
onMessage
(
$msg
({
_converse
.
chatboxes
.
onMessage
(
$msg
({
'
from
'
:
sender_jid
,
'
from
'
:
sender_jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
to
'
:
_converse
.
connection
.
jid
,
...
@@ -957,12 +957,12 @@
...
@@ -957,12 +957,12 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
let
stanza
=
u
.
toStanza
(
`
let
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>Hey\nHave you heard the news?</body>
<body>Hey\nHave you heard the news?</body>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -972,7 +972,7 @@
...
@@ -972,7 +972,7 @@
stanza
=
u
.
toStanza
(
`
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>Hey\n\n\nHave you heard the news?</body>
<body>Hey\n\n\nHave you heard the news?</body>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -981,7 +981,7 @@
...
@@ -981,7 +981,7 @@
stanza
=
u
.
toStanza
(
`
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>Hey\nHave you heard\nthe news?</body>
<body>Hey\nHave you heard\nthe news?</body>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -998,7 +998,7 @@
...
@@ -998,7 +998,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
let
base_url
=
'
https://conversejs.org
'
;
let
base_url
=
'
https://conversejs.org
'
;
let
message
=
base_url
+
"
/logo/conversejs-filled.svg
"
;
let
message
=
base_url
+
"
/logo/conversejs-filled.svg
"
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
...
@@ -1045,7 +1045,7 @@
...
@@ -1045,7 +1045,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
_converse
.
time_format
=
'
hh:mm
'
;
_converse
.
time_format
=
'
hh:mm
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
message
=
'
This message is sent from this chatbox
'
;
const
message
=
'
This message is sent from this chatbox
'
;
...
@@ -1056,7 +1056,7 @@
...
@@ -1056,7 +1056,7 @@
const
msg_object
=
chatbox
.
messages
.
models
[
0
];
const
msg_object
=
chatbox
.
messages
.
models
[
0
];
const
msg_author
=
view
.
el
.
querySelector
(
'
.chat-content .chat-msg:last-child .chat-msg__author
'
);
const
msg_author
=
view
.
el
.
querySelector
(
'
.chat-content .chat-msg:last-child .chat-msg__author
'
);
expect
(
msg_author
.
textContent
.
trim
()).
toBe
(
'
Max Mustermann
'
);
expect
(
msg_author
.
textContent
.
trim
()).
toBe
(
'
Romeo Montague
'
);
const
msg_time
=
view
.
el
.
querySelector
(
'
.chat-content .chat-msg:last-child .chat-msg__time
'
);
const
msg_time
=
view
.
el
.
querySelector
(
'
.chat-content .chat-msg:last-child .chat-msg__time
'
);
const
time
=
dayjs
(
msg_object
.
get
(
'
time
'
)).
format
(
_converse
.
time_format
);
const
time
=
dayjs
(
msg_object
.
get
(
'
time
'
)).
format
(
_converse
.
time_format
);
...
@@ -1077,7 +1077,7 @@
...
@@ -1077,7 +1077,7 @@
const
ONE_MINUTE_LATER
=
60000
;
const
ONE_MINUTE_LATER
=
60000
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
300
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
300
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
filter_by_resource
=
true
;
_converse
.
filter_by_resource
=
true
;
jasmine
.
clock
().
install
();
jasmine
.
clock
().
install
();
...
@@ -1237,7 +1237,7 @@
...
@@ -1237,7 +1237,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msg_id
=
u
.
getUniqueId
();
const
msg_id
=
u
.
getUniqueId
();
const
sent_stanzas
=
[];
const
sent_stanzas
=
[];
spyOn
(
_converse
.
connection
,
'
send
'
).
and
.
callFake
(
function
(
stanza
)
{
spyOn
(
_converse
.
connection
,
'
send
'
).
and
.
callFake
(
function
(
stanza
)
{
...
@@ -1263,7 +1263,7 @@
...
@@ -1263,7 +1263,7 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msg_id
=
u
.
getUniqueId
();
const
msg_id
=
u
.
getUniqueId
();
const
sent_stanzas
=
[];
const
sent_stanzas
=
[];
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
...
@@ -1294,7 +1294,7 @@
...
@@ -1294,7 +1294,7 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
recipient_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
recipient_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msg_id
=
u
.
getUniqueId
();
const
msg_id
=
u
.
getUniqueId
();
const
sent_stanzas
=
[];
const
sent_stanzas
=
[];
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
recipient_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
recipient_jid
);
...
@@ -1325,7 +1325,7 @@
...
@@ -1325,7 +1325,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
...
@@ -1389,7 +1389,7 @@
...
@@ -1389,7 +1389,7 @@
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
300
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
300
);
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
const
message
=
'
This is a received message
'
;
const
message
=
'
This is a received message
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// We don't already have an open chatbox for this user
// We don't already have an open chatbox for this user
expect
(
_converse
.
chatboxes
.
get
(
sender_jid
)).
not
.
toBeDefined
();
expect
(
_converse
.
chatboxes
.
get
(
sender_jid
)).
not
.
toBeDefined
();
_converse
.
chatboxes
.
onMessage
(
_converse
.
chatboxes
.
onMessage
(
...
@@ -1420,7 +1420,7 @@
...
@@ -1420,7 +1420,7 @@
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
.chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
await
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
mock
.
cur_names
[
0
]);
await
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
mock
.
cur_names
[
0
]);
expect
(
chat_content
.
querySelector
(
'
span.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
M
ax Frankfurter
'
);
expect
(
chat_content
.
querySelector
(
'
span.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
M
ercutio
'
);
done
();
done
();
}));
}));
...
@@ -1432,7 +1432,7 @@
...
@@ -1432,7 +1432,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
message
=
'
This is a received message
'
;
const
message
=
'
This is a received message
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msg_id
=
u
.
getUniqueId
();
const
msg_id
=
u
.
getUniqueId
();
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
);
_converse
.
chatboxes
.
onMessage
(
$msg
({
_converse
.
chatboxes
.
onMessage
(
$msg
({
...
@@ -1495,7 +1495,7 @@
...
@@ -1495,7 +1495,7 @@
_converse
.
allow_non_roster_messaging
=
true
;
_converse
.
allow_non_roster_messaging
=
true
;
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
spyOn
(
_converse
.
api
,
"
trigger
"
).
and
.
callThrough
();
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
var
vcard_fetched
=
false
;
var
vcard_fetched
=
false
;
spyOn
(
_converse
.
api
.
vcard
,
"
get
"
).
and
.
callFake
(
function
()
{
spyOn
(
_converse
.
api
.
vcard
,
"
get
"
).
and
.
callFake
(
function
()
{
vcard_fetched
=
true
;
vcard_fetched
=
true
;
...
@@ -1530,14 +1530,14 @@
...
@@ -1530,14 +1530,14 @@
expect
(
chatbox
.
get
(
'
fullname
'
)
===
sender_jid
);
expect
(
chatbox
.
get
(
'
fullname
'
)
===
sender_jid
);
await
new
Promise
(
resolve
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
(
resolve
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()
===
'
M
ax Frankfurter
'
);
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()
===
'
M
ercutio
'
);
let
author_el
=
view
.
el
.
querySelector
(
'
.chat-msg__author
'
);
let
author_el
=
view
.
el
.
querySelector
(
'
.chat-msg__author
'
);
expect
(
_
.
includes
(
author_el
.
textContent
.
trim
(),
'
M
ax Frankfurter
'
)).
toBeTruthy
();
expect
(
_
.
includes
(
author_el
.
textContent
.
trim
(),
'
M
ercutio
'
)).
toBeTruthy
();
await
test_utils
.
waitUntil
(()
=>
vcard_fetched
,
100
);
await
test_utils
.
waitUntil
(()
=>
vcard_fetched
,
100
);
expect
(
_converse
.
api
.
vcard
.
get
).
toHaveBeenCalled
();
expect
(
_converse
.
api
.
vcard
.
get
).
toHaveBeenCalled
();
await
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
mock
.
cur_names
[
0
])
await
test_utils
.
waitUntil
(()
=>
chatbox
.
vcard
.
get
(
'
fullname
'
)
===
mock
.
cur_names
[
0
])
author_el
=
view
.
el
.
querySelector
(
'
.chat-msg__author
'
);
author_el
=
view
.
el
.
querySelector
(
'
.chat-msg__author
'
);
expect
(
_
.
includes
(
author_el
.
textContent
.
trim
(),
'
M
ax Frankfurter
'
)).
toBeTruthy
();
expect
(
_
.
includes
(
author_el
.
textContent
.
trim
(),
'
M
ercutio
'
)).
toBeTruthy
();
done
();
done
();
}));
}));
});
});
...
@@ -1555,7 +1555,7 @@
...
@@ -1555,7 +1555,7 @@
spyOn
(
_converse
.
api
,
"
trigger
"
);
spyOn
(
_converse
.
api
,
"
trigger
"
);
const
message
=
'
This is a received message from someone not on the roster
'
;
const
message
=
'
This is a received message from someone not on the roster
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
msg
=
$msg
({
const
msg
=
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
to
:
_converse
.
connection
.
jid
,
...
@@ -1593,12 +1593,12 @@
...
@@ -1593,12 +1593,12 @@
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
sender
'
)).
toEqual
(
'
them
'
);
expect
(
msg_obj
.
get
(
'
is_delayed
'
)).
toEqual
(
false
);
expect
(
msg_obj
.
get
(
'
is_delayed
'
)).
toEqual
(
false
);
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()
===
'
M
ax Frankfurter
'
);
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()
===
'
M
ercutio
'
);
// Now check that the message appears inside the chatbox in the DOM
// Now check that the message appears inside the chatbox in the DOM
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg .chat-msg__text
'
).
textContent
).
toEqual
(
message
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
.chat-msg__time
'
).
textContent
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
expect
(
chat_content
.
querySelector
(
'
span.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
M
ax Frankfurter
'
);
expect
(
chat_content
.
querySelector
(
'
span.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
M
ercutio
'
);
done
();
done
();
}));
}));
});
});
...
@@ -1630,7 +1630,7 @@
...
@@ -1630,7 +1630,7 @@
* </message>
* </message>
*/
*/
const
error_txt
=
'
Server-to-server connection failed: Connecting failed: connection timeout
'
;
const
error_txt
=
'
Server-to-server connection failed: Connecting failed: connection timeout
'
;
const
sender_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
let
fullname
=
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
let
fullname
=
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
fullname
=
_
.
isEmpty
(
fullname
)?
_converse
.
bare_jid
:
fullname
;
fullname
=
_
.
isEmpty
(
fullname
)?
_converse
.
bare_jid
:
fullname
;
await
_converse
.
api
.
chats
.
open
(
sender_jid
)
await
_converse
.
api
.
chats
.
open
(
sender_jid
)
...
@@ -1760,13 +1760,13 @@
...
@@ -1760,13 +1760,13 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
messages
=
_converse
.
connection
.
sent_stanzas
.
filter
(
s
=>
s
.
nodeName
===
'
message
'
);
const
messages
=
_converse
.
connection
.
sent_stanzas
.
filter
(
s
=>
s
.
nodeName
===
'
message
'
);
expect
(
messages
.
length
).
toBe
(
1
);
expect
(
messages
.
length
).
toBe
(
1
);
expect
(
Strophe
.
serialize
(
messages
[
0
])).
toBe
(
expect
(
Strophe
.
serialize
(
messages
[
0
])).
toBe
(
`<message id="
${
messages
[
0
].
getAttribute
(
'
id
'
)}
" to="
robin.schook@localhos
t" type="chat" xmlns="jabber:client">`
+
`<message id="
${
messages
[
0
].
getAttribute
(
'
id
'
)}
" to="
tybalt@montague.li
t" type="chat" xmlns="jabber:client">`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<no-store xmlns="urn:xmpp:hints"/>`
+
`<no-store xmlns="urn:xmpp:hints"/>`
+
`<no-permanent-store xmlns="urn:xmpp:hints"/>`
+
`<no-permanent-store xmlns="urn:xmpp:hints"/>`
+
...
@@ -1795,7 +1795,7 @@
...
@@ -1795,7 +1795,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
const
view
=
_converse
.
api
.
chatviews
.
get
(
sender_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
sender_jid
);
// Create enough messages so that there's a scrollbar.
// Create enough messages so that there's a scrollbar.
...
@@ -1855,7 +1855,7 @@
...
@@ -1855,7 +1855,7 @@
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
,
'
log
'
);
spyOn
(
_converse
.
chatboxes
,
'
getChatBox
'
).
and
.
callThrough
();
spyOn
(
_converse
.
chatboxes
,
'
getChatBox
'
).
and
.
callThrough
();
_converse
.
filter_by_resource
=
true
;
_converse
.
filter_by_resource
=
true
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
let
msg
=
$msg
({
let
msg
=
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
to
:
_converse
.
bare_jid
+
"
/some-other-resource
"
,
to
:
_converse
.
bare_jid
+
"
/some-other-resource
"
,
...
@@ -1866,7 +1866,7 @@
...
@@ -1866,7 +1866,7 @@
await
_converse
.
chatboxes
.
onMessage
(
msg
);
await
_converse
.
chatboxes
.
onMessage
(
msg
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
);
expect
(
_converse
.
log
).
toHaveBeenCalledWith
(
expect
(
_converse
.
log
).
toHaveBeenCalledWith
(
"
onMessage: Ignoring incoming message intended for a different resource:
dummy@localhos
t/some-other-resource
"
,
"
onMessage: Ignoring incoming message intended for a different resource:
romeo@montague.li
t/some-other-resource
"
,
Strophe
.
LogLevel
.
INFO
);
Strophe
.
LogLevel
.
INFO
);
expect
(
_converse
.
chatboxes
.
getChatBox
).
not
.
toHaveBeenCalled
();
expect
(
_converse
.
chatboxes
.
getChatBox
).
not
.
toHaveBeenCalled
();
_converse
.
filter_by_resource
=
false
;
_converse
.
filter_by_resource
=
false
;
...
@@ -1900,7 +1900,7 @@
...
@@ -1900,7 +1900,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
...
@@ -1908,9 +1908,9 @@
...
@@ -1908,9 +1908,9 @@
let
stanza
=
u
.
toStanza
(
`
let
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>Have you heard this funny audio?</body>
<body>Have you heard this funny audio?</body>
<x xmlns="jabber:x:oob"><url>https://
localhos
t/audio.mp3</url></x>
<x xmlns="jabber:x:oob"><url>https://
montague.li
t/audio.mp3</url></x>
</message>`
)
</message>`
)
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
...
@@ -1922,16 +1922,16 @@
...
@@ -1922,16 +1922,16 @@
let
media
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
);
let
media
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
);
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
'
<!-- src/templates/audio.html -->
'
+
'
<!-- src/templates/audio.html -->
'
+
'
<audio controls="" src="https://
localhos
t/audio.mp3"></audio>
'
+
'
<audio controls="" src="https://
montague.li
t/audio.mp3"></audio>
'
+
'
<a target="_blank" rel="noopener" href="https://
localhos
t/audio.mp3">Download audio file "audio.mp3"</a>
'
);
'
<a target="_blank" rel="noopener" href="https://
montague.li
t/audio.mp3">Download audio file "audio.mp3"</a>
'
);
// If the <url> and <body> contents is the same, don't duplicate.
// If the <url> and <body> contents is the same, don't duplicate.
stanza
=
u
.
toStanza
(
`
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>https://
localhos
t/audio.mp3</body>
<body>https://
montague.li
t/audio.mp3</body>
<x xmlns="jabber:x:oob"><url>https://
localhos
t/audio.mp3</url></x>
<x xmlns="jabber:x:oob"><url>https://
montague.li
t/audio.mp3</url></x>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
...
@@ -1940,8 +1940,8 @@
...
@@ -1940,8 +1940,8 @@
media
=
view
.
el
.
querySelector
(
'
.chat-msg:last-child .chat-msg__media
'
);
media
=
view
.
el
.
querySelector
(
'
.chat-msg:last-child .chat-msg__media
'
);
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
'
<!-- src/templates/audio.html -->
'
+
'
<!-- src/templates/audio.html -->
'
+
'
<audio controls="" src="https://
localhos
t/audio.mp3"></audio>
'
+
'
<audio controls="" src="https://
montague.li
t/audio.mp3"></audio>
'
+
'
<a target="_blank" rel="noopener" href="https://
localhos
t/audio.mp3">Download audio file "audio.mp3"</a>
'
'
<a target="_blank" rel="noopener" href="https://
montague.li
t/audio.mp3">Download audio file "audio.mp3"</a>
'
);
);
done
();
done
();
}));
}));
...
@@ -1952,7 +1952,7 @@
...
@@ -1952,7 +1952,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
...
@@ -1960,9 +1960,9 @@
...
@@ -1960,9 +1960,9 @@
let
stanza
=
u
.
toStanza
(
`
let
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>Have you seen this funny video?</body>
<body>Have you seen this funny video?</body>
<x xmlns="jabber:x:oob"><url>https://
localhos
t/video.mp4</url></x>
<x xmlns="jabber:x:oob"><url>https://
montague.li
t/video.mp4</url></x>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-msg video
'
).
length
,
2000
)
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-msg video
'
).
length
,
2000
)
...
@@ -1972,16 +1972,16 @@
...
@@ -1972,16 +1972,16 @@
let
media
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
);
let
media
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
);
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
'
<!-- src/templates/video.html -->
'
+
'
<!-- src/templates/video.html -->
'
+
'
<video controls="" src="https://
localhos
t/video.mp4" style="max-height: 50vh"></video>
'
+
'
<video controls="" src="https://
montague.li
t/video.mp4" style="max-height: 50vh"></video>
'
+
'
<a target="_blank" rel="noopener" href="https://
localhos
t/video.mp4">Download video file "video.mp4"</a>
'
);
'
<a target="_blank" rel="noopener" href="https://
montague.li
t/video.mp4">Download video file "video.mp4"</a>
'
);
// If the <url> and <body> contents is the same, don't duplicate.
// If the <url> and <body> contents is the same, don't duplicate.
stanza
=
u
.
toStanza
(
`
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>https://
localhos
t/video.mp4</body>
<body>https://
montague.li
t/video.mp4</body>
<x xmlns="jabber:x:oob"><url>https://
localhos
t/video.mp4</url></x>
<x xmlns="jabber:x:oob"><url>https://
montague.li
t/video.mp4</url></x>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
...
@@ -1990,8 +1990,8 @@
...
@@ -1990,8 +1990,8 @@
media
=
view
.
el
.
querySelector
(
'
.chat-msg:last-child .chat-msg__media
'
);
media
=
view
.
el
.
querySelector
(
'
.chat-msg:last-child .chat-msg__media
'
);
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
'
<!-- src/templates/video.html -->
'
+
'
<!-- src/templates/video.html -->
'
+
'
<video controls="" src="https://
localhos
t/video.mp4" style="max-height: 50vh"></video>
'
+
'
<video controls="" src="https://
montague.li
t/video.mp4" style="max-height: 50vh"></video>
'
+
'
<a target="_blank" rel="noopener" href="https://
localhos
t/video.mp4">Download video file "video.mp4"</a>
'
);
'
<a target="_blank" rel="noopener" href="https://
montague.li
t/video.mp4">Download video file "video.mp4"</a>
'
);
done
();
done
();
}));
}));
...
@@ -2001,16 +2001,16 @@
...
@@ -2001,16 +2001,16 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>Have you downloaded this funny file?</body>
<body>Have you downloaded this funny file?</body>
<x xmlns="jabber:x:oob"><url>https://
localhos
t/funny.pdf</url></x>
<x xmlns="jabber:x:oob"><url>https://
montague.li
t/funny.pdf</url></x>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
...
@@ -2021,7 +2021,7 @@
...
@@ -2021,7 +2021,7 @@
const
media
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
);
const
media
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
);
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
expect
(
media
.
innerHTML
.
replace
(
/
(\r\n
|
\n
|
\r)
/gm
,
""
)).
toEqual
(
'
<!-- src/templates/file.html -->
'
+
'
<!-- src/templates/file.html -->
'
+
'
<a target="_blank" rel="noopener" href="https://
localhos
t/funny.pdf">Download file "funny.pdf"</a>
'
);
'
<a target="_blank" rel="noopener" href="https://
montague.li
t/funny.pdf">Download file "funny.pdf"</a>
'
);
done
();
done
();
}));
}));
...
@@ -2032,7 +2032,7 @@
...
@@ -2032,7 +2032,7 @@
const
base_url
=
'
https://conversejs.org
'
;
const
base_url
=
'
https://conversejs.org
'
;
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
...
@@ -2041,7 +2041,7 @@
...
@@ -2041,7 +2041,7 @@
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<message from="
${
contact_jid
}
"
<message from="
${
contact_jid
}
"
type="chat"
type="chat"
to="
dummy@localhost/resource
">
to="
romeo@montague.lit/orchard
">
<body>Have you seen this funny image?</body>
<body>Have you seen this funny image?</body>
<x xmlns="jabber:x:oob"><url>
${
url
}
</url></x>
<x xmlns="jabber:x:oob"><url>
${
url
}
</url></x>
</message>`
);
</message>`
);
...
@@ -2070,7 +2070,7 @@
...
@@ -2070,7 +2070,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
msgid
=
u
.
getUniqueId
();
const
msgid
=
u
.
getUniqueId
();
...
@@ -2089,7 +2089,7 @@
...
@@ -2089,7 +2089,7 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
sendMarker
.
calls
.
count
()
===
1
);
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
sendMarker
.
calls
.
count
()
===
1
);
expect
(
Strophe
.
serialize
(
sent_stanzas
[
0
])).
toBe
(
expect
(
Strophe
.
serialize
(
sent_stanzas
[
0
])).
toBe
(
`<message from="
dummy@localhost/resource
" `
+
`<message from="
romeo@montague.lit/orchard
" `
+
`id="
${
sent_stanzas
[
0
].
nodeTree
.
getAttribute
(
'
id
'
)}
" `
+
`id="
${
sent_stanzas
[
0
].
nodeTree
.
getAttribute
(
'
id
'
)}
" `
+
`to="
${
contact_jid
}
" type="chat" xmlns="jabber:client">`
+
`to="
${
contact_jid
}
" type="chat" xmlns="jabber:client">`
+
`<received id="
${
msgid
}
" xmlns="urn:xmpp:chat-markers:0"/>`
+
`<received id="
${
msgid
}
" xmlns="urn:xmpp:chat-markers:0"/>`
+
...
@@ -2103,7 +2103,7 @@
...
@@ -2103,7 +2103,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
'
someone@
localhos
t
'
;
const
contact_jid
=
'
someone@
montague.li
t
'
;
const
msgid
=
u
.
getUniqueId
();
const
msgid
=
u
.
getUniqueId
();
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<message from='
${
contact_jid
}
'
<message from='
${
contact_jid
}
'
...
@@ -2125,7 +2125,7 @@
...
@@ -2125,7 +2125,7 @@
// Only one message is sent out, and it's not a chat marker
// Only one message is sent out, and it's not a chat marker
expect
(
sent_messages
.
length
).
toBe
(
1
);
expect
(
sent_messages
.
length
).
toBe
(
1
);
expect
(
Strophe
.
serialize
(
sent_messages
[
0
])).
toBe
(
expect
(
Strophe
.
serialize
(
sent_messages
[
0
])).
toBe
(
`<message id="
${
sent_messages
[
0
].
getAttribute
(
'
id
'
)}
" to="someone@
localhos
t" type="chat" xmlns="jabber:client">`
+
`<message id="
${
sent_messages
[
0
].
getAttribute
(
'
id
'
)}
" to="someone@
montague.li
t" type="chat" xmlns="jabber:client">`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<no-store xmlns="urn:xmpp:hints"/>`
+
`<no-store xmlns="urn:xmpp:hints"/>`
+
`<no-permanent-store xmlns="urn:xmpp:hints"/>`
+
`<no-permanent-store xmlns="urn:xmpp:hints"/>`
+
...
@@ -2141,7 +2141,7 @@
...
@@ -2141,7 +2141,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[],
[
Strophe
.
NS
.
SID
]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[],
[
Strophe
.
NS
.
SID
]);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
...
@@ -2190,15 +2190,15 @@
...
@@ -2190,15 +2190,15 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
const
message
=
'
dummy
: Your attention is required
'
;
const
message
=
'
romeo
: Your attention is required
'
;
const
nick
=
mock
.
chatroom_names
[
0
],
const
nick
=
mock
.
chatroom_names
[
0
],
msg
=
$msg
({
msg
=
$msg
({
from
:
'
lounge@
localhos
t/
'
+
nick
,
from
:
'
lounge@
montague.li
t/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
}).
c
(
'
body
'
).
t
(
message
).
tree
();
await
view
.
model
.
onMessage
(
msg
);
await
view
.
model
.
onMessage
(
msg
);
...
@@ -2212,14 +2212,14 @@
...
@@ -2212,14 +2212,14 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
const
id
=
u
.
getUniqueId
();
const
id
=
u
.
getUniqueId
();
let
msg
=
$msg
({
let
msg
=
$msg
({
from
:
'
lounge@
localhos
t/some1
'
,
from
:
'
lounge@
montague.li
t/some1
'
,
id
:
id
,
id
:
id
,
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
First message
'
).
tree
();
}).
c
(
'
body
'
).
t
(
'
First message
'
).
tree
();
await
view
.
model
.
onMessage
(
msg
);
await
view
.
model
.
onMessage
(
msg
);
...
@@ -2227,9 +2227,9 @@
...
@@ -2227,9 +2227,9 @@
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
).
toBe
(
1
);
msg
=
$msg
({
msg
=
$msg
({
from
:
'
lounge@
localhos
t/some2
'
,
from
:
'
lounge@
montague.li
t/some2
'
,
id
:
id
,
id
:
id
,
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
Another message
'
).
tree
();
}).
c
(
'
body
'
).
t
(
'
Another message
'
).
tree
();
await
view
.
model
.
onMessage
(
msg
);
await
view
.
model
.
onMessage
(
msg
);
...
@@ -2243,7 +2243,7 @@
...
@@ -2243,7 +2243,7 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
room
'
,
'
muc.example.com
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
room
'
,
'
muc.example.com
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
room@muc.example.com
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
room@muc.example.com
'
);
spyOn
(
view
.
model
,
'
findDuplicateFromStanzaID
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
findDuplicateFromStanzaID
'
).
and
.
callThrough
();
let
stanza
=
u
.
toStanza
(
`
let
stanza
=
u
.
toStanza
(
`
...
@@ -2288,12 +2288,12 @@
...
@@ -2288,12 +2288,12 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
let
msg
=
$msg
({
let
msg
=
$msg
({
from
:
'
lounge@
localhost/dummy
'
,
from
:
'
lounge@
montague.lit/romeo
'
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
I wrote this message!
'
).
tree
();
}).
c
(
'
body
'
).
t
(
'
I wrote this message!
'
).
tree
();
await
view
.
model
.
onMessage
(
msg
);
await
view
.
model
.
onMessage
(
msg
);
...
@@ -2304,13 +2304,13 @@
...
@@ -2304,13 +2304,13 @@
expect
(
sizzle
(
'
.chat-msg__author
'
,
view
.
el
).
pop
().
classList
.
value
.
trim
()).
toBe
(
'
chat-msg__author chat-msg__me moderator
'
);
expect
(
sizzle
(
'
.chat-msg__author
'
,
view
.
el
).
pop
().
classList
.
value
.
trim
()).
toBe
(
'
chat-msg__author chat-msg__me moderator
'
);
let
presence
=
$pres
({
let
presence
=
$pres
({
to
:
'
dummy@localhost/resource
'
,
to
:
'
romeo@montague.lit/orchard
'
,
from
:
'
lounge@
localhost/dummy
'
,
from
:
'
lounge@
montague.lit/romeo
'
,
id
:
u
.
getUniqueId
()
id
:
u
.
getUniqueId
()
}).
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc#user
'
})
}).
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
).
attrs
({
.
c
(
'
item
'
).
attrs
({
affiliation
:
'
member
'
,
affiliation
:
'
member
'
,
jid
:
'
dummy@localhost/resource
'
,
jid
:
'
romeo@montague.lit/orchard
'
,
role
:
'
participant
'
role
:
'
participant
'
}).
up
()
}).
up
()
.
c
(
'
status
'
).
attrs
({
code
:
'
110
'
}).
up
()
.
c
(
'
status
'
).
attrs
({
code
:
'
110
'
}).
up
()
...
@@ -2318,9 +2318,9 @@
...
@@ -2318,9 +2318,9 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
msg
=
$msg
({
msg
=
$msg
({
from
:
'
lounge@
localhost/dummy
'
,
from
:
'
lounge@
montague.lit/romeo
'
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
Another message!
'
).
tree
();
}).
c
(
'
body
'
).
t
(
'
Another message!
'
).
tree
();
await
view
.
model
.
onMessage
(
msg
);
await
view
.
model
.
onMessage
(
msg
);
...
@@ -2331,13 +2331,13 @@
...
@@ -2331,13 +2331,13 @@
expect
(
sizzle
(
'
.chat-msg__author
'
,
view
.
el
).
pop
().
classList
.
value
.
trim
()).
toBe
(
'
chat-msg__author chat-msg__me participant
'
);
expect
(
sizzle
(
'
.chat-msg__author
'
,
view
.
el
).
pop
().
classList
.
value
.
trim
()).
toBe
(
'
chat-msg__author chat-msg__me participant
'
);
presence
=
$pres
({
presence
=
$pres
({
to
:
'
dummy@localhost/resource
'
,
to
:
'
romeo@montague.lit/orchard
'
,
from
:
'
lounge@
localhost/dummy
'
,
from
:
'
lounge@
montague.lit/romeo
'
,
id
:
u
.
getUniqueId
()
id
:
u
.
getUniqueId
()
}).
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc#user
'
})
}).
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
).
attrs
({
.
c
(
'
item
'
).
attrs
({
affiliation
:
'
owner
'
,
affiliation
:
'
owner
'
,
jid
:
'
dummy@localhost/resource
'
,
jid
:
'
romeo@montague.lit/orchard
'
,
role
:
'
moderator
'
role
:
'
moderator
'
}).
up
()
}).
up
()
.
c
(
'
status
'
).
attrs
({
code
:
'
110
'
}).
up
()
.
c
(
'
status
'
).
attrs
({
code
:
'
110
'
}).
up
()
...
@@ -2358,12 +2358,12 @@
...
@@ -2358,12 +2358,12 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
const
msg
=
$msg
({
const
msg
=
$msg
({
from
:
'
lounge@
localhost/dummy
'
,
from
:
'
lounge@
montague.lit/romeo
'
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
I wrote this message!
'
).
tree
();
}).
c
(
'
body
'
).
t
(
'
I wrote this message!
'
).
tree
();
await
view
.
model
.
onMessage
(
msg
);
await
view
.
model
.
onMessage
(
msg
);
...
@@ -2377,24 +2377,24 @@
...
@@ -2377,24 +2377,24 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
jid
=
'
lounge@
localhos
t
'
;
const
jid
=
'
lounge@
montague.li
t
'
;
const
room
=
_converse
.
api
.
rooms
.
get
(
jid
);
const
room
=
_converse
.
api
.
rooms
.
get
(
jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
jid
);
const
stanza
=
$pres
({
const
stanza
=
$pres
({
to
:
'
dummy@localhos
t/_converse.js-29092160
'
,
to
:
'
romeo@montague.li
t/_converse.js-29092160
'
,
from
:
'
coven@chat.shakespeare.lit/newguy
'
from
:
'
coven@chat.shakespeare.lit/newguy
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
newguy@
localhos
t/_converse.js-290929789
'
,
'
jid
'
:
'
newguy@
montague.li
t/_converse.js-290929789
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
}).
tree
();
}).
tree
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
const
msg_id
=
u
.
getUniqueId
();
const
msg_id
=
u
.
getUniqueId
();
await
view
.
model
.
onMessage
(
$msg
({
await
view
.
model
.
onMessage
(
$msg
({
'
from
'
:
'
lounge@
localhos
t/newguy
'
,
'
from
'
:
'
lounge@
montague.li
t/newguy
'
,
'
to
'
:
_converse
.
connection
.
jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
groupchat
'
,
'
type
'
:
'
groupchat
'
,
'
id
'
:
msg_id
,
'
id
'
:
msg_id
,
...
@@ -2405,7 +2405,7 @@
...
@@ -2405,7 +2405,7 @@
.
toBe
(
'
But soft, what light through yonder airlock breaks?
'
);
.
toBe
(
'
But soft, what light through yonder airlock breaks?
'
);
await
view
.
model
.
onMessage
(
$msg
({
await
view
.
model
.
onMessage
(
$msg
({
'
from
'
:
'
lounge@
localhos
t/newguy
'
,
'
from
'
:
'
lounge@
montague.li
t/newguy
'
,
'
to
'
:
_converse
.
connection
.
jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
groupchat
'
,
'
type
'
:
'
groupchat
'
,
'
id
'
:
u
.
getUniqueId
(),
'
id
'
:
u
.
getUniqueId
(),
...
@@ -2417,7 +2417,7 @@
...
@@ -2417,7 +2417,7 @@
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__content .fa-edit
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__content .fa-edit
'
).
length
).
toBe
(
1
);
await
view
.
model
.
onMessage
(
$msg
({
await
view
.
model
.
onMessage
(
$msg
({
'
from
'
:
'
lounge@
localhos
t/newguy
'
,
'
from
'
:
'
lounge@
montague.li
t/newguy
'
,
'
to
'
:
_converse
.
connection
.
jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
groupchat
'
,
'
type
'
:
'
groupchat
'
,
'
id
'
:
u
.
getUniqueId
(),
'
id
'
:
u
.
getUniqueId
(),
...
@@ -2445,8 +2445,8 @@
...
@@ -2445,8 +2445,8 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
room_jid
=
'
lounge@
localhos
t
'
;
const
room_jid
=
'
lounge@
montague.li
t
'
;
const
room
=
_converse
.
api
.
rooms
.
get
(
room_jid
);
const
room
=
_converse
.
api
.
rooms
.
get
(
room_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
room_jid
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
room_jid
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
...
@@ -2492,8 +2492,8 @@
...
@@ -2492,8 +2492,8 @@
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
expect
(
msg
.
toLocaleString
())
expect
(
msg
.
toLocaleString
())
.
toBe
(
`<message from="
dummy@localhost/resource
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
.
toBe
(
`<message from="
romeo@montague.lit/orchard
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="lounge@
localhos
t" type="groupchat" `
+
`to="lounge@
montague.li
t" type="groupchat" `
+
`xmlns="jabber:client">`
+
`xmlns="jabber:client">`
+
`<body>But soft, what light through yonder window breaks?</body>`
+
`<body>But soft, what light through yonder window breaks?</body>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
...
@@ -2518,7 +2518,7 @@
...
@@ -2518,7 +2518,7 @@
await
view
.
model
.
onMessage
(
$msg
({
await
view
.
model
.
onMessage
(
$msg
({
'
from
'
:
room_jid
+
'
/someone-else
'
,
'
from
'
:
room_jid
+
'
/someone-else
'
,
'
id
'
:
(
new
Date
()).
getTime
(),
'
id
'
:
(
new
Date
()).
getTime
(),
'
to
'
:
'
dummy@localhos
t
'
,
'
to
'
:
'
romeo@montague.li
t
'
,
'
type
'
:
'
groupchat
'
'
type
'
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
Hello world
'
).
tree
());
}).
c
(
'
body
'
).
t
(
'
Hello world
'
).
tree
());
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
...
@@ -2552,8 +2552,8 @@
...
@@ -2552,8 +2552,8 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
;
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
;
view
.
onKeyDown
({
view
.
onKeyDown
({
...
@@ -2571,7 +2571,7 @@
...
@@ -2571,7 +2571,7 @@
<body>
${
msg_obj
.
get
(
'
message
'
)}
</body>
<body>
${
msg_obj
.
get
(
'
message
'
)}
</body>
<stanza-id xmlns="urn:xmpp:sid:0"
<stanza-id xmlns="urn:xmpp:sid:0"
id="5f3dbc5e-e1d3-4077-a492-693f3769c7ad"
id="5f3dbc5e-e1d3-4077-a492-693f3769c7ad"
by="lounge@
localhos
t"/>
by="lounge@
montague.li
t"/>
<origin-id xmlns="urn:xmpp:sid:0" id="
${
msg_obj
.
get
(
'
origin_id
'
)}
"/>
<origin-id xmlns="urn:xmpp:sid:0" id="
${
msg_obj
.
get
(
'
origin_id
'
)}
"/>
</message>`
);
</message>`
);
await
view
.
model
.
onMessage
(
stanza
);
await
view
.
model
.
onMessage
(
stanza
);
...
@@ -2580,7 +2580,7 @@
...
@@ -2580,7 +2580,7 @@
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
const
message
=
view
.
model
.
messages
.
at
(
0
);
const
message
=
view
.
model
.
messages
.
at
(
0
);
expect
(
message
.
get
(
'
stanza_id lounge@
localhos
t
'
)).
toBe
(
'
5f3dbc5e-e1d3-4077-a492-693f3769c7ad
'
);
expect
(
message
.
get
(
'
stanza_id lounge@
montague.li
t
'
)).
toBe
(
'
5f3dbc5e-e1d3-4077-a492-693f3769c7ad
'
);
expect
(
message
.
get
(
'
origin_id
'
)).
toBe
(
msg_obj
.
get
(
'
origin_id
'
));
expect
(
message
.
get
(
'
origin_id
'
)).
toBe
(
msg_obj
.
get
(
'
origin_id
'
));
done
();
done
();
}));
}));
...
@@ -2590,7 +2590,7 @@
...
@@ -2590,7 +2590,7 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
room
'
,
'
muc.example.com
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
room
'
,
'
muc.example.com
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
room@muc.example.com
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
room@muc.example.com
'
);
view
.
model
.
sendMessage
(
'
hello world
'
);
view
.
model
.
sendMessage
(
'
hello world
'
);
...
@@ -2602,7 +2602,7 @@
...
@@ -2602,7 +2602,7 @@
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<message xmlns="jabber:client"
<message xmlns="jabber:client"
from="room@muc.example.com/
dummy
"
from="room@muc.example.com/
romeo
"
to="
${
_converse
.
connection
.
jid
}
"
to="
${
_converse
.
connection
.
jid
}
"
type="groupchat">
type="groupchat">
<body>Hello world</body>
<body>Hello world</body>
...
@@ -2626,8 +2626,8 @@
...
@@ -2626,8 +2626,8 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
;
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
;
view
.
onKeyDown
({
view
.
onKeyDown
({
...
@@ -2640,8 +2640,8 @@
...
@@ -2640,8 +2640,8 @@
const
msg_obj
=
view
.
model
.
messages
.
at
(
0
);
const
msg_obj
=
view
.
model
.
messages
.
at
(
0
);
const
stanza
=
u
.
toStanza
(
`
const
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="
dummy@localhost/resource
"
<message xml:lang="en" to="
romeo@montague.lit/orchard
"
from="lounge@
localhos
t/some1" type="groupchat" xmlns="jabber:client">
from="lounge@
montague.li
t/some1" type="groupchat" xmlns="jabber:client">
<received xmlns="urn:xmpp:receipts" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
<received xmlns="urn:xmpp:receipts" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
<origin-id xmlns="urn:xmpp:sid:0" id="CE08D448-5ED8-4B6A-BB5B-07ED9DFE4FF0"/>
<origin-id xmlns="urn:xmpp:sid:0" id="CE08D448-5ED8-4B6A-BB5B-07ED9DFE4FF0"/>
</message>`
);
</message>`
);
...
@@ -2661,8 +2661,8 @@
...
@@ -2661,8 +2661,8 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
;
textarea
.
value
=
'
But soft, what light through yonder airlock breaks?
'
;
view
.
onKeyDown
({
view
.
onKeyDown
({
...
@@ -2677,8 +2677,8 @@
...
@@ -2677,8 +2677,8 @@
const
msg_obj
=
view
.
model
.
messages
.
at
(
0
);
const
msg_obj
=
view
.
model
.
messages
.
at
(
0
);
let
stanza
=
u
.
toStanza
(
`
let
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="
dummy@localhost/resource
"
<message xml:lang="en" to="
romeo@montague.lit/orchard
"
from="lounge@
localhos
t/some1" type="groupchat" xmlns="jabber:client">
from="lounge@
montague.li
t/some1" type="groupchat" xmlns="jabber:client">
<received xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
<received xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
</message>`
);
</message>`
);
spyOn
(
view
.
model
,
"
isChatMarker
"
).
and
.
callThrough
();
spyOn
(
view
.
model
,
"
isChatMarker
"
).
and
.
callThrough
();
...
@@ -2688,8 +2688,8 @@
...
@@ -2688,8 +2688,8 @@
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
stanza
=
u
.
toStanza
(
`
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="
dummy@localhost/resource
"
<message xml:lang="en" to="
romeo@montague.lit/orchard
"
from="lounge@
localhos
t/some1" type="groupchat" xmlns="jabber:client">
from="lounge@
montague.li
t/some1" type="groupchat" xmlns="jabber:client">
<displayed xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
<displayed xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -2698,8 +2698,8 @@
...
@@ -2698,8 +2698,8 @@
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
stanza
=
u
.
toStanza
(
`
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="
dummy@localhost/resource
"
<message xml:lang="en" to="
romeo@montague.lit/orchard
"
from="lounge@
localhos
t/some1" type="groupchat" xmlns="jabber:client">
from="lounge@
montague.li
t/some1" type="groupchat" xmlns="jabber:client">
<acknowledged xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
<acknowledged xmlns="urn:xmpp:chat-markers:0" id="
${
msg_obj
.
get
(
'
msgid
'
)}
"/>
</message>`
);
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -2709,8 +2709,8 @@
...
@@ -2709,8 +2709,8 @@
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__receipt
'
).
length
).
toBe
(
0
);
stanza
=
u
.
toStanza
(
`
stanza
=
u
.
toStanza
(
`
<message xml:lang="en" to="
dummy@localhost/resource
"
<message xml:lang="en" to="
romeo@montague.lit/orchard
"
from="lounge@
localhos
t/some1" type="groupchat" xmlns="jabber:client">
from="lounge@
montague.li
t/some1" type="groupchat" xmlns="jabber:client">
<body>'tis I!</body>
<body>'tis I!</body>
<markable xmlns="urn:xmpp:chat-markers:0"/>
<markable xmlns="urn:xmpp:chat-markers:0"/>
</message>`
);
</message>`
);
...
@@ -2728,31 +2728,31 @@
...
@@ -2728,31 +2728,31 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhos
t
'
,
'
tom
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.li
t
'
,
'
tom
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
[
'
z3r0
'
,
'
mr.robot
'
,
'
gibson
'
,
'
sw0rdf1sh
'
].
forEach
((
nick
)
=>
{
[
'
z3r0
'
,
'
mr.robot
'
,
'
gibson
'
,
'
sw0rdf1sh
'
].
forEach
((
nick
)
=>
{
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$pres
({
$pres
({
'
to
'
:
'
tom@
localhos
t/resource
'
,
'
to
'
:
'
tom@
montague.li
t/resource
'
,
'
from
'
:
`lounge@
localhos
t/
${
nick
}
`
'
from
'
:
`lounge@
montague.li
t/
${
nick
}
`
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
`
${
nick
}
@
localhos
t/resource`
,
'
jid
'
:
`
${
nick
}
@
montague.li
t/resource`
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
}))
}))
);
);
});
});
const
msg
=
$msg
({
const
msg
=
$msg
({
from
:
'
lounge@
localhos
t/gibson
'
,
from
:
'
lounge@
montague.li
t/gibson
'
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
hello z3r0 tom mr.robot, how are you?
'
).
up
()
}).
c
(
'
body
'
).
t
(
'
hello z3r0 tom mr.robot, how are you?
'
).
up
()
.
c
(
'
reference
'
,
{
'
xmlns
'
:
'
urn:xmpp:reference:0
'
,
'
begin
'
:
'
6
'
,
'
end
'
:
'
10
'
,
'
type
'
:
'
mention
'
,
'
uri
'
:
'
xmpp:z3r0@
localhos
t
'
}).
up
()
.
c
(
'
reference
'
,
{
'
xmlns
'
:
'
urn:xmpp:reference:0
'
,
'
begin
'
:
'
6
'
,
'
end
'
:
'
10
'
,
'
type
'
:
'
mention
'
,
'
uri
'
:
'
xmpp:z3r0@
montague.li
t
'
}).
up
()
.
c
(
'
reference
'
,
{
'
xmlns
'
:
'
urn:xmpp:reference:0
'
,
'
begin
'
:
'
11
'
,
'
end
'
:
'
14
'
,
'
type
'
:
'
mention
'
,
'
uri
'
:
'
xmpp:
dummy@localhos
t
'
}).
up
()
.
c
(
'
reference
'
,
{
'
xmlns
'
:
'
urn:xmpp:reference:0
'
,
'
begin
'
:
'
11
'
,
'
end
'
:
'
14
'
,
'
type
'
:
'
mention
'
,
'
uri
'
:
'
xmpp:
romeo@montague.li
t
'
}).
up
()
.
c
(
'
reference
'
,
{
'
xmlns
'
:
'
urn:xmpp:reference:0
'
,
'
begin
'
:
'
15
'
,
'
end
'
:
'
23
'
,
'
type
'
:
'
mention
'
,
'
uri
'
:
'
xmpp:mr.robot@
localhos
t
'
}).
nodeTree
;
.
c
(
'
reference
'
,
{
'
xmlns
'
:
'
urn:xmpp:reference:0
'
,
'
begin
'
:
'
15
'
,
'
end
'
:
'
23
'
,
'
type
'
:
'
mention
'
,
'
uri
'
:
'
xmpp:mr.robot@
montague.li
t
'
}).
nodeTree
;
await
view
.
model
.
onMessage
(
msg
);
await
view
.
model
.
onMessage
(
msg
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
const
messages
=
view
.
el
.
querySelectorAll
(
'
.chat-msg__text
'
);
const
messages
=
view
.
el
.
querySelectorAll
(
'
.chat-msg__text
'
);
...
@@ -2773,18 +2773,18 @@
...
@@ -2773,18 +2773,18 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhos
t
'
,
'
tom
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.li
t
'
,
'
tom
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
[
'
z3r0
'
,
'
mr.robot
'
,
'
gibson
'
,
'
sw0rdf1sh
'
,
'
Link Mauve
'
].
forEach
((
nick
)
=>
{
[
'
z3r0
'
,
'
mr.robot
'
,
'
gibson
'
,
'
sw0rdf1sh
'
,
'
Link Mauve
'
].
forEach
((
nick
)
=>
{
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$pres
({
$pres
({
'
to
'
:
'
tom@
localhos
t/resource
'
,
'
to
'
:
'
tom@
montague.li
t/resource
'
,
'
from
'
:
`lounge@
localhos
t/
${
nick
}
`
'
from
'
:
`lounge@
montague.li
t/
${
nick
}
`
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
`
${
nick
.
replace
(
/
\s
/g
,
'
-
'
)}
@
localhos
t/resource`
,
'
jid
'
:
`
${
nick
.
replace
(
/
\s
/g
,
'
-
'
)}
@
montague.li
t/resource`
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
})));
})));
});
});
...
@@ -2798,14 +2798,14 @@
...
@@ -2798,14 +2798,14 @@
expect
(
references
.
length
).
toBe
(
1
);
expect
(
references
.
length
).
toBe
(
1
);
expect
(
text
).
toBe
(
'
hello z3r0
'
);
expect
(
text
).
toBe
(
'
hello z3r0
'
);
expect
(
JSON
.
stringify
(
references
))
expect
(
JSON
.
stringify
(
references
))
.
toBe
(
'
[{"begin":6,"end":10,"value":"z3r0","type":"mention","uri":"xmpp:z3r0@
localhos
t"}]
'
);
.
toBe
(
'
[{"begin":6,"end":10,"value":"z3r0","type":"mention","uri":"xmpp:z3r0@
montague.li
t"}]
'
);
[
text
,
references
]
=
view
.
model
.
parseTextForReferences
(
'
hello @some1 @z3r0 @gibson @mr.robot, how are you?
'
)
[
text
,
references
]
=
view
.
model
.
parseTextForReferences
(
'
hello @some1 @z3r0 @gibson @mr.robot, how are you?
'
)
expect
(
text
).
toBe
(
'
hello @some1 z3r0 gibson mr.robot, how are you?
'
);
expect
(
text
).
toBe
(
'
hello @some1 z3r0 gibson mr.robot, how are you?
'
);
expect
(
JSON
.
stringify
(
references
))
expect
(
JSON
.
stringify
(
references
))
.
toBe
(
'
[{"begin":13,"end":17,"value":"z3r0","type":"mention","uri":"xmpp:z3r0@
localhos
t"},
'
+
.
toBe
(
'
[{"begin":13,"end":17,"value":"z3r0","type":"mention","uri":"xmpp:z3r0@
montague.li
t"},
'
+
'
{"begin":18,"end":24,"value":"gibson","type":"mention","uri":"xmpp:gibson@
localhos
t"},
'
+
'
{"begin":18,"end":24,"value":"gibson","type":"mention","uri":"xmpp:gibson@
montague.li
t"},
'
+
'
{"begin":25,"end":33,"value":"mr.robot","type":"mention","uri":"xmpp:mr.robot@
localhos
t"}]
'
);
'
{"begin":25,"end":33,"value":"mr.robot","type":"mention","uri":"xmpp:mr.robot@
montague.li
t"}]
'
);
[
text
,
references
]
=
view
.
model
.
parseTextForReferences
(
'
yo @gib
'
)
[
text
,
references
]
=
view
.
model
.
parseTextForReferences
(
'
yo @gib
'
)
expect
(
text
).
toBe
(
'
yo @gib
'
);
expect
(
text
).
toBe
(
'
yo @gib
'
);
...
@@ -2819,13 +2819,13 @@
...
@@ -2819,13 +2819,13 @@
expect
(
text
).
toBe
(
'
gibson
'
);
expect
(
text
).
toBe
(
'
gibson
'
);
expect
(
references
.
length
).
toBe
(
1
);
expect
(
references
.
length
).
toBe
(
1
);
expect
(
JSON
.
stringify
(
references
))
expect
(
JSON
.
stringify
(
references
))
.
toBe
(
'
[{"begin":0,"end":6,"value":"gibson","type":"mention","uri":"xmpp:gibson@
localhos
t"}]
'
);
.
toBe
(
'
[{"begin":0,"end":6,"value":"gibson","type":"mention","uri":"xmpp:gibson@
montague.li
t"}]
'
);
[
text
,
references
]
=
view
.
model
.
parseTextForReferences
(
'
hi @Link Mauve how are you?
'
)
[
text
,
references
]
=
view
.
model
.
parseTextForReferences
(
'
hi @Link Mauve how are you?
'
)
expect
(
text
).
toBe
(
'
hi Link Mauve how are you?
'
);
expect
(
text
).
toBe
(
'
hi Link Mauve how are you?
'
);
expect
(
references
.
length
).
toBe
(
1
);
expect
(
references
.
length
).
toBe
(
1
);
expect
(
JSON
.
stringify
(
references
))
expect
(
JSON
.
stringify
(
references
))
.
toBe
(
'
[{"begin":3,"end":13,"value":"Link Mauve","type":"mention","uri":"xmpp:Link-Mauve@
localhos
t"}]
'
);
.
toBe
(
'
[{"begin":3,"end":13,"value":"Link Mauve","type":"mention","uri":"xmpp:Link-Mauve@
montague.li
t"}]
'
);
[
text
,
references
]
=
view
.
model
.
parseTextForReferences
(
'
https://example.org/@gibson
'
)
[
text
,
references
]
=
view
.
model
.
parseTextForReferences
(
'
https://example.org/@gibson
'
)
expect
(
text
).
toBe
(
'
https://example.org/@gibson
'
);
expect
(
text
).
toBe
(
'
https://example.org/@gibson
'
);
...
@@ -2854,18 +2854,18 @@
...
@@ -2854,18 +2854,18 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhos
t
'
,
'
tom
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.li
t
'
,
'
tom
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
[
'
NotAnAdress
'
,
'
darnuria
'
].
forEach
((
nick
)
=>
{
[
'
NotAnAdress
'
,
'
darnuria
'
].
forEach
((
nick
)
=>
{
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$pres
({
$pres
({
'
to
'
:
'
tom@
localhos
t/resource
'
,
'
to
'
:
'
tom@
montague.li
t/resource
'
,
'
from
'
:
`lounge@
localhos
t/
${
nick
}
`
'
from
'
:
`lounge@
montague.li
t/
${
nick
}
`
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
`
${
nick
.
replace
(
/
\s
/g
,
'
-
'
)}
@
localhos
t/resource`
,
'
jid
'
:
`
${
nick
.
replace
(
/
\s
/g
,
'
-
'
)}
@
montague.li
t/resource`
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
})));
})));
});
});
...
@@ -2888,18 +2888,18 @@
...
@@ -2888,18 +2888,18 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhos
t
'
,
'
tom
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.li
t
'
,
'
tom
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
[
'
z3r0
'
,
'
mr.robot
'
,
'
gibson
'
,
'
sw0rdf1sh
'
].
forEach
((
nick
)
=>
{
[
'
z3r0
'
,
'
mr.robot
'
,
'
gibson
'
,
'
sw0rdf1sh
'
].
forEach
((
nick
)
=>
{
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$pres
({
$pres
({
'
to
'
:
'
tom@
localhos
t/resource
'
,
'
to
'
:
'
tom@
montague.li
t/resource
'
,
'
from
'
:
`lounge@
localhos
t/
${
nick
}
`
'
from
'
:
`lounge@
montague.li
t/
${
nick
}
`
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
`
${
nick
}
@
localhos
t/resource`
,
'
jid
'
:
`
${
nick
}
@
montague.li
t/resource`
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
})));
})));
});
});
...
@@ -2917,14 +2917,14 @@
...
@@ -2917,14 +2917,14 @@
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
expect
(
msg
.
toLocaleString
())
expect
(
msg
.
toLocaleString
())
.
toBe
(
`<message from="
dummy@localhost/resource
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
.
toBe
(
`<message from="
romeo@montague.lit/orchard
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="lounge@
localhos
t" type="groupchat" `
+
`to="lounge@
montague.li
t" type="groupchat" `
+
`xmlns="jabber:client">`
+
`xmlns="jabber:client">`
+
`<body>hello z3r0 gibson mr.robot, how are you?</body>`
+
`<body>hello z3r0 gibson mr.robot, how are you?</body>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<origin-id id="
${
msg
.
nodeTree
.
querySelector
(
'
origin-id
'
).
getAttribute
(
"
id
"
)}
" xmlns="urn:xmpp:sid:0"/>`
+
`<origin-id id="
${
msg
.
nodeTree
.
querySelector
(
'
origin-id
'
).
getAttribute
(
"
id
"
)}
" xmlns="urn:xmpp:sid:0"/>`
+
`</message>`
);
`</message>`
);
...
@@ -2945,14 +2945,14 @@
...
@@ -2945,14 +2945,14 @@
const
correction
=
_converse
.
connection
.
send
.
calls
.
all
()[
1
].
args
[
0
];
const
correction
=
_converse
.
connection
.
send
.
calls
.
all
()[
1
].
args
[
0
];
expect
(
correction
.
toLocaleString
())
expect
(
correction
.
toLocaleString
())
.
toBe
(
`<message from="
dummy@localhost/resource
" id="
${
correction
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
.
toBe
(
`<message from="
romeo@montague.lit/orchard
" id="
${
correction
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="lounge@
localhos
t" type="groupchat" `
+
`to="lounge@
montague.li
t" type="groupchat" `
+
`xmlns="jabber:client">`
+
`xmlns="jabber:client">`
+
`<body>hello z3r0 gibson sw0rdf1sh, how are you?</body>`
+
`<body>hello z3r0 gibson sw0rdf1sh, how are you?</body>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="18" end="27" type="mention" uri="xmpp:sw0rdf1sh@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="18" end="27" type="mention" uri="xmpp:sw0rdf1sh@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<replace id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" xmlns="urn:xmpp:message-correct:0"/>`
+
`<replace id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" 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
.
nodeTree
.
querySelector
(
'
origin-id
'
).
getAttribute
(
"
id
"
)}
" xmlns="urn:xmpp:sid:0"/>`
+
`</message>`
);
`</message>`
);
...
@@ -2964,18 +2964,18 @@
...
@@ -2964,18 +2964,18 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhos
t
'
,
'
tom
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.li
t
'
,
'
tom
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
[
'
z3r0
'
,
'
mr.robot
'
,
'
gibson
'
,
'
sw0rdf1sh
'
].
forEach
((
nick
)
=>
{
[
'
z3r0
'
,
'
mr.robot
'
,
'
gibson
'
,
'
sw0rdf1sh
'
].
forEach
((
nick
)
=>
{
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
$pres
({
$pres
({
'
to
'
:
'
tom@
localhos
t/resource
'
,
'
to
'
:
'
tom@
montague.li
t/resource
'
,
'
from
'
:
`lounge@
localhos
t/
${
nick
}
`
'
from
'
:
`lounge@
montague.li
t/
${
nick
}
`
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
`
${
nick
}
@
localhos
t/resource`
,
'
jid
'
:
`
${
nick
}
@
montague.li
t/resource`
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
})));
})));
});
});
...
@@ -2993,14 +2993,14 @@
...
@@ -2993,14 +2993,14 @@
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
const
msg
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
expect
(
msg
.
toLocaleString
())
expect
(
msg
.
toLocaleString
())
.
toBe
(
`<message from="
dummy@localhost/resource
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
.
toBe
(
`<message from="
romeo@montague.lit/orchard
" id="
${
msg
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="lounge@
localhos
t" type="groupchat" `
+
`to="lounge@
montague.li
t" type="groupchat" `
+
`xmlns="jabber:client">`
+
`xmlns="jabber:client">`
+
`<body>hello z3r0 gibson mr.robot, how are you?</body>`
+
`<body>hello z3r0 gibson mr.robot, how are you?</body>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`
+
`<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@
localhos
t" xmlns="urn:xmpp:reference:0"/>`
+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@
montague.li
t" xmlns="urn:xmpp:reference:0"/>`
+
`<origin-id id="
${
msg
.
nodeTree
.
querySelector
(
'
origin-id
'
).
getAttribute
(
"
id
"
)}
" xmlns="urn:xmpp:sid:0"/>`
+
`<origin-id id="
${
msg
.
nodeTree
.
querySelector
(
'
origin-id
'
).
getAttribute
(
"
id
"
)}
" xmlns="urn:xmpp:sid:0"/>`
+
`</message>`
);
`</message>`
);
done
();
done
();
...
...
spec/minchats.js
View file @
737e27c7
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
_converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
_converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
_converse
.
minimized_chats
.
initToggle
();
_converse
.
minimized_chats
.
initToggle
();
let
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
let
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
let
chatview
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
let
chatview
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
expect
(
_converse
.
minimized_chats
.
keys
().
length
).
toBe
(
1
);
expect
(
_converse
.
minimized_chats
.
keys
().
length
).
toBe
(
1
);
expect
(
_converse
.
minimized_chats
.
keys
()[
0
]).
toBe
(
contact_jid
);
expect
(
_converse
.
minimized_chats
.
keys
()[
0
]).
toBe
(
contact_jid
);
contact_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
contact_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
chatview
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
chatview
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +55,7 @@
_converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
_converse
.
minimized_chats
.
toggleview
.
model
.
browserStorage
.
_clear
();
_converse
.
minimized_chats
.
initToggle
();
_converse
.
minimized_chats
.
initToggle
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
chatview
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
chatview
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
expect
(
u
.
isVisible
(
_converse
.
minimized_chats
.
el
)).
toBeFalsy
();
expect
(
u
.
isVisible
(
_converse
.
minimized_chats
.
el
)).
toBeFalsy
();
...
@@ -90,7 +90,7 @@
...
@@ -90,7 +90,7 @@
expect
(
_
.
isNull
(
unread_el
)).
toBe
(
true
);
expect
(
_
.
isNull
(
unread_el
)).
toBe
(
true
);
for
(
i
=
0
;
i
<
3
;
i
++
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
contact_jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
contact_jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
}
}
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
4
).
then
(()
=>
{
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
==
4
).
then
(()
=>
{
...
@@ -161,13 +161,13 @@
...
@@ -161,13 +161,13 @@
var
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
var
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
view
.
model
.
set
({
'
minimized
'
:
true
});
view
.
model
.
set
({
'
minimized
'
:
true
});
var
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
var
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
var
message
=
'
fires: Your attention is required
'
;
var
message
=
'
fires: Your attention is required
'
;
var
nick
=
mock
.
chatroom_names
[
0
],
var
nick
=
mock
.
chatroom_names
[
0
],
msg
=
$msg
({
msg
=
$msg
({
from
:
room_jid
+
'
/
'
+
nick
,
from
:
room_jid
+
'
/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
}).
c
(
'
body
'
).
t
(
message
).
tree
();
view
.
model
.
onMessage
(
msg
);
view
.
model
.
onMessage
(
msg
);
...
...
spec/muc.js
View file @
737e27c7
This source diff could not be displayed because it is too large. You can
view the blob
instead.
spec/notification.js
View file @
737e27c7
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
spyOn
(
_converse
,
'
isMessageToHiddenChat
'
).
and
.
returnValue
(
true
);
spyOn
(
_converse
,
'
isMessageToHiddenChat
'
).
and
.
returnValue
(
true
);
const
message
=
'
This message will show a desktop notification
'
;
const
message
=
'
This message will show a desktop notification
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
msg
=
$msg
({
msg
=
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
to
:
_converse
.
connection
.
jid
,
...
@@ -47,8 +47,8 @@
...
@@ -47,8 +47,8 @@
async
(
done
,
_converse
)
=>
{
async
(
done
,
_converse
)
=>
{
await
test_utils
.
createContacts
(
_converse
,
'
current
'
);
await
test_utils
.
createContacts
(
_converse
,
'
current
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
'
lounge@
montague.li
t
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
view
.
renderChatArea
();
}
}
...
@@ -64,12 +64,12 @@
...
@@ -64,12 +64,12 @@
spyOn
(
_converse
,
'
showMessageNotification
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
showMessageNotification
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
areDesktopNotificationsEnabled
'
).
and
.
returnValue
(
true
);
spyOn
(
_converse
,
'
areDesktopNotificationsEnabled
'
).
and
.
returnValue
(
true
);
const
message
=
'
dummy
: This message will show a desktop notification
'
;
const
message
=
'
romeo
: This message will show a desktop notification
'
;
const
nick
=
mock
.
chatroom_names
[
0
],
const
nick
=
mock
.
chatroom_names
[
0
],
msg
=
$msg
({
msg
=
$msg
({
from
:
'
lounge@
localhos
t/
'
+
nick
,
from
:
'
lounge@
montague.li
t/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
}).
c
(
'
body
'
).
t
(
message
).
tree
();
...
@@ -94,7 +94,7 @@
...
@@ -94,7 +94,7 @@
const
stanza
=
$msg
({
const
stanza
=
$msg
({
'
type
'
:
'
headline
'
,
'
type
'
:
'
headline
'
,
'
from
'
:
'
notify.example.com
'
,
'
from
'
:
'
notify.example.com
'
,
'
to
'
:
'
dummy@localhos
t
'
,
'
to
'
:
'
romeo@montague.li
t
'
,
'
xml:lang
'
:
'
en
'
'
xml:lang
'
:
'
en
'
})
})
.
c
(
'
subject
'
).
t
(
'
SIEVE
'
).
up
()
.
c
(
'
subject
'
).
t
(
'
SIEVE
'
).
up
()
...
@@ -120,7 +120,7 @@
...
@@ -120,7 +120,7 @@
const
stanza
=
$msg
({
const
stanza
=
$msg
({
'
type
'
:
'
headline
'
,
'
type
'
:
'
headline
'
,
'
from
'
:
'
someone@notify.example.com
'
,
'
from
'
:
'
someone@notify.example.com
'
,
'
to
'
:
'
dummy@localhos
t
'
,
'
to
'
:
'
romeo@montague.li
t
'
,
'
xml:lang
'
:
'
en
'
'
xml:lang
'
:
'
en
'
})
})
.
c
(
'
subject
'
).
t
(
'
SIEVE
'
).
up
()
.
c
(
'
subject
'
).
t
(
'
SIEVE
'
).
up
()
...
@@ -143,7 +143,7 @@
...
@@ -143,7 +143,7 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
spyOn
(
_converse
,
'
areDesktopNotificationsEnabled
'
).
and
.
returnValue
(
true
);
spyOn
(
_converse
,
'
areDesktopNotificationsEnabled
'
).
and
.
returnValue
(
true
);
spyOn
(
_converse
,
'
showChatStateNotification
'
);
spyOn
(
_converse
,
'
showChatStateNotification
'
);
const
jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
busy
'
);
// This will emit 'contactStatusChanged'
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
busy
'
);
// This will emit 'contactStatusChanged'
expect
(
_converse
.
areDesktopNotificationsEnabled
).
toHaveBeenCalled
();
expect
(
_converse
.
areDesktopNotificationsEnabled
).
toHaveBeenCalled
();
expect
(
_converse
.
showChatStateNotification
).
toHaveBeenCalled
();
expect
(
_converse
.
showChatStateNotification
).
toHaveBeenCalled
();
...
@@ -173,18 +173,18 @@
...
@@ -173,18 +173,18 @@
async
(
done
,
_converse
)
=>
{
async
(
done
,
_converse
)
=>
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
_converse
.
play_sounds
=
true
;
_converse
.
play_sounds
=
true
;
spyOn
(
_converse
,
'
playSoundNotification
'
);
spyOn
(
_converse
,
'
playSoundNotification
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
view
.
renderChatArea
();
}
}
let
text
=
'
This message will play a sound because it mentions
dummy
'
;
let
text
=
'
This message will play a sound because it mentions
romeo
'
;
let
message
=
$msg
({
let
message
=
$msg
({
from
:
'
lounge@
localhos
t/otheruser
'
,
from
:
'
lounge@
montague.li
t/otheruser
'
,
id
:
'
1
'
,
id
:
'
1
'
,
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
}).
c
(
'
body
'
).
t
(
text
);
await
view
.
model
.
onMessage
(
message
.
nodeTree
);
await
view
.
model
.
onMessage
(
message
.
nodeTree
);
...
@@ -193,20 +193,20 @@
...
@@ -193,20 +193,20 @@
text
=
"
This message won't play a sound
"
;
text
=
"
This message won't play a sound
"
;
message
=
$msg
({
message
=
$msg
({
from
:
'
lounge@
localhos
t/otheruser
'
,
from
:
'
lounge@
montague.li
t/otheruser
'
,
id
:
'
2
'
,
id
:
'
2
'
,
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
}).
c
(
'
body
'
).
t
(
text
);
await
view
.
model
.
onMessage
(
message
.
nodeTree
);
await
view
.
model
.
onMessage
(
message
.
nodeTree
);
expect
(
_converse
.
playSoundNotification
,
1
);
expect
(
_converse
.
playSoundNotification
,
1
);
_converse
.
play_sounds
=
false
;
_converse
.
play_sounds
=
false
;
text
=
"
This message won't play a sound because it is sent by
dummy
"
;
text
=
"
This message won't play a sound because it is sent by
romeo
"
;
message
=
$msg
({
message
=
$msg
({
from
:
'
lounge@
localhost/dummy
'
,
from
:
'
lounge@
montague.lit/romeo
'
,
id
:
'
3
'
,
id
:
'
3
'
,
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
}).
c
(
'
body
'
).
t
(
text
);
await
view
.
model
.
onMessage
(
message
.
nodeTree
);
await
view
.
model
.
onMessage
(
message
.
nodeTree
);
...
...
spec/omemo.js
View file @
737e27c7
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
const
message
=
'
This message will be encrypted
'
const
message
=
'
This message will be encrypted
'
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
payload
=
await
view
.
model
.
encryptMessage
(
message
);
const
payload
=
await
view
.
model
.
encryptMessage
(
message
);
const
result
=
await
view
.
model
.
decryptMessage
(
payload
);
const
result
=
await
view
.
model
.
decryptMessage
(
payload
);
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
let
sent_stanza
;
let
sent_stanza
;
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
...
@@ -171,8 +171,8 @@
...
@@ -171,8 +171,8 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
sent_stanza
);
await
test_utils
.
waitUntil
(()
=>
sent_stanza
);
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
`<message from="
dummy@localhost/resource
" id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`<message from="
romeo@montague.lit/orchard
" id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="m
ax.frankfurter@localhos
t" `
+
`to="m
ercutio@montague.li
t" `
+
`type="chat" xmlns="jabber:client">`
+
`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>`
+
`<body>This is an OMEMO encrypted message which your client doesn’t seem to support. Find more information on https://conversations.im/omemo</body>`
+
`<request xmlns="urn:xmpp:receipts"/>`
+
`<request xmlns="urn:xmpp:receipts"/>`
+
...
@@ -250,8 +250,8 @@
...
@@ -250,8 +250,8 @@
'
muc_unmoderated
'
,
'
muc_unmoderated
'
,
'
muc_nonanonymous
'
'
muc_nonanonymous
'
];
];
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
,
features
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
,
features
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
const
toolbar
=
view
.
el
.
querySelector
(
'
.chat-toolbar
'
);
const
toolbar
=
view
.
el
.
querySelector
(
'
.chat-toolbar
'
);
...
@@ -260,15 +260,15 @@
...
@@ -260,15 +260,15 @@
expect
(
view
.
model
.
get
(
'
omemo_active
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
omemo_active
'
)).
toBe
(
true
);
// newguy enters the room
// newguy enters the room
const
contact_jid
=
'
newguy@
localhos
t
'
;
const
contact_jid
=
'
newguy@
montague.li
t
'
;
let
stanza
=
$pres
({
let
stanza
=
$pres
({
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
from
'
:
'
lounge@
localhos
t/newguy
'
'
from
'
:
'
lounge@
montague.li
t/newguy
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
newguy@
localhos
t/_converse.js-290929789
'
,
'
jid
'
:
'
newguy@
montague.li
t/_converse.js-290929789
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
}).
tree
();
}).
tree
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -276,7 +276,7 @@
...
@@ -276,7 +276,7 @@
// Wait for Converse to fetch newguy's device list
// Wait for Converse to fetch newguy's device list
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -361,9 +361,9 @@
...
@@ -361,9 +361,9 @@
const
sent_stanza
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
const
sent_stanza
=
_converse
.
connection
.
send
.
calls
.
all
()[
0
].
args
[
0
];
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
sent_stanza
)).
toBe
(
`<message from="
dummy@localhost/resource
" `
+
`<message from="
romeo@montague.lit/orchard
" `
+
`id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`id="
${
sent_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" `
+
`to="lounge@
localhos
t" `
+
`to="lounge@
montague.li
t" `
+
`type="groupchat" `
+
`type="groupchat" `
+
`xmlns="jabber:client">`
+
`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>`
+
`<body>This is an OMEMO encrypted message which your client doesn’t seem to support. Find more information on https://conversations.im/omemo</body>`
+
...
@@ -391,7 +391,7 @@
...
@@ -391,7 +391,7 @@
let
sent_stanza
;
let
sent_stanza
;
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
...
@@ -416,17 +416,17 @@
...
@@ -416,17 +416,17 @@
// Test reception of an encrypted carbon message
// Test reception of an encrypted carbon message
const
obj
=
await
view
.
model
.
encryptMessage
(
'
This is an encrypted carbon message from another device of mine
'
)
const
obj
=
await
view
.
model
.
encryptMessage
(
'
This is an encrypted carbon message from another device of mine
'
)
const
carbon
=
u
.
toStanza
(
`
const
carbon
=
u
.
toStanza
(
`
<message xmlns="jabber:client" to="
dummy@localhost/resource" from="dummy@localhos
t" type="chat">
<message xmlns="jabber:client" to="
romeo@montague.lit/orchard" from="romeo@montague.li
t" type="chat">
<sent xmlns="urn:xmpp:carbons:2">
<sent xmlns="urn:xmpp:carbons:2">
<forwarded xmlns="urn:xmpp:forward:0">
<forwarded xmlns="urn:xmpp:forward:0">
<message xmlns="jabber:client"
<message xmlns="jabber:client"
from="
dummy@localhos
t/gajim.HE02SW1L"
from="
romeo@montague.li
t/gajim.HE02SW1L"
xml:lang="en"
xml:lang="en"
to="
${
contact_jid
}
/gajim.0LATM5V2"
to="
${
contact_jid
}
/gajim.0LATM5V2"
type="chat" id="87141781-61d6-4eb3-9a31-429935a61b76">
type="chat" id="87141781-61d6-4eb3-9a31-429935a61b76">
<archived xmlns="urn:xmpp:mam:tmp" by="
dummy@localhos
t" id="1554033877043470"/>
<archived xmlns="urn:xmpp:mam:tmp" by="
romeo@montague.li
t" id="1554033877043470"/>
<stanza-id xmlns="urn:xmpp:sid:0" by="
dummy@localhos
t" id="1554033877043470"/>
<stanza-id xmlns="urn:xmpp:sid:0" by="
romeo@montague.li
t" id="1554033877043470"/>
<request xmlns="urn:xmpp:receipts"/>
<request xmlns="urn:xmpp:receipts"/>
<active xmlns="http://jabber.org/protocol/chatstates"/>
<active xmlns="http://jabber.org/protocol/chatstates"/>
<origin-id xmlns="urn:xmpp:sid:0" id="87141781-61d6-4eb3-9a31-429935a61b76"/>
<origin-id xmlns="urn:xmpp:sid:0" id="87141781-61d6-4eb3-9a31-429935a61b76"/>
...
@@ -465,7 +465,7 @@
...
@@ -465,7 +465,7 @@
});
});
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
_converse
.
bare_jid
,
'
988349631
'
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
_converse
.
bare_jid
,
'
988349631
'
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
_converse
.
bare_jid
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
_converse
.
bare_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.bundles:988349631"/>`
+
`<items node="eu.siacs.conversations.axolotl.bundles:988349631"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -490,19 +490,19 @@
...
@@ -490,19 +490,19 @@
'
muc_unmoderated
'
,
'
muc_unmoderated
'
,
'
muc_nonanonymous
'
'
muc_nonanonymous
'
];
];
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
,
features
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
,
features
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
const
contact_jid
=
'
newguy@
localhos
t
'
;
const
contact_jid
=
'
newguy@
montague.li
t
'
;
let
stanza
=
$pres
({
let
stanza
=
$pres
({
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
from
'
:
'
lounge@
localhos
t/newguy
'
'
from
'
:
'
lounge@
montague.li
t/newguy
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
newguy@
localhos
t/_converse.js-290929789
'
,
'
jid
'
:
'
newguy@
montague.li
t/_converse.js-290929789
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
}).
tree
();
}).
tree
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -522,7 +522,7 @@
...
@@ -522,7 +522,7 @@
});
});
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -594,7 +594,7 @@
...
@@ -594,7 +594,7 @@
const
header
=
document
.
querySelector
(
'
.alert-danger .modal-title
'
);
const
header
=
document
.
querySelector
(
'
.alert-danger .modal-title
'
);
expect
(
header
.
textContent
).
toBe
(
"
Error
"
);
expect
(
header
.
textContent
).
toBe
(
"
Error
"
);
expect
(
u
.
ancestor
(
header
,
'
.modal-content
'
).
querySelector
(
'
.modal-body p
'
).
textContent
.
trim
())
expect
(
u
.
ancestor
(
header
,
'
.modal-content
'
).
querySelector
(
'
.modal-body p
'
).
textContent
.
trim
())
.
toBe
(
"
Sorry, we're unable to send an encrypted message because newguy@
localhos
t requires you
"
+
.
toBe
(
"
Sorry, we're unable to send an encrypted message because newguy@
montague.li
t requires you
"
+
"
to be subscribed to their presence in order to see their OMEMO information
"
);
"
to be subscribed to their presence in order to see their OMEMO information
"
);
expect
(
view
.
model
.
get
(
'
omemo_supported
'
)).
toBe
(
false
);
expect
(
view
.
model
.
get
(
'
omemo_supported
'
)).
toBe
(
false
);
...
@@ -611,7 +611,7 @@
...
@@ -611,7 +611,7 @@
let
view
,
sent_stanza
;
let
view
,
sent_stanza
;
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
const
obj
=
await
_converse
.
ChatBox
.
prototype
.
encryptMessage
(
'
This is an encrypted message from the contact
'
);
const
obj
=
await
_converse
.
ChatBox
.
prototype
.
encryptMessage
(
'
This is an encrypted message from the contact
'
);
...
@@ -666,7 +666,7 @@
...
@@ -666,7 +666,7 @@
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`
+
`<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`
+
`<item>`
+
`<item>`
+
...
@@ -715,12 +715,12 @@
...
@@ -715,12 +715,12 @@
);
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// Wait until own devices are fetched
// Wait until own devices are fetched
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="dummy@localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="romeo@montague.li
t" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -841,7 +841,7 @@
...
@@ -841,7 +841,7 @@
// Check that our own device is added again, but that removed
// Check that our own device is added again, but that removed
// devices are not added.
// devices are not added.
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
`id`
)}
" type="set" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
`id`
)}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="eu.siacs.conversations.axolotl.devicelist">`
+
`<publish node="eu.siacs.conversations.axolotl.devicelist">`
+
`<item>`
+
`<item>`
+
...
@@ -889,10 +889,10 @@
...
@@ -889,10 +889,10 @@
);
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="dummy@localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="romeo@montague.li
t" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -1042,7 +1042,7 @@
...
@@ -1042,7 +1042,7 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
stanza
=
$iq
({
let
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
from
'
:
contact_jid
,
...
@@ -1067,7 +1067,7 @@
...
@@ -1067,7 +1067,7 @@
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`
+
`<publish node="eu.siacs.conversations.axolotl.bundles:123456789">`
+
`<item>`
+
`<item>`
+
...
@@ -1119,11 +1119,11 @@
...
@@ -1119,11 +1119,11 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="dummy@localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="romeo@montague.li
t" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -1149,7 +1149,7 @@
...
@@ -1149,7 +1149,7 @@
// Check that own device was published
// Check that own device was published
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
ownDeviceHasBeenPublished
(
_converse
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
ownDeviceHasBeenPublished
(
_converse
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
`id`
)}
" type="set" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
`id`
)}
" type="set" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<publish node="eu.siacs.conversations.axolotl.devicelist">`
+
`<publish node="eu.siacs.conversations.axolotl.devicelist">`
+
`<item>`
+
`<item>`
+
...
@@ -1200,7 +1200,7 @@
...
@@ -1200,7 +1200,7 @@
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -1293,8 +1293,8 @@
...
@@ -1293,8 +1293,8 @@
'
muc_unmoderated
'
,
'
muc_unmoderated
'
,
'
muc_nonanonymous
'
'
muc_nonanonymous
'
];
];
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
,
features
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
,
features
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
await
test_utils
.
waitUntil
(()
=>
initializedOMEMO
(
_converse
));
const
toolbar
=
view
.
el
.
querySelector
(
'
.chat-toolbar
'
);
const
toolbar
=
view
.
el
.
querySelector
(
'
.chat-toolbar
'
);
...
@@ -1314,22 +1314,22 @@
...
@@ -1314,22 +1314,22 @@
expect
(
u
.
hasClass
(
'
disabled
'
,
toggle
)).
toBe
(
false
);
expect
(
u
.
hasClass
(
'
disabled
'
,
toggle
)).
toBe
(
false
);
expect
(
view
.
model
.
get
(
'
omemo_supported
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
omemo_supported
'
)).
toBe
(
true
);
let
contact_jid
=
'
newguy@
localhos
t
'
;
let
contact_jid
=
'
newguy@
montague.li
t
'
;
let
stanza
=
$pres
({
let
stanza
=
$pres
({
to
:
'
dummy@localhost/resource
'
,
to
:
'
romeo@montague.lit/orchard
'
,
from
:
'
lounge@
localhos
t/newguy
'
from
:
'
lounge@
montague.li
t/newguy
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
newguy@
localhos
t/_converse.js-290929789
'
,
'
jid
'
:
'
newguy@
montague.li
t/_converse.js-290929789
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
}).
tree
();
}).
tree
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -1401,10 +1401,10 @@
...
@@ -1401,10 +1401,10 @@
// Someone enters the room who doesn't have OMEMO support, while we
// Someone enters the room who doesn't have OMEMO support, while we
// have OMEMO activated...
// have OMEMO activated...
contact_jid
=
'
oldguy@
localhos
t
'
;
contact_jid
=
'
oldguy@
montague.li
t
'
;
stanza
=
$pres
({
stanza
=
$pres
({
to
:
'
dummy@localhost/resource
'
,
to
:
'
romeo@montague.lit/orchard
'
,
from
:
'
lounge@
localhos
t/oldguy
'
from
:
'
lounge@
montague.li
t/oldguy
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
...
@@ -1415,7 +1415,7 @@
...
@@ -1415,7 +1415,7 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhos
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.li
t" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="
${
contact_jid
}
" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`<items node="eu.siacs.conversations.axolotl.devicelist"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
@@ -1466,7 +1466,7 @@
...
@@ -1466,7 +1466,7 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
// We simply emit, to avoid doing all the setup work
// We simply emit, to avoid doing all the setup work
_converse
.
api
.
trigger
(
'
OMEMOInitialized
'
);
_converse
.
api
.
trigger
(
'
OMEMOInitialized
'
);
...
@@ -1478,7 +1478,7 @@
...
@@ -1478,7 +1478,7 @@
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
contact_jid
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="max.frankfurter@localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="mercutio@montague.li
t" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub>`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub>`
+
`</iq>`
);
`</iq>`
);
let
stanza
=
$iq
({
let
stanza
=
$iq
({
...
@@ -1495,7 +1495,7 @@
...
@@ -1495,7 +1495,7 @@
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
);
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
contact_jid
,
'
555
'
));
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleFetched
(
_converse
,
contact_jid
,
'
555
'
));
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq_stanza
)).
toBe
(
`<iq from="
dummy@localhost" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="max.frankfurter@localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit" id="
${
iq_stanza
.
getAttribute
(
"
id
"
)}
" to="mercutio@montague.li
t" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub">`
+
`<items node="eu.siacs.conversations.axolotl.bundles:555"/>`
+
`<items node="eu.siacs.conversations.axolotl.bundles:555"/>`
+
`</pubsub>`
+
`</pubsub>`
+
...
...
spec/ping.js
View file @
737e27c7
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
});
});
_converse
.
ping
();
_converse
.
ping
();
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
`<iq id="
${
IQ_id
}
" to="
localhos
t" type="get" xmlns="jabber:client">`
+
`<iq id="
${
IQ_id
}
" to="
montague.li
t" type="get" xmlns="jabber:client">`
+
`<ping xmlns="urn:xmpp:ping"/>`
+
`<ping xmlns="urn:xmpp:ping"/>`
+
`</iq>`
);
`</iq>`
);
done
();
done
();
...
...
spec/presence.js
View file @
737e27c7
...
@@ -120,11 +120,11 @@
...
@@ -120,11 +120,11 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// Create some contacts so that we can test positioning
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// Create some contacts so that we can test positioning
const
contact_jid
=
mock
.
cur_names
[
8
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
8
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
contact
=
_converse
.
roster
.
get
(
contact_jid
);
const
contact
=
_converse
.
roster
.
get
(
contact_jid
);
let
stanza
=
u
.
toStanza
(
`
let
stanza
=
u
.
toStanza
(
`
<presence xmlns="jabber:client"
<presence xmlns="jabber:client"
to="
dummy@localhos
t/converse.js-21770972"
to="
romeo@montague.li
t/converse.js-21770972"
from="
${
contact_jid
}
/priority-1-resource">
from="
${
contact_jid
}
/priority-1-resource">
<priority>1</priority>
<priority>1</priority>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" ext="voice-v1 camera-v1 video-v1"
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" ext="voice-v1 camera-v1 video-v1"
...
@@ -142,7 +142,7 @@
...
@@ -142,7 +142,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
from="
'
+
contact_jid
+
'
/priority-0-resource">
'
+
'
from="
'
+
contact_jid
+
'
/priority-0-resource">
'
+
'
<status/>
'
+
'
<status/>
'
+
'
<priority>0</priority>
'
+
'
<priority>0</priority>
'
+
...
@@ -162,7 +162,7 @@
...
@@ -162,7 +162,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
from="
'
+
contact_jid
+
'
/priority-2-resource">
'
+
'
from="
'
+
contact_jid
+
'
/priority-2-resource">
'
+
'
<priority>2</priority>
'
+
'
<priority>2</priority>
'
+
'
<show>dnd</show>
'
+
'
<show>dnd</show>
'
+
...
@@ -179,7 +179,7 @@
...
@@ -179,7 +179,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
from="
'
+
contact_jid
+
'
/priority-3-resource">
'
+
'
from="
'
+
contact_jid
+
'
/priority-3-resource">
'
+
'
<priority>3</priority>
'
+
'
<priority>3</priority>
'
+
'
<show>away</show>
'
+
'
<show>away</show>
'
+
...
@@ -198,7 +198,7 @@
...
@@ -198,7 +198,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
from="
'
+
contact_jid
+
'
/older-priority-1-resource">
'
+
'
from="
'
+
contact_jid
+
'
/older-priority-1-resource">
'
+
'
<priority>1</priority>
'
+
'
<priority>1</priority>
'
+
'
<show>dnd</show>
'
+
'
<show>dnd</show>
'
+
...
@@ -220,7 +220,7 @@
...
@@ -220,7 +220,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
type="unavailable"
'
+
'
type="unavailable"
'
+
'
from="
'
+
contact_jid
+
'
/priority-3-resource">
'
+
'
from="
'
+
contact_jid
+
'
/priority-3-resource">
'
+
'
</presence>
'
);
'
</presence>
'
);
...
@@ -238,7 +238,7 @@
...
@@ -238,7 +238,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
type="unavailable"
'
+
'
type="unavailable"
'
+
'
from="
'
+
contact_jid
+
'
/priority-2-resource">
'
+
'
from="
'
+
contact_jid
+
'
/priority-2-resource">
'
+
'
</presence>
'
);
'
</presence>
'
);
...
@@ -254,7 +254,7 @@
...
@@ -254,7 +254,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
type="unavailable"
'
+
'
type="unavailable"
'
+
'
from="
'
+
contact_jid
+
'
/priority-1-resource">
'
+
'
from="
'
+
contact_jid
+
'
/priority-1-resource">
'
+
'
</presence>
'
);
'
</presence>
'
);
...
@@ -268,7 +268,7 @@
...
@@ -268,7 +268,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
type="unavailable"
'
+
'
type="unavailable"
'
+
'
from="
'
+
contact_jid
+
'
/older-priority-1-resource">
'
+
'
from="
'
+
contact_jid
+
'
/older-priority-1-resource">
'
+
'
</presence>
'
);
'
</presence>
'
);
...
@@ -280,7 +280,7 @@
...
@@ -280,7 +280,7 @@
stanza
=
u
.
toStanza
(
stanza
=
u
.
toStanza
(
'
<presence xmlns="jabber:client"
'
+
'
<presence xmlns="jabber:client"
'
+
'
to="
dummy@localhos
t/converse.js-21770972"
'
+
'
to="
romeo@montague.li
t/converse.js-21770972"
'
+
'
type="unavailable"
'
+
'
type="unavailable"
'
+
'
from="
'
+
contact_jid
+
'
/priority-0-resource">
'
+
'
from="
'
+
contact_jid
+
'
/priority-0-resource">
'
+
'
</presence>
'
);
'
</presence>
'
);
...
...
spec/protocol.js
View file @
737e27c7
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +55,7 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
,
modal
;
var
contact
,
sent_stanza
,
IQ_id
,
stanza
,
modal
;
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
localhos
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.li
t
'
,
[],
[
'
vcard-temp
'
]);
await
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
),
300
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
),
300
);
/* The process by which a user subscribes to a contact, including
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
* the interaction between roster items and subscription states.
...
@@ -177,7 +177,7 @@
...
@@ -177,7 +177,7 @@
expect
(
contact
.
subscribe
).
toHaveBeenCalled
();
expect
(
contact
.
subscribe
).
toHaveBeenCalled
();
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
// Strophe adds the xmlns attr (although not in spec)
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
// Strophe adds the xmlns attr (although not in spec)
`<presence to="contact@example.org" type="subscribe" xmlns="jabber:client">`
+
`<presence to="contact@example.org" type="subscribe" xmlns="jabber:client">`
+
`<nick xmlns="http://jabber.org/protocol/nick">
Max Mustermann
</nick>`
+
`<nick xmlns="http://jabber.org/protocol/nick">
Romeo Montague
</nick>`
+
`</presence>`
`</presence>`
);
);
/* As a result, the user's server MUST initiate a second roster
/* As a result, the user's server MUST initiate a second roster
...
@@ -274,7 +274,7 @@
...
@@ -274,7 +274,7 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
// Check that the IQ set was acknowledged.
// Check that the IQ set was acknowledged.
expect
(
Strophe
.
serialize
(
sent_stanza
)).
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)
`<iq from="
dummy@localhost/resource
" id="
${
IQ_id
}
" type="result" xmlns="jabber:client"/>`
`<iq from="
romeo@montague.lit/orchard
" id="
${
IQ_id
}
" type="result" xmlns="jabber:client"/>`
);
);
expect
(
_converse
.
roster
.
updateContact
).
toHaveBeenCalled
();
expect
(
_converse
.
roster
.
updateContact
).
toHaveBeenCalled
();
...
@@ -458,7 +458,7 @@
...
@@ -458,7 +458,7 @@
{
roster_groups
:
false
},
{
roster_groups
:
false
},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
var
sent_IQ
,
IQ_id
,
jid
=
'
a
nnegreet.gomez@localhos
t
'
;
var
sent_IQ
,
IQ_id
,
jid
=
'
a
bram@montague.li
t
'
;
test_utils
.
openControlBox
(
_converse
);
test_utils
.
openControlBox
(
_converse
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
...
@@ -499,7 +499,7 @@
...
@@ -499,7 +499,7 @@
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
`<iq id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
`<iq id="
${
IQ_id
}
" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster">`
+
`<query xmlns="jabber:iq:roster">`
+
`<item jid="a
nnegreet.gomez@localhos
t" subscription="remove"/>`
+
`<item jid="a
bram@montague.li
t" subscription="remove"/>`
+
`</query>`
+
`</query>`
+
`</iq>`
);
`</iq>`
);
...
...
spec/push.js
View file @
737e27c7
...
@@ -78,12 +78,12 @@
...
@@ -78,12 +78,12 @@
`<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>`
+
`<enable jid="push-5@client.example" node="yxs32uqsflafdk3iuqo" xmlns="urn:xmpp:push:0"/>`
+
`</iq>`
`</iq>`
);
);
const
result
=
u
.
toStanza
(
`<iq type="result" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="
dummy@localhos
t" />`
);
const
result
=
u
.
toStanza
(
`<iq type="result" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="
romeo@montague.li
t" />`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
session
.
get
(
'
push_enabled
'
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
session
.
get
(
'
push_enabled
'
));
expect
(
_converse
.
session
.
get
(
'
push_enabled
'
).
length
).
toBe
(
1
);
expect
(
_converse
.
session
.
get
(
'
push_enabled
'
).
length
).
toBe
(
1
);
expect
(
_
.
includes
(
_converse
.
session
.
get
(
'
push_enabled
'
),
'
dummy@localhos
t
'
)).
toBe
(
true
);
expect
(
_
.
includes
(
_converse
.
session
.
get
(
'
push_enabled
'
),
'
romeo@montague.li
t
'
)).
toBe
(
true
);
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
coven
'
,
'
chat.shakespeare.lit
'
,
'
oldhag
'
);
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
coven
'
,
'
chat.shakespeare.lit
'
,
'
oldhag
'
);
await
test_utils
.
waitUntilDiscoConfirmed
(
await
test_utils
.
waitUntilDiscoConfirmed
(
...
...
spec/room_registration.js
View file @
737e27c7
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
).
pop
());
).
pop
());
}).
then
(
stanza
=>
{
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
))
expect
(
Strophe
.
serialize
(
stanza
))
.
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" `
+
.
toBe
(
`<iq from="
romeo@montague.lit/orchard
" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" `
+
`type="get" xmlns="jabber:client">`
+
`type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register"/></iq>`
);
`<query xmlns="jabber:iq:register"/></iq>`
);
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
).
pop
());
).
pop
());
}).
then
(
stanza
=>
{
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard
" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register">`
+
`<query xmlns="jabber:iq:register">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`
+
`<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`
+
...
@@ -94,7 +94,7 @@
...
@@ -94,7 +94,7 @@
const
features_stanza
=
$iq
({
const
features_stanza
=
$iq
({
'
from
'
:
room_jid
,
'
from
'
:
room_jid
,
'
id
'
:
stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
'
dummy@localhos
t/desktop
'
,
'
to
'
:
'
romeo@montague.li
t/desktop
'
,
'
type
'
:
'
result
'
'
type
'
:
'
result
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
.
c
(
'
identity
'
,
{
...
@@ -129,7 +129,7 @@
...
@@ -129,7 +129,7 @@
).
pop
());
).
pop
());
}).
then
(
stanza
=>
{
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
))
expect
(
Strophe
.
serialize
(
stanza
))
.
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" `
+
.
toBe
(
`<iq from="
romeo@montague.lit/orchard
" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" `
+
`type="get" xmlns="jabber:client">`
+
`type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register"/></iq>`
);
`<query xmlns="jabber:iq:register"/></iq>`
);
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
...
@@ -152,7 +152,7 @@
...
@@ -152,7 +152,7 @@
).
pop
());
).
pop
());
}).
then
(
stanza
=>
{
}).
then
(
stanza
=>
{
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
expect
(
Strophe
.
serialize
(
stanza
)).
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard
" id="
${
stanza
.
getAttribute
(
'
id
'
)}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:register">`
+
`<query xmlns="jabber:iq:register">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`
+
`<field var="FORM_TYPE"><value>http://jabber.org/protocol/muc#register</value></field>`
+
...
...
spec/roomslist.js
View file @
737e27c7
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
let
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
let
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
1
);
expect
(
room_els
.
length
).
toBe
(
1
);
expect
(
room_els
[
0
].
innerText
).
toBe
(
'
room@conference.shakespeare.lit
'
);
expect
(
room_els
[
0
].
innerText
).
toBe
(
'
room@conference.shakespeare.lit
'
);
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
2
);
expect
(
room_els
.
length
).
toBe
(
2
);
...
@@ -31,11 +31,11 @@
...
@@ -31,11 +31,11 @@
view
.
close
();
view
.
close
();
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
1
);
expect
(
room_els
.
length
).
toBe
(
1
);
expect
(
room_els
[
0
].
innerText
).
toBe
(
'
lounge@
localhos
t
'
);
expect
(
room_els
[
0
].
innerText
).
toBe
(
'
lounge@
montague.li
t
'
);
list
=
controlbox
.
el
.
querySelector
(
'
div.rooms-list-container
'
);
list
=
controlbox
.
el
.
querySelector
(
'
div.rooms-list-container
'
);
test_utils
.
waitUntil
(()
=>
_
.
includes
(
list
.
classList
,
'
hidden
'
));
test_utils
.
waitUntil
(()
=>
_
.
includes
(
list
.
classList
,
'
hidden
'
));
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
view
.
close
();
view
.
close
();
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
0
);
expect
(
room_els
.
length
).
toBe
(
0
);
...
@@ -51,18 +51,18 @@
...
@@ -51,18 +51,18 @@
{
'
connection
'
:
[
'
send
'
]},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
{
'
connection
'
:
[
'
send
'
]},
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
localhos
t
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@
montague.li
t
'
);
const
contact_jid
=
'
newguy@
localhos
t
'
;
const
contact_jid
=
'
newguy@
montague.li
t
'
;
let
stanza
=
$pres
({
let
stanza
=
$pres
({
to
:
'
dummy@localhost/resource
'
,
to
:
'
romeo@montague.lit/orchard
'
,
from
:
'
lounge@
localhos
t/newguy
'
from
:
'
lounge@
montague.li
t/newguy
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
newguy@
localhos
t/_converse.js-290929789
'
,
'
jid
'
:
'
newguy@
montague.li
t/_converse.js-290929789
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
}).
tree
();
}).
tree
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -82,7 +82,7 @@
...
@@ -82,7 +82,7 @@
).
pop
()
).
pop
()
);
);
expect
(
Strophe
.
serialize
(
call
.
args
[
0
])).
toBe
(
expect
(
Strophe
.
serialize
(
call
.
args
[
0
])).
toBe
(
`<iq from="
dummy@localhost/resource
" id="
${
call
.
args
[
0
].
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard
" id="
${
call
.
args
[
0
].
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<items node="storage:bookmarks"/>
'
+
'
<items node="storage:bookmarks"/>
'
+
'
</pubsub>
'
+
'
</pubsub>
'
+
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
.
c
(
'
storage
'
,
{
'
xmlns
'
:
'
storage:bookmarks
'
})
.
c
(
'
storage
'
,
{
'
xmlns
'
:
'
storage:bookmarks
'
})
.
c
(
'
conference
'
,
{
.
c
(
'
conference
'
,
{
'
name
'
:
'
Bookmarked Lounge
'
,
'
name
'
:
'
Bookmarked Lounge
'
,
'
jid
'
:
'
lounge@
localhos
t
'
'
jid
'
:
'
lounge@
montague.li
t
'
});
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
@@ -161,7 +161,7 @@
...
@@ -161,7 +161,7 @@
const
features_stanza
=
$iq
({
const
features_stanza
=
$iq
({
'
from
'
:
'
coven@chat.shakespeare.lit
'
,
'
from
'
:
'
coven@chat.shakespeare.lit
'
,
'
id
'
:
IQ_id
,
'
id
'
:
IQ_id
,
'
to
'
:
'
dummy@localhos
t/desktop
'
,
'
to
'
:
'
romeo@montague.li
t/desktop
'
,
'
type
'
:
'
result
'
'
type
'
:
'
result
'
})
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
...
@@ -222,13 +222,13 @@
...
@@ -222,13 +222,13 @@
'
Not moderated - Participants entering this groupchat can write right away
'
'
Not moderated - Participants entering this groupchat can write right away
'
);
);
presence
=
$pres
({
presence
=
$pres
({
to
:
'
dummy@localhos
t/_converse.js-29092160
'
,
to
:
'
romeo@montague.li
t/_converse.js-29092160
'
,
from
:
'
coven@chat.shakespeare.lit/newguy
'
from
:
'
coven@chat.shakespeare.lit/newguy
'
})
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
x
'
,
{
xmlns
:
Strophe
.
NS
.
MUC_USER
})
.
c
(
'
item
'
,
{
.
c
(
'
item
'
,
{
'
affiliation
'
:
'
none
'
,
'
affiliation
'
:
'
none
'
,
'
jid
'
:
'
newguy@
localhos
t/_converse.js-290929789
'
,
'
jid
'
:
'
newguy@
montague.li
t/_converse.js-290929789
'
,
'
role
'
:
'
participant
'
'
role
'
:
'
participant
'
});
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
...
@@ -282,13 +282,13 @@
...
@@ -282,13 +282,13 @@
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
kitchen
'
,
'
conference.shakespeare.lit
'
,
'
romeo
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
kitchen
'
,
'
conference.shakespeare.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
view
.
model
.
set
({
'
minimized
'
:
true
});
view
.
model
.
set
({
'
minimized
'
:
true
});
const
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
nick
=
mock
.
chatroom_names
[
0
];
const
nick
=
mock
.
chatroom_names
[
0
];
await
view
.
model
.
onMessage
(
await
view
.
model
.
onMessage
(
$msg
({
$msg
({
from
:
room_jid
+
'
/
'
+
nick
,
from
:
room_jid
+
'
/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
foo
'
).
tree
());
}).
c
(
'
body
'
).
t
(
'
foo
'
).
tree
());
...
@@ -301,7 +301,7 @@
...
@@ -301,7 +301,7 @@
$msg
({
$msg
({
from
:
room_jid
+
'
/
'
+
nick
,
from
:
room_jid
+
'
/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
romeo: Your attention is required
'
).
tree
()
}).
c
(
'
body
'
).
t
(
'
romeo: Your attention is required
'
).
tree
()
);
);
...
@@ -313,7 +313,7 @@
...
@@ -313,7 +313,7 @@
$msg
({
$msg
({
from
:
room_jid
+
'
/
'
+
nick
,
from
:
room_jid
+
'
/
'
+
nick
,
id
:
(
new
Date
()).
getTime
(),
id
:
(
new
Date
()).
getTime
(),
to
:
'
dummy@localhos
t
'
,
to
:
'
romeo@montague.li
t
'
,
type
:
'
groupchat
'
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
romeo: and another thing...
'
).
tree
()
}).
c
(
'
body
'
).
t
(
'
romeo: and another thing...
'
).
tree
()
);
);
...
...
spec/roster.js
View file @
737e27c7
...
@@ -150,32 +150,30 @@
...
@@ -150,32 +150,30 @@
const
contacts
=
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
15
),
600
);
const
contacts
=
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
15
),
600
);
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
5
);
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
5
);
filter
.
value
=
"
candice
"
;
filter
.
value
=
"
juliet
"
;
u
.
triggerEvent
(
filter
,
"
keydown
"
,
"
KeyboardEvent
"
);
u
.
triggerEvent
(
filter
,
"
keydown
"
,
"
KeyboardEvent
"
);
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
),
600
);
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
),
600
);
// Only one roster contact is now visible
// Only one roster contact is now visible
let
visible_contacts
=
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
);
let
visible_contacts
=
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
);
expect
(
visible_contacts
.
length
).
toBe
(
1
);
expect
(
visible_contacts
.
length
).
toBe
(
1
);
expect
(
visible_contacts
.
pop
().
textContent
.
trim
()).
toBe
(
'
Candice van der Knijff
'
);
expect
(
visible_contacts
.
pop
().
textContent
.
trim
()).
toBe
(
'
Juliet Capulet
'
);
// Only one foster group is still visible
// Only one foster group is still visible
expect
(
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
1
);
expect
(
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
1
);
const
visible_group
=
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
pop
();
const
visible_group
=
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
pop
();
expect
(
visible_group
.
querySelector
(
'
a.group-toggle
'
).
textContent
.
trim
()).
toBe
(
'
colleagues
'
);
expect
(
visible_group
.
querySelector
(
'
a.group-toggle
'
).
textContent
.
trim
()).
toBe
(
'
colleagues
'
);
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter
'
);
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter
'
);
filter
.
value
=
"
an
"
;
filter
.
value
=
"
j
"
;
u
.
triggerEvent
(
filter
,
"
keydown
"
,
"
KeyboardEvent
"
);
u
.
triggerEvent
(
filter
,
"
keydown
"
,
"
KeyboardEvent
"
);
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
5
),
6
00
);
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
2
),
7
00
);
visible_contacts
=
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
);
visible_contacts
=
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
);
expect
(
visible_contacts
.
length
).
toBe
(
5
);
expect
(
visible_contacts
.
length
).
toBe
(
2
);
let
visible_groups
=
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
map
(
el
=>
el
.
querySelector
(
'
a.group-toggle
'
));
let
visible_groups
=
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
map
(
el
=>
el
.
querySelector
(
'
a.group-toggle
'
));
expect
(
visible_groups
.
length
).
toBe
(
4
);
expect
(
visible_groups
.
length
).
toBe
(
2
);
expect
(
visible_groups
[
0
].
textContent
.
trim
()).
toBe
(
'
colleagues
'
);
expect
(
visible_groups
[
0
].
textContent
.
trim
()).
toBe
(
'
colleagues
'
);
expect
(
visible_groups
[
1
].
textContent
.
trim
()).
toBe
(
'
Family
'
);
expect
(
visible_groups
[
1
].
textContent
.
trim
()).
toBe
(
'
Ungrouped
'
);
expect
(
visible_groups
[
2
].
textContent
.
trim
()).
toBe
(
'
friends & acquaintences
'
);
expect
(
visible_groups
[
3
].
textContent
.
trim
()).
toBe
(
'
ænemies
'
);
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter
'
);
filter
=
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-filter
'
);
filter
.
value
=
"
xxx
"
;
filter
.
value
=
"
xxx
"
;
...
@@ -205,35 +203,33 @@
...
@@ -205,35 +203,33 @@
_converse
.
rosterview
.
filter_view
.
delegateEvents
();
_converse
.
rosterview
.
filter_view
.
delegateEvents
();
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
15
),
600
);
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
15
),
600
);
filter
.
value
=
"
an
"
;
filter
.
value
=
"
la
"
;
u
.
triggerEvent
(
filter
,
"
keydown
"
,
"
KeyboardEvent
"
);
u
.
triggerEvent
(
filter
,
"
keydown
"
,
"
KeyboardEvent
"
);
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
5
),
600
);
await
test_utils
.
waitUntil
(()
=>
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
3
),
600
);
// Five roster contact is now visible
// Five roster contact is now visible
const
visible_contacts
=
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
);
const
visible_contacts
=
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
);
expect
(
visible_contacts
.
length
).
toBe
(
5
);
expect
(
visible_contacts
.
length
).
toBe
(
3
);
let
visible_groups
=
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
map
(
el
=>
el
.
querySelector
(
'
a.group-toggle
'
));
let
visible_groups
=
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
map
(
el
=>
el
.
querySelector
(
'
a.group-toggle
'
));
expect
(
visible_groups
.
length
).
toBe
(
4
);
expect
(
visible_groups
.
length
).
toBe
(
3
);
expect
(
visible_groups
[
0
].
textContent
.
trim
()).
toBe
(
'
colleagues
'
);
expect
(
visible_groups
[
0
].
textContent
.
trim
()).
toBe
(
'
colleagues
'
);
expect
(
visible_groups
[
1
].
textContent
.
trim
()).
toBe
(
'
Family
'
);
expect
(
visible_groups
[
1
].
textContent
.
trim
()).
toBe
(
'
Family
'
);
expect
(
visible_groups
[
2
].
textContent
.
trim
()).
toBe
(
'
friends & acquaintences
'
);
expect
(
visible_groups
[
2
].
textContent
.
trim
()).
toBe
(
'
friends & acquaintences
'
);
expect
(
visible_groups
[
3
].
textContent
.
trim
()).
toBe
(
'
ænemies
'
);
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
'
latecomer@localhos
t
'
,
jid
:
'
valentine@montague.li
t
'
,
subscription
:
'
both
'
,
subscription
:
'
both
'
,
ask
:
null
,
ask
:
null
,
groups
:
[
'
newgroup
'
],
groups
:
[
'
newgroup
'
],
fullname
:
'
Marty McLatecomer
'
fullname
:
'
Valentine
'
});
});
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group[data-group="newgroup"] li
'
,
roster
).
length
,
300
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group[data-group="newgroup"] li
'
,
roster
).
length
,
300
);
visible_groups
=
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
map
(
el
=>
el
.
querySelector
(
'
a.group-toggle
'
));
visible_groups
=
sizzle
(
'
.roster-group
'
,
roster
).
filter
(
u
.
isVisible
).
map
(
el
=>
el
.
querySelector
(
'
a.group-toggle
'
));
// The "newgroup" group doesn't appear
// The "newgroup" group doesn't appear
expect
(
visible_groups
.
length
).
toBe
(
4
);
expect
(
visible_groups
.
length
).
toBe
(
3
);
expect
(
visible_groups
[
0
].
textContent
.
trim
()).
toBe
(
'
colleagues
'
);
expect
(
visible_groups
[
0
].
textContent
.
trim
()).
toBe
(
'
colleagues
'
);
expect
(
visible_groups
[
1
].
textContent
.
trim
()).
toBe
(
'
Family
'
);
expect
(
visible_groups
[
1
].
textContent
.
trim
()).
toBe
(
'
Family
'
);
expect
(
visible_groups
[
2
].
textContent
.
trim
()).
toBe
(
'
friends & acquaintences
'
);
expect
(
visible_groups
[
2
].
textContent
.
trim
()).
toBe
(
'
friends & acquaintences
'
);
expect
(
visible_groups
[
3
].
textContent
.
trim
()).
toBe
(
'
ænemies
'
);
expect
(
roster
.
querySelectorAll
(
'
.roster-group
'
).
length
).
toBe
(
6
);
expect
(
roster
.
querySelectorAll
(
'
.roster-group
'
).
length
).
toBe
(
6
);
done
();
done
();
}));
}));
...
@@ -310,9 +306,9 @@
...
@@ -310,9 +306,9 @@
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
createGroupedContacts
(
_converse
);
test_utils
.
createGroupedContacts
(
_converse
);
let
jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
let
jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
jid
=
mock
.
cur_names
[
4
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
4
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
button
=
_converse
.
rosterview
.
el
.
querySelector
(
'
span[data-type="state"]
'
);
const
button
=
_converse
.
rosterview
.
el
.
querySelector
(
'
span[data-type="state"]
'
);
...
@@ -325,13 +321,13 @@
...
@@ -325,13 +321,13 @@
u
.
triggerEvent
(
filter
,
'
change
'
);
u
.
triggerEvent
(
filter
,
'
change
'
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
,
900
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
,
900
);
expect
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
pop
().
textContent
.
trim
()).
toBe
(
'
Rinse Sommer
'
);
expect
(
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
pop
().
textContent
.
trim
()).
toBe
(
'
Lord Montague
'
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
,
900
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
===
1
,
900
);
const
ul
=
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
pop
();
const
ul
=
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
pop
();
expect
(
ul
.
parentElement
.
firstElementChild
.
textContent
.
trim
()).
toBe
(
'
friends & acquaintences
'
);
expect
(
ul
.
parentElement
.
firstElementChild
.
textContent
.
trim
()).
toBe
(
'
friends & acquaintences
'
);
filter
.
value
=
"
dnd
"
;
filter
.
value
=
"
dnd
"
;
u
.
triggerEvent
(
filter
,
'
change
'
);
u
.
triggerEvent
(
filter
,
'
change
'
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
pop
().
textContent
.
trim
()
===
'
Annegreet Gomez
'
,
900
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
roster
).
filter
(
u
.
isVisible
).
pop
().
textContent
.
trim
()
===
'
Friar Laurence
'
,
900
);
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
1
);
expect
(
sizzle
(
'
ul.roster-group-contacts
'
,
roster
).
filter
(
u
.
isVisible
).
length
).
toBe
(
1
);
done
();
done
();
}));
}));
...
@@ -389,7 +385,7 @@
...
@@ -389,7 +385,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
'
groupchanger@
localhos
t
'
,
jid
:
'
groupchanger@
montague.li
t
'
,
subscription
:
'
both
'
,
subscription
:
'
both
'
,
ask
:
null
,
ask
:
null
,
groups
:
[
'
firstgroup
'
],
groups
:
[
'
firstgroup
'
],
...
@@ -408,7 +404,7 @@
...
@@ -408,7 +404,7 @@
},
1000
);
},
1000
);
expect
(
group_titles
).
toEqual
([
'
firstgroup
'
]);
expect
(
group_titles
).
toEqual
([
'
firstgroup
'
]);
const
contact
=
_converse
.
roster
.
get
(
'
groupchanger@
localhos
t
'
);
const
contact
=
_converse
.
roster
.
get
(
'
groupchanger@
montague.li
t
'
);
contact
.
set
({
'
groups
'
:
[
'
secondgroup
'
]});
contact
.
set
({
'
groups
'
:
[
'
secondgroup
'
]});
group_titles
=
await
test_utils
.
waitUntil
(()
=>
{
group_titles
=
await
test_utils
.
waitUntil
(()
=>
{
const
toggles
=
sizzle
(
'
.roster-group[data-group="secondgroup"] a.group-toggle
'
,
_converse
.
rosterview
.
el
);
const
toggles
=
sizzle
(
'
.roster-group[data-group="secondgroup"] a.group-toggle
'
,
_converse
.
rosterview
.
el
);
...
@@ -433,7 +429,7 @@
...
@@ -433,7 +429,7 @@
_converse
.
rosterview
.
render
();
_converse
.
rosterview
.
render
();
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
both
'
,
subscription
:
'
both
'
,
ask
:
null
,
ask
:
null
,
groups
:
groups
,
groups
:
groups
,
...
@@ -469,7 +465,7 @@
...
@@ -469,7 +465,7 @@
j
=
i
;
j
=
i
;
for
(
i
=
j
;
i
<
j
+
groups
[
name
];
i
++
)
{
for
(
i
=
j
;
i
<
j
+
groups
[
name
];
i
++
)
{
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
both
'
,
subscription
:
'
both
'
,
ask
:
null
,
ask
:
null
,
groups
:
name
===
'
ungrouped
'
?
[]
:
[
name
],
groups
:
name
===
'
ungrouped
'
?
[]
:
[
name
],
...
@@ -518,7 +514,7 @@
...
@@ -518,7 +514,7 @@
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
pend_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
mock
.
pend_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
none
'
,
subscription
:
'
none
'
,
ask
:
'
subscribe
'
,
ask
:
'
subscribe
'
,
fullname
:
mock
.
pend_names
[
0
]
fullname
:
mock
.
pend_names
[
0
]
...
@@ -566,7 +562,7 @@
...
@@ -566,7 +562,7 @@
_addContacts
(
_converse
);
_addContacts
(
_converse
);
const
name
=
mock
.
pend_names
[
0
];
const
name
=
mock
.
pend_names
[
0
];
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
contact
=
_converse
.
roster
.
get
(
jid
);
const
contact
=
_converse
.
roster
.
get
(
jid
);
var
sent_IQ
;
var
sent_IQ
;
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
...
@@ -585,7 +581,7 @@
...
@@ -585,7 +581,7 @@
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
`<iq type="set" xmlns="jabber:client">`
+
`<iq type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster">`
+
`<query xmlns="jabber:iq:roster">`
+
`<item jid="
suleyman.van.beusichem@localhos
t" subscription="remove"/>`
+
`<item jid="
lord.capulet@montague.li
t" subscription="remove"/>`
+
`</query>`
+
`</query>`
+
`</iq>`
);
`</iq>`
);
done
();
done
();
...
@@ -599,7 +595,7 @@
...
@@ -599,7 +595,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
name
=
mock
.
pend_names
[
0
];
const
name
=
mock
.
pend_names
[
0
];
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
none
'
,
subscription
:
'
none
'
,
ask
:
'
subscribe
'
,
ask
:
'
subscribe
'
,
fullname
:
name
fullname
:
name
...
@@ -619,11 +615,11 @@
...
@@ -619,11 +615,11 @@
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq id="
${
iq
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<iq id="
${
iq
.
getAttribute
(
'
id
'
)}
" type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster">`
+
`<query xmlns="jabber:iq:roster">`
+
`<item jid="
suleyman.van.beusichem@localhos
t" subscription="remove"/>`
+
`<item jid="
lord.capulet@montague.li
t" subscription="remove"/>`
+
`</query>`
+
`</query>`
+
`</iq>`
);
`</iq>`
);
const
stanza
=
u
.
toStanza
(
`<iq id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="
dummy@localhost/resource
" type="result"/>`
);
const
stanza
=
u
.
toStanza
(
`<iq id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="
romeo@montague.lit/orchard
" type="result"/>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
!
u
.
isVisible
(
_converse
.
rosterview
.
get
(
'
Pending contacts
'
).
el
));
await
test_utils
.
waitUntil
(()
=>
!
u
.
isVisible
(
_converse
.
rosterview
.
get
(
'
Pending contacts
'
).
el
));
done
();
done
();
...
@@ -655,7 +651,7 @@
...
@@ -655,7 +651,7 @@
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
for
(
i
=
0
;
i
<
mock
.
pend_names
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
mock
.
pend_names
.
length
;
i
++
)
{
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
pend_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
mock
.
pend_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
none
'
,
subscription
:
'
none
'
,
ask
:
'
subscribe
'
,
ask
:
'
subscribe
'
,
fullname
:
mock
.
pend_names
[
i
]
fullname
:
mock
.
pend_names
[
i
]
...
@@ -697,8 +693,8 @@
...
@@ -697,8 +693,8 @@
_addContacts
(
_converse
);
_addContacts
(
_converse
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
_converse
.
rosterview
.
el
).
filter
(
u
.
isVisible
).
length
,
500
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
li
'
,
_converse
.
rosterview
.
el
).
filter
(
u
.
isVisible
).
length
,
500
);
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-group a.group-toggle
'
).
click
();
_converse
.
rosterview
.
el
.
querySelector
(
'
.roster-group a.group-toggle
'
).
click
();
const
name
=
"
Max Mustermann
"
;
const
name
=
"
Romeo Montague
"
;
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
ask
:
null
,
ask
:
null
,
fullname
:
name
,
fullname
:
name
,
...
@@ -721,7 +717,7 @@
...
@@ -721,7 +717,7 @@
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
both
'
,
subscription
:
'
both
'
,
ask
:
null
,
ask
:
null
,
fullname
:
mock
.
cur_names
[
i
]
fullname
:
mock
.
cur_names
[
i
]
...
@@ -746,7 +742,7 @@
...
@@ -746,7 +742,7 @@
_addContacts
(
_converse
);
_addContacts
(
_converse
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
li
'
).
length
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
li
'
).
length
);
const
name
=
mock
.
cur_names
[
0
];
const
name
=
mock
.
cur_names
[
0
];
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
contact
=
_converse
.
roster
.
get
(
jid
);
const
contact
=
_converse
.
roster
.
get
(
jid
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
contact
,
'
removeFromRoster
'
).
and
.
callThrough
();
spyOn
(
contact
,
'
removeFromRoster
'
).
and
.
callThrough
();
...
@@ -761,7 +757,7 @@
...
@@ -761,7 +757,7 @@
expect
(
window
.
confirm
).
toHaveBeenCalled
();
expect
(
window
.
confirm
).
toHaveBeenCalled
();
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
expect
(
sent_IQ
.
toLocaleString
()).
toBe
(
`<iq type="set" xmlns="jabber:client">`
+
`<iq type="set" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"><item jid="m
ax.frankfurter@localhos
t" subscription="remove"/></query>`
+
`<query xmlns="jabber:iq:roster"><item jid="m
ercutio@montague.li
t" subscription="remove"/></query>`
+
`</iq>`
);
`</iq>`
);
expect
(
contact
.
removeFromRoster
).
toHaveBeenCalled
();
expect
(
contact
.
removeFromRoster
).
toHaveBeenCalled
();
await
test_utils
.
waitUntil
(()
=>
sizzle
(
"
.open-chat:contains('
"
+
name
+
"
')
"
,
_converse
.
rosterview
.
el
).
length
===
0
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
"
.open-chat:contains('
"
+
name
+
"
')
"
,
_converse
.
rosterview
.
el
).
length
===
0
);
...
@@ -777,7 +773,7 @@
...
@@ -777,7 +773,7 @@
var
name
=
mock
.
cur_names
[
0
];
var
name
=
mock
.
cur_names
[
0
];
var
contact
;
var
contact
;
contact
=
_converse
.
roster
.
create
({
contact
=
_converse
.
roster
.
create
({
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
both
'
,
subscription
:
'
both
'
,
ask
:
null
,
ask
:
null
,
fullname
:
name
fullname
:
name
...
@@ -808,7 +804,7 @@
...
@@ -808,7 +804,7 @@
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
const
roster
=
_converse
.
rosterview
.
el
;
const
roster
=
_converse
.
rosterview
.
el
;
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
// Check that they are sorted alphabetically
...
@@ -830,7 +826,7 @@
...
@@ -830,7 +826,7 @@
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
const
roster
=
_converse
.
rosterview
.
el
;
const
roster
=
_converse
.
rosterview
.
el
;
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
// Check that they are sorted alphabetically
...
@@ -852,7 +848,7 @@
...
@@ -852,7 +848,7 @@
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
const
roster
=
_converse
.
rosterview
.
el
;
const
roster
=
_converse
.
rosterview
.
el
;
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
away
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
away
'
);
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
// Check that they are sorted alphabetically
...
@@ -874,7 +870,7 @@
...
@@ -874,7 +870,7 @@
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
const
roster
=
_converse
.
rosterview
.
el
;
const
roster
=
_converse
.
rosterview
.
el
;
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
xa
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
xa
'
);
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
// Check that they are sorted alphabetically
...
@@ -898,7 +894,7 @@
...
@@ -898,7 +894,7 @@
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
var
roster
=
_converse
.
rosterview
.
el
;
var
roster
=
_converse
.
rosterview
.
el
;
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
unavailable
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
unavailable
'
);
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
// Check that they are sorted alphabetically
// Check that they are sorted alphabetically
...
@@ -920,27 +916,27 @@
...
@@ -920,27 +916,27 @@
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
let
i
,
jid
;
let
i
,
jid
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
online
'
);
}
}
for
(
i
=
3
;
i
<
6
;
i
++
)
{
for
(
i
=
3
;
i
<
6
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
dnd
'
);
}
}
for
(
i
=
6
;
i
<
9
;
i
++
)
{
for
(
i
=
6
;
i
<
9
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
away
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
away
'
);
}
}
for
(
i
=
9
;
i
<
12
;
i
++
)
{
for
(
i
=
9
;
i
<
12
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
xa
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
xa
'
);
}
}
for
(
i
=
12
;
i
<
15
;
i
++
)
{
for
(
i
=
12
;
i
<
15
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
unavailable
'
);
_converse
.
roster
.
get
(
jid
).
presence
.
set
(
'
show
'
,
'
unavailable
'
);
}
}
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
li.online
'
).
length
)
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
li.online
'
).
length
)
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelector
(
'
li:first-child
'
).
textContent
.
trim
()
===
'
Candice van der Knijff
'
,
900
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelector
(
'
li:first-child
'
).
textContent
.
trim
()
===
'
Juliet Capulet
'
,
900
);
const
contacts
=
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.current-xmpp-contact
'
);
const
contacts
=
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.current-xmpp-contact
'
);
for
(
i
=
0
;
i
<
3
;
i
++
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
true
);
expect
(
u
.
hasClass
(
'
online
'
,
contacts
[
i
])).
toBe
(
true
);
...
@@ -1007,6 +1003,7 @@
...
@@ -1007,6 +1003,7 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
let
names
=
[];
let
names
=
[];
const
addName
=
function
(
item
)
{
const
addName
=
function
(
item
)
{
if
(
!
u
.
hasClass
(
'
request-actions
'
,
item
))
{
if
(
!
u
.
hasClass
(
'
request-actions
'
,
item
))
{
...
@@ -1014,14 +1011,13 @@
...
@@ -1014,14 +1011,13 @@
}
}
};
};
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
spyOn
(
_converse
.
controlboxtoggle
,
'
showControlBox
'
).
and
.
callThrough
();
for
(
let
i
=
0
;
i
<
mock
.
req_names
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
mock
.
req_names
.
length
;
i
++
)
{
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
mock
.
req_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
mock
.
req_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
subscription
:
'
none
'
,
subscription
:
'
none
'
,
ask
:
null
,
ask
:
null
,
requesting
:
true
,
requesting
:
true
,
full
name
:
mock
.
req_names
[
i
]
nick
name
:
mock
.
req_names
[
i
]
});
});
}
}
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
get
(
'
Contact requests
'
).
el
.
querySelectorAll
(
'
li
'
).
length
,
700
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
get
(
'
Contact requests
'
).
el
.
querySelectorAll
(
'
li
'
).
length
,
700
);
...
@@ -1043,11 +1039,11 @@
...
@@ -1043,11 +1039,11 @@
const
name
=
mock
.
req_names
[
0
];
const
name
=
mock
.
req_names
[
0
];
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
_converse
.
roster
.
create
({
_converse
.
roster
.
create
({
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhos
t
'
,
'
jid
'
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.li
t
'
,
subscription
:
'
none
'
,
'
subscription
'
:
'
none
'
,
ask
:
null
,
'
ask
'
:
null
,
requesting
:
true
,
'
requesting
'
:
true
,
fullname
:
name
'
nickname
'
:
name
});
});
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group
'
,
_converse
.
rosterview
.
el
).
filter
(
u
.
isVisible
).
length
,
900
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group
'
,
_converse
.
rosterview
.
el
).
filter
(
u
.
isVisible
).
length
,
900
);
expect
(
u
.
isVisible
(
_converse
.
rosterview
.
get
(
'
Contact requests
'
).
el
)).
toEqual
(
true
);
expect
(
u
.
isVisible
(
_converse
.
rosterview
.
get
(
'
Contact requests
'
).
el
)).
toEqual
(
true
);
...
@@ -1080,7 +1076,7 @@
...
@@ -1080,7 +1076,7 @@
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
requesting
'
).
openControlBox
();
test_utils
.
createContacts
(
_converse
,
'
requesting
'
).
openControlBox
();
const
name
=
mock
.
req_names
.
sort
()[
0
];
const
name
=
mock
.
req_names
.
sort
()[
0
];
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
contact
=
_converse
.
roster
.
get
(
jid
);
const
contact
=
_converse
.
roster
.
get
(
jid
);
spyOn
(
contact
,
'
authorize
'
).
and
.
callFake
(()
=>
contact
);
spyOn
(
contact
,
'
authorize
'
).
and
.
callFake
(()
=>
contact
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group li
'
).
length
)
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group li
'
).
length
)
...
@@ -1088,7 +1084,7 @@
...
@@ -1088,7 +1084,7 @@
// actually not accepted/authorized because of
// actually not accepted/authorized because of
// mock_connection.
// mock_connection.
spyOn
(
_converse
.
roster
,
'
sendContactAddIQ
'
).
and
.
callFake
(()
=>
Promise
.
resolve
());
spyOn
(
_converse
.
roster
,
'
sendContactAddIQ
'
).
and
.
callFake
(()
=>
Promise
.
resolve
());
const
req_contact
=
sizzle
(
"
.req-contact-name:contains('
"
+
name
+
"
')
"
,
_converse
.
rosterview
.
el
).
pop
();
const
req_contact
=
sizzle
(
`.req-contact-name:contains("
${
contact
.
getDisplayName
()}
")`
,
_converse
.
rosterview
.
el
).
pop
();
req_contact
.
parentElement
.
parentElement
.
querySelector
(
'
.accept-xmpp-request
'
).
click
();
req_contact
.
parentElement
.
parentElement
.
querySelector
(
'
.accept-xmpp-request
'
).
click
();
expect
(
_converse
.
roster
.
sendContactAddIQ
).
toHaveBeenCalled
();
expect
(
_converse
.
roster
.
sendContactAddIQ
).
toHaveBeenCalled
();
await
test_utils
.
waitUntil
(()
=>
contact
.
authorize
.
calls
.
count
());
await
test_utils
.
waitUntil
(()
=>
contact
.
authorize
.
calls
.
count
());
...
@@ -1105,7 +1101,7 @@
...
@@ -1105,7 +1101,7 @@
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
_converse
.
rosterview
.
update
();
// XXX: Hack to make sure $roster element is attaced.
_converse
.
rosterview
.
update
();
// XXX: Hack to make sure $roster element is attaced.
const
name
=
mock
.
req_names
.
sort
()[
1
];
const
name
=
mock
.
req_names
.
sort
()[
1
];
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
contact
=
_converse
.
roster
.
get
(
jid
);
const
contact
=
_converse
.
roster
.
get
(
jid
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
contact
,
'
unauthorize
'
).
and
.
callFake
(
function
()
{
return
contact
;
});
spyOn
(
contact
,
'
unauthorize
'
).
and
.
callFake
(
function
()
{
return
contact
;
});
...
@@ -1199,7 +1195,7 @@
...
@@ -1199,7 +1195,7 @@
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group li
'
,
_converse
.
rosterview
.
el
).
length
,
700
);
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
mock
.
cur_names
.
length
;
i
++
)
{
const
name
=
mock
.
cur_names
[
i
];
const
name
=
mock
.
cur_names
[
i
];
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
const
child
=
sizzle
(
"
li:contains('
"
+
name
+
"
')
"
,
_converse
.
rosterview
.
el
).
pop
().
firstElementChild
;
const
child
=
sizzle
(
"
li:contains('
"
+
name
+
"
')
"
,
_converse
.
rosterview
.
el
).
pop
().
firstElementChild
;
expect
(
child
.
textContent
.
trim
()).
toBe
(
name
);
expect
(
child
.
textContent
.
trim
()).
toBe
(
name
);
expect
(
child
.
getAttribute
(
'
title
'
)).
toContain
(
name
);
expect
(
child
.
getAttribute
(
'
title
'
)).
toContain
(
name
);
...
...
spec/smacks.js
View file @
737e27c7
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
const
view
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
);
spyOn
(
view
,
'
renderControlBoxPane
'
).
and
.
callThrough
();
spyOn
(
view
,
'
renderControlBoxPane
'
).
and
.
callThrough
();
_converse
.
api
.
user
.
login
(
'
dummy@localhos
t
'
,
'
secret
'
);
_converse
.
api
.
user
.
login
(
'
romeo@montague.li
t
'
,
'
secret
'
);
const
sent_stanzas
=
_converse
.
connection
.
sent_stanzas
;
const
sent_stanzas
=
_converse
.
connection
.
sent_stanzas
;
let
stanza
=
await
test_utils
.
waitUntil
(()
=>
let
stanza
=
await
test_utils
.
waitUntil
(()
=>
sent_stanzas
.
filter
(
s
=>
(
s
.
tagName
===
'
enable
'
)).
pop
());
sent_stanzas
.
filter
(
s
=>
(
s
.
tagName
===
'
enable
'
)).
pop
());
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
let
iq
=
IQ_stanzas
.
pop
();
let
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="
dummy@localhost/resource" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="dummy@localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="romeo@montague.li
t" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
iq
=
IQ_stanzas
.
pop
();
iq
=
IQ_stanzas
.
pop
();
...
@@ -50,12 +50,12 @@
...
@@ -50,12 +50,12 @@
iq
=
IQ_stanzas
.
pop
();
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="
dummy@localhost/resource" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="montague.li
t" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
const
disco_iq
=
IQ_stanzas
.
pop
();
const
disco_iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
disco_iq
)).
toBe
(
expect
(
Strophe
.
serialize
(
disco_iq
)).
toBe
(
`<iq from="
dummy@localhost" id="
${
disco_iq
.
getAttribute
(
'
id
'
)}
" to="dummy@localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit" id="
${
disco_iq
.
getAttribute
(
'
id
'
)}
" to="romeo@montague.li
t" type="get" xmlns="jabber:client">`
+
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub></iq>`
);
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub></iq>`
);
expect
(
sent_stanzas
.
filter
(
s
=>
(
s
.
nodeName
===
'
r
'
)).
length
).
toBe
(
2
);
expect
(
sent_stanzas
.
filter
(
s
=>
(
s
.
nodeName
===
'
r
'
)).
length
).
toBe
(
2
);
...
@@ -74,8 +74,8 @@
...
@@ -74,8 +74,8 @@
const
disco_result
=
$iq
({
const
disco_result
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
from
'
:
'
localhos
t
'
,
'
from
'
:
'
montague.li
t
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
disco_iq
.
getAttribute
(
'
id
'
),
'
id
'
:
disco_iq
.
getAttribute
(
'
id
'
),
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
.
c
(
'
identity
'
,
{
...
@@ -115,7 +115,7 @@
...
@@ -115,7 +115,7 @@
// Test that unacked stanzas get resent out
// Test that unacked stanzas get resent out
iq
=
IQ_stanzas
.
pop
();
iq
=
IQ_stanzas
.
pop
();
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
expect
(
Strophe
.
serialize
(
iq
)).
toBe
(
`<iq from="
dummy@localhost/resource" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="dummy@localhos
t" type="get" xmlns="jabber:client">`
+
`<iq from="
romeo@montague.lit/orchard" id="
${
iq
.
getAttribute
(
'
id
'
)}
" to="romeo@montague.li
t" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`
);
iq
=
IQ_stanzas
.
pop
();
iq
=
IQ_stanzas
.
pop
();
...
...
spec/spoilers.js
View file @
737e27c7
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
async
(
done
,
_converse
)
=>
{
async
(
done
,
_converse
)
=>
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
/* <message to='romeo@montague.net/orchard' from='juliet@capulet.net/balcony' id='spoiler2'>
/* <message to='romeo@montague.net/orchard' from='juliet@capulet.net/balcony' id='spoiler2'>
* <body>And at the end of the story, both of them die! It is so tragic!</body>
* <body>And at the end of the story, both of them die! It is so tragic!</body>
...
@@ -38,8 +38,8 @@
...
@@ -38,8 +38,8 @@
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
===
2
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
===
2
);
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
vcard
.
get
(
'
fullname
'
)
===
'
M
ax Frankfurter
'
)
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
vcard
.
get
(
'
fullname
'
)
===
'
M
ercutio
'
)
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
M
ax Frankfurter
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
M
ercutio
'
);
const
message_content
=
view
.
el
.
querySelector
(
'
.chat-msg__text
'
);
const
message_content
=
view
.
el
.
querySelector
(
'
.chat-msg__text
'
);
expect
(
message_content
.
textContent
).
toBe
(
spoiler
);
expect
(
message_content
.
textContent
).
toBe
(
spoiler
);
const
spoiler_hint_el
=
view
.
el
.
querySelector
(
'
.spoiler-hint
'
);
const
spoiler_hint_el
=
view
.
el
.
querySelector
(
'
.spoiler-hint
'
);
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
async
(
done
,
_converse
)
=>
{
async
(
done
,
_converse
)
=>
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
/* <message to='romeo@montague.net/orchard' from='juliet@capulet.net/balcony' id='spoiler2'>
/* <message to='romeo@montague.net/orchard' from='juliet@capulet.net/balcony' id='spoiler2'>
* <body>And at the end of the story, both of them die! It is so tragic!</body>
* <body>And at the end of the story, both of them die! It is so tragic!</body>
* <spoiler xmlns='urn:xmpp:spoiler:0'>Love story end</spoiler>
* <spoiler xmlns='urn:xmpp:spoiler:0'>Love story end</spoiler>
...
@@ -72,8 +72,8 @@
...
@@ -72,8 +72,8 @@
await
_converse
.
chatboxes
.
onMessage
(
msg
);
await
_converse
.
chatboxes
.
onMessage
(
msg
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
===
2
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
===
2
);
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
vcard
.
get
(
'
fullname
'
)
===
'
M
ax Frankfurter
'
)
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
vcard
.
get
(
'
fullname
'
)
===
'
M
ercutio
'
)
expect
(
_
.
includes
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
,
'
M
ax Frankfurter
'
)).
toBeTruthy
();
expect
(
_
.
includes
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
,
'
M
ercutio
'
)).
toBeTruthy
();
const
message_content
=
view
.
el
.
querySelector
(
'
.chat-msg__text
'
);
const
message_content
=
view
.
el
.
querySelector
(
'
.chat-msg__text
'
);
expect
(
message_content
.
textContent
).
toBe
(
spoiler
);
expect
(
message_content
.
textContent
).
toBe
(
spoiler
);
const
spoiler_hint_el
=
view
.
el
.
querySelector
(
'
.spoiler-hint
'
);
const
spoiler_hint_el
=
view
.
el
.
querySelector
(
'
.spoiler-hint
'
);
...
@@ -88,7 +88,7 @@
...
@@ -88,7 +88,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// XXX: We need to send a presence from the contact, so that we
// XXX: We need to send a presence from the contact, so that we
// have a resource, that resource is then queried to see
// have a resource, that resource is then queried to see
...
@@ -96,7 +96,7 @@
...
@@ -96,7 +96,7 @@
// the spoiler button will appear.
// the spoiler button will appear.
const
presence
=
$pres
({
const
presence
=
$pres
({
'
from
'
:
contact_jid
+
'
/phone
'
,
'
from
'
:
contact_jid
+
'
/phone
'
,
'
to
'
:
'
dummy@localhos
t
'
'
to
'
:
'
romeo@montague.li
t
'
});
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -119,8 +119,8 @@
...
@@ -119,8 +119,8 @@
/* Test the XML stanza
/* Test the XML stanza
*
*
* <message from="
dummy@localhost/resource
"
* <message from="
romeo@montague.lit/orchard
"
* to="max.frankfurter@
localhos
t"
* to="max.frankfurter@
montague.li
t"
* type="chat"
* type="chat"
* id="4547c38b-d98b-45a5-8f44-b4004dbc335e"
* id="4547c38b-d98b-45a5-8f44-b4004dbc335e"
* xmlns="jabber:client">
* xmlns="jabber:client">
...
@@ -138,7 +138,7 @@
...
@@ -138,7 +138,7 @@
expect
(
body_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
expect
(
body_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
/* Test the HTML spoiler message */
/* Test the HTML spoiler message */
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Max Mustermann
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Romeo Montague
'
);
const
spoiler_msg_el
=
view
.
el
.
querySelector
(
'
.chat-msg__text.spoiler
'
);
const
spoiler_msg_el
=
view
.
el
.
querySelector
(
'
.chat-msg__text.spoiler
'
);
expect
(
spoiler_msg_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
expect
(
spoiler_msg_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
...
@@ -161,7 +161,7 @@
...
@@ -161,7 +161,7 @@
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
// XXX: We need to send a presence from the contact, so that we
// XXX: We need to send a presence from the contact, so that we
// have a resource, that resource is then queried to see
// have a resource, that resource is then queried to see
...
@@ -169,7 +169,7 @@
...
@@ -169,7 +169,7 @@
// the spoiler button will appear.
// the spoiler button will appear.
const
presence
=
$pres
({
const
presence
=
$pres
({
'
from
'
:
contact_jid
+
'
/phone
'
,
'
from
'
:
contact_jid
+
'
/phone
'
,
'
to
'
:
'
dummy@localhos
t
'
'
to
'
:
'
romeo@montague.li
t
'
});
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -196,8 +196,8 @@
...
@@ -196,8 +196,8 @@
/* Test the XML stanza
/* Test the XML stanza
*
*
* <message from="
dummy@localhost/resource
"
* <message from="
romeo@montague.lit/orchard
"
* to="max.frankfurter@
localhos
t"
* to="max.frankfurter@
montague.li
t"
* type="chat"
* type="chat"
* id="4547c38b-d98b-45a5-8f44-b4004dbc335e"
* id="4547c38b-d98b-45a5-8f44-b4004dbc335e"
* xmlns="jabber:client">
* xmlns="jabber:client">
...
@@ -216,7 +216,7 @@
...
@@ -216,7 +216,7 @@
expect
(
body_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
expect
(
body_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
/* Test the HTML spoiler message */
/* Test the HTML spoiler message */
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Max Mustermann
'
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
trim
()).
toBe
(
'
Romeo Montague
'
);
const
spoiler_msg_el
=
view
.
el
.
querySelector
(
'
.chat-msg__text.spoiler
'
);
const
spoiler_msg_el
=
view
.
el
.
querySelector
(
'
.chat-msg__text.spoiler
'
);
expect
(
spoiler_msg_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
expect
(
spoiler_msg_el
.
textContent
).
toBe
(
'
This is the spoiler
'
);
...
...
spec/transcripts.js
View file @
737e27c7
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +55,7 @@
_converse
.
allow_non_roster_messaging
=
true
;
_converse
.
allow_non_roster_messaging
=
true
;
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
discuss
'
,
'
conference.conversejs.org
'
,
'
dummy
'
).
then
(
function
()
{
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
discuss
'
,
'
conference.conversejs.org
'
,
'
romeo
'
).
then
(
function
()
{
spyOn
(
_converse
,
'
areDesktopNotificationsEnabled
'
).
and
.
returnValue
(
true
);
spyOn
(
_converse
,
'
areDesktopNotificationsEnabled
'
).
and
.
returnValue
(
true
);
_
.
each
(
transcripts
,
function
(
transcript
)
{
_
.
each
(
transcripts
,
function
(
transcript
)
{
var
text
=
transcript
();
var
text
=
transcript
();
...
...
spec/user-details-modal.js
View file @
737e27c7
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
>
1
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
>
1
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
...
@@ -55,7 +55,7 @@
...
@@ -55,7 +55,7 @@
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
_converse
.
api
.
trigger
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
let
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
let
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
...
@@ -75,7 +75,7 @@
...
@@ -75,7 +75,7 @@
const
header
=
document
.
querySelector
(
'
.alert-danger .modal-title
'
);
const
header
=
document
.
querySelector
(
'
.alert-danger .modal-title
'
);
expect
(
header
.
textContent
).
toBe
(
"
Error
"
);
expect
(
header
.
textContent
).
toBe
(
"
Error
"
);
expect
(
u
.
ancestor
(
header
,
'
.modal-content
'
).
querySelector
(
'
.modal-body p
'
).
textContent
.
trim
())
expect
(
u
.
ancestor
(
header
,
'
.modal-content
'
).
querySelector
(
'
.modal-body p
'
).
textContent
.
trim
())
.
toBe
(
"
Sorry, there was an error while trying to remove M
ax Frankfurter
as a contact.
"
);
.
toBe
(
"
Sorry, there was an error while trying to remove M
ercutio
as a contact.
"
);
document
.
querySelector
(
'
.alert-danger button.close
'
).
click
();
document
.
querySelector
(
'
.alert-danger button.close
'
).
click
();
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
show_modal_button
.
click
();
show_modal_button
.
click
();
...
...
src/headless/converse-core.js
View file @
737e27c7
...
@@ -1524,7 +1524,7 @@ _converse.api = {
...
@@ -1524,7 +1524,7 @@ _converse.api = {
* @example
* @example
* converse.plugins.add('myplugin', {
* converse.plugins.add('myplugin', {
* initialize: function () {
* initialize: function () {
* this._converse.api.user.login('
dummy@example.com
', 'secret');
* this._converse.api.user.login('
romeo@montague.lit
', 'secret');
* }
* }
* });
* });
*/
*/
...
...
tests/mock.js
View file @
737e27c7
...
@@ -71,15 +71,15 @@
...
@@ -71,15 +71,15 @@
// Names from http://www.fakenamegenerator.com/
// Names from http://www.fakenamegenerator.com/
mock
.
req_names
=
[
mock
.
req_names
=
[
'
Louw Spekman
'
,
'
Mohamad Stet
'
,
'
Dominik Beyer
'
'
Escalus, Prince of Verona
'
,
'
The Nurse
'
,
'
Paris
'
];
];
mock
.
pend_names
=
[
mock
.
pend_names
=
[
'
Suleyman van Beusichem
'
,
'
Nanja van Yperen
'
,
'
Nicole Diederich
'
'
Lord Capulet
'
,
'
Lady Capulet
'
,
'
Servant
'
];
];
mock
.
cur_names
=
[
mock
.
cur_names
=
[
'
M
ax Frankfurter
'
,
'
Candice van der Knijff
'
,
'
Irini Vlastuin
'
,
'
Rinse Sommer
'
,
'
Annegreet Gomez
'
,
'
M
ercutio
'
,
'
Juliet Capulet
'
,
'
Lady Montague
'
,
'
Lord Montague
'
,
'
Friar Laurence
'
,
'
Robin Schook
'
,
'
Marcel Eberhardt
'
,
'
Simone Brauer
'
,
'
Asmaa Haakman
'
,
'
Felix Amsel
'
,
'
Tybalt
'
,
'
Lady Capulet
'
,
'
Benviolo
'
,
'
Balthasar
'
,
'
Lena Grunewald
'
,
'
Laura Grunewald
'
,
'
Mandy Seiler
'
,
'
Sven Bosch
'
,
'
Nuriye Cuypers
'
'
Peter
'
,
'
Abram
'
,
'
Sampson
'
,
'
Gregory
'
,
'
Potpan
'
,
'
Friar John
'
];
];
mock
.
num_contacts
=
mock
.
req_names
.
length
+
mock
.
pend_names
.
length
+
mock
.
cur_names
.
length
;
mock
.
num_contacts
=
mock
.
req_names
.
length
+
mock
.
pend_names
.
length
+
mock
.
cur_names
.
length
;
...
@@ -154,7 +154,7 @@
...
@@ -154,7 +154,7 @@
c
.
_proto
.
_connect
=
function
()
{
c
.
_proto
.
_connect
=
function
()
{
c
.
connected
=
true
;
c
.
connected
=
true
;
c
.
mock
=
true
;
c
.
mock
=
true
;
c
.
jid
=
'
dummy@localhost/resource
'
;
c
.
jid
=
'
romeo@montague.lit/orchard
'
;
c
.
_changeConnectStatus
(
Strophe
.
Status
.
BINDREQUIRED
);
c
.
_changeConnectStatus
(
Strophe
.
Status
.
BINDREQUIRED
);
};
};
...
@@ -190,7 +190,7 @@
...
@@ -190,7 +190,7 @@
'
i18n
'
:
'
en
'
,
'
i18n
'
:
'
en
'
,
'
auto_subscribe
'
:
false
,
'
auto_subscribe
'
:
false
,
'
play_sounds
'
:
false
,
'
play_sounds
'
:
false
,
'
bosh_service_url
'
:
'
localhost
'
,
'
bosh_service_url
'
:
'
montague.lit/http-bind
'
,
'
connection
'
:
connection
,
'
connection
'
:
connection
,
'
animate
'
:
false
,
'
animate
'
:
false
,
'
use_emojione
'
:
false
,
'
use_emojione
'
:
false
,
...
@@ -214,9 +214,9 @@
...
@@ -214,9 +214,9 @@
jid
=
model
.
get
(
'
jid
'
)
||
model
.
get
(
'
muc_jid
'
);
jid
=
model
.
get
(
'
jid
'
)
||
model
.
get
(
'
muc_jid
'
);
}
}
let
fullname
;
let
fullname
;
if
(
!
jid
||
jid
==
'
dummy@localhos
t
'
)
{
if
(
!
jid
||
jid
==
'
romeo@montague.li
t
'
)
{
jid
=
'
dummy@localhos
t
'
;
jid
=
'
romeo@montague.li
t
'
;
fullname
=
'
Max Mustermann
'
;
fullname
=
'
Romeo Montague
'
;
}
else
{
}
else
{
const
name
=
jid
.
split
(
'
@
'
)[
0
].
replace
(
/
\.
/g
,
'
'
).
split
(
'
'
);
const
name
=
jid
.
split
(
'
@
'
)[
0
].
replace
(
/
\.
/g
,
'
'
).
split
(
'
'
);
const
last
=
name
.
length
-
1
;
const
last
=
name
.
length
-
1
;
...
@@ -238,7 +238,7 @@
...
@@ -238,7 +238,7 @@
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
};
};
if
(
_
.
get
(
settings
,
'
auto_login
'
)
!==
false
)
{
if
(
_
.
get
(
settings
,
'
auto_login
'
)
!==
false
)
{
_converse
.
api
.
user
.
login
(
'
dummy@localhos
t
'
,
'
secret
'
);
_converse
.
api
.
user
.
login
(
'
romeo@montague.li
t
'
,
'
secret
'
);
await
_converse
.
api
.
waitUntil
(
'
afterResourceBinding
'
);
await
_converse
.
api
.
waitUntil
(
'
afterResourceBinding
'
);
}
}
window
.
converse_disable_effects
=
true
;
window
.
converse_disable_effects
=
true
;
...
...
tests/runner.js
View file @
737e27c7
...
@@ -34,11 +34,11 @@ var specs = [
...
@@ -34,11 +34,11 @@ var specs = [
"
jasmine
"
,
"
jasmine
"
,
//"spec/transcripts",
//"spec/transcripts",
"
spec/spoilers
"
,
"
spec/spoilers
"
,
"
spec/roomslist
"
,
"
spec/profiling
"
,
"
spec/profiling
"
,
"
spec/utils
"
,
"
spec/utils
"
,
"
spec/converse
"
,
"
spec/converse
"
,
"
spec/bookmarks
"
,
"
spec/bookmarks
"
,
"
spec/roomslist
"
,
"
spec/headline
"
,
"
spec/headline
"
,
"
spec/disco
"
,
"
spec/disco
"
,
"
spec/protocol
"
,
"
spec/protocol
"
,
...
...
tests/utils.js
View file @
737e27c7
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
const
stanza
=
$iq
({
const
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
'
from
'
:
entity_jid
,
'
from
'
:
entity_jid
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
to
'
:
'
romeo@montague.lit/orchard
'
,
'
id
'
:
iq
.
getAttribute
(
'
id
'
),
'
id
'
:
iq
.
getAttribute
(
'
id
'
),
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#
'
+
type
});
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#
'
+
type
});
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
utils
.
openChatBoxes
=
function
(
converse
,
amount
)
{
utils
.
openChatBoxes
=
function
(
converse
,
amount
)
{
var
i
=
0
,
jid
,
views
=
[];
var
i
=
0
,
jid
,
views
=
[];
for
(
i
;
i
<
amount
;
i
++
)
{
for
(
i
;
i
<
amount
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
views
[
i
]
=
converse
.
roster
.
get
(
jid
).
trigger
(
"
open
"
);
views
[
i
]
=
converse
.
roster
.
get
(
jid
).
trigger
(
"
open
"
);
}
}
return
views
;
return
views
;
...
@@ -130,7 +130,7 @@
...
@@ -130,7 +130,7 @@
const
features_stanza
=
$iq
({
const
features_stanza
=
$iq
({
'
from
'
:
room_jid
,
'
from
'
:
room_jid
,
'
id
'
:
stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
'
dummy@localhos
t/desktop
'
,
'
to
'
:
'
romeo@montague.li
t/desktop
'
,
'
type
'
:
'
result
'
'
type
'
:
'
result
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
.
c
(
'
identity
'
,
{
...
@@ -254,11 +254,11 @@
...
@@ -254,11 +254,11 @@
length
=
names
.
length
;
length
=
names
.
length
;
}
}
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
jid
=
names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
;
jid
=
names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
;
if
(
!
converse
.
roster
.
get
(
jid
))
{
if
(
!
converse
.
roster
.
get
(
jid
))
{
converse
.
roster
.
create
({
converse
.
roster
.
create
({
'
ask
'
:
ask
,
'
ask
'
:
ask
,
'
full
name
'
:
names
[
i
],
'
name
'
:
names
[
i
],
'
jid
'
:
jid
,
'
jid
'
:
jid
,
'
requesting
'
:
requesting
,
'
requesting
'
:
requesting
,
'
subscription
'
:
subscription
'
subscription
'
:
subscription
...
@@ -285,7 +285,7 @@
...
@@ -285,7 +285,7 @@
if
(
type
===
'
pending
'
||
type
===
'
all
'
)
{
if
(
type
===
'
pending
'
||
type
===
'
all
'
)
{
mock
.
pend_names
.
slice
(
0
,
length
).
map
(
name
=>
mock
.
pend_names
.
slice
(
0
,
length
).
map
(
name
=>
result
.
c
(
'
item
'
,
{
result
.
c
(
'
item
'
,
{
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
name
:
include_nick
?
name
:
undefined
,
name
:
include_nick
?
name
:
undefined
,
subscription
:
'
to
'
subscription
:
'
to
'
}).
up
()
}).
up
()
...
@@ -293,7 +293,7 @@
...
@@ -293,7 +293,7 @@
}
else
if
(
type
===
'
current
'
||
type
===
'
all
'
)
{
}
else
if
(
type
===
'
current
'
||
type
===
'
all
'
)
{
mock
.
cur_names
.
slice
(
0
,
length
).
map
(
name
=>
mock
.
cur_names
.
slice
(
0
,
length
).
map
(
name
=>
result
.
c
(
'
item
'
,
{
result
.
c
(
'
item
'
,
{
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
localhos
t
'
,
jid
:
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@
montague.li
t
'
,
name
:
include_nick
?
name
:
undefined
,
name
:
include_nick
?
name
:
undefined
,
subscription
:
'
both
'
subscription
:
'
both
'
}).
up
()
}).
up
()
...
@@ -311,11 +311,11 @@
...
@@ -311,11 +311,11 @@
j
=
i
;
j
=
i
;
for
(
i
=
j
;
i
<
j
+
mock
.
groups
[
name
];
i
++
)
{
for
(
i
=
j
;
i
<
j
+
mock
.
groups
[
name
];
i
++
)
{
converse
.
roster
.
create
({
converse
.
roster
.
create
({
jid
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhos
t
'
,
'
jid
'
:
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.li
t
'
,
subscription
:
'
both
'
,
'
subscription
'
:
'
both
'
,
ask
:
null
,
'
ask
'
:
null
,
groups
:
name
===
'
ungrouped
'
?
[]
:
[
name
],
'
groups
'
:
name
===
'
ungrouped
'
?
[]
:
[
name
],
fullname
:
mock
.
cur_names
[
i
]
'
name
'
:
mock
.
cur_names
[
i
]
});
});
}
}
});
});
...
...
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